Repository navigation
Ex2
The second part of the project focuses on an algorithm that runs the Pokemon game. The game consists of 24 stages. Each stage has a different graphic shape and a number of different agents and Pokemon. The object of the game is to earn as many points as possible in as few steps as possible The Pokemon concept gets points for each Pokemon with a different weight point The number of steps is counted on each transition from vertex to vertex and on each Pokemon concept Our algorithm consists of 3 main steps The first stage is in the Init function before running the game and is the positioning of the agents at strategic points according to the largest Pokemon weights Each phase has a different number of agents and a different Pokemon number, so depending on the phase number, we will receive data unique to this phase from the server, and after receiving the data, we will know how to locate the agents. To find the list of the heaviest Pokemon we built an auxiliary function that sorts the list of Pokemon only by their weight We will also mark each Pokemon agent as one target (curr_fruit) and mark his next step in the game. The second step is during the game run the function checkifcatch checks if there is an agent who is ready to capture the Pokemon his goal i.e. if he is at the vertex that leads him to the side where the Pokemon is located If so the agent will catch the Pokemon and to reduce the number of steps on the side we used two changes one before the catch and one after the catch and until reaching the next vertex after the catch we updated the list of agents and Pokemon and the graph sides. And after the perception the setpath function sets a new trajectory for the agent who captured his Pokemon target and sets him a new Pokemon target. The third stage is responsible for the movement of agents on the graph The moveagents function runs on all existing agents and checks if they have reached their next vertex if and also calculates their next vertex in the target Pokemon trajectory and calculates the approximate time to reach the next vertex for each of them and then takes the shortest time If one of the agents reaches the next vertex in the function path, the shortest time belonging to one of the agents will change to reduce the number of steps And then we will update again the list of agents and their destination and the list of Pokemon and the sides of the graph. Thus the algorithm is divided into two main layers the movement of agents and the perception of Pokemon by an agent.