Defender - PrincekinNicholas/PacMan-AI-Planning GitHub Wiki
In our project, we created an agent for defence and this agent completes its defensive tasks. through the A* search algorithm. It will automatically find the optimal path to the task point through the A* algorithm. At the same time, the defender agent will change the mode to attacker agent in some cases.
In our defensive strategy, we will prefer to choose a current best target as our goal. This target will be different for different situations. At first, when the enemy attacking agent has not arrived at our position, the defender agent will wait for the enemy at the optimal position which has been chosen by itself. When the enemy starts to attack, if the defender agent can know the enemy position, it will start to defend by chasing the enemy and the target will be changed to the enemy position. If the defender agent can't know this information, it will guess where the enemy is and set that position as our defender target.
After selecting the target, we will use A* search to determine the optimal path to the target.
- Waiting Position
- When enemies are not Pacman, the defender will find the best position to protect the portals. Portals are the path that enemy attacker must pass. The best position will be the most open position which near portals.
- High-Value Position
- When an enemy is attacking and the defender can't get and guess where enemies are. At this time the defender will go to the position which has highest values in team side. The highest values position means this position is closest to every food which the defender protected.
- Guess Position
- When enemies are attacking and they eat foods the defender protected, the defender will guess enemies position by using guess position method. This method will return the position where the last position the food has been eaten.
- Mode Change
- When the attacking enemy eats the capsule, the defender will change its mode to attacking. This mode change strategy is according to game theory. Because at that time the defender is afraid of enemies, the best action it can do is to become an attacker to avoid lost. When the scare time passed half, the defender will back to the defender.