Role: Solo Developer
Skills: Unity, C#
Platform: PC
Status: Finished
Description: Given the base game (which is similar to the classic bomber man), our job as participants is to create an AI that can win the game by either killing all the enemies in the scene, or be the first to collect the diamond and deliver it to the goal. This was part of an event at my University, and I ended up at 2nd-place with 6 points (1 point behind first-place who got 7 points and 3 points ahead of 3rd-place who got 3 points).
Link to AI script: AI Script
Link to project with AI: AI Battle
Credit: Jonathan Dearborn and David Carrigg for providing the base project.
The video above shows two AIs competing with each other to try to be the last winner. Both AIs use the same script that I wrote for the competition, which is the TestAI script.
AI Logic: (Ordered by priority level)
When the turn first starts, the AI will scan the surrounding areas (current position, up, left, down, and right), and store what is currently occupying the space (empty, wall, off-grid, goal, diamond, bomb, or enemy).
Every time the AI makes a move, it stores the moves it took from the starting position to its position so that this information can be used again when trying to go back to any given position.
If the AI spots the goal and has the diamond, the AI will move to the goal and end the game. If it doesn't have the diamond, it will store the position information of the goal so that once it finds the diamond, it can go back to the goal.
If the AI spots the diamond, the AI will move toward the diamond.
If there is a bomb nearby, run to a space where the bomb can't kill the AI.
If there is an enemy nearby, place a bomb then run away from it.
If the AI is surrounded by empty spaces on all sides, the AI will check for walkable space, and it follows the order of up, left, down, and right. This means that it will first try to go up, if going up isn't an option (maybe it's a wall or off-grid), it will go left, so on and so forth.
Things to keep in mind:
Since the AI keeps track of the positions it traveled to, it will not go to the same space ever again unless it reaches a dead end. If the AI reaches a dead end, it will go back to the space where it came from, eliminate the move that it just took, and look for other options.
Once the diamond is found and the AI knows where the goal is, it will first go back to the starting position, then moves toward the goal position.
The AI can move however many spaces I want, but I can either make a move or drop a bomb.
Room for improvement:
If the AI entered like a tunnel where going up is the only option, it will keep going up until it reaches the dead end. Once it reaches the dead end, it will start going back to the previous position. But since it's in a tunnel, the AI will have to go back one space at a time, which wastes a lot of time. What I could have done instead is to store how many walkable spaces each space has, and if the AI reaches the dead end, it will go back to the last space that has at least one walkable space, which is the space before the AI entered the tunnel.
There is really no need to go back to the starting position and then go to the goal position. Although it doesn't affect the performance of the AI, the AI is still making unnecessary moves that could be and should be improved in real-life applications.