Here is a description of the AI currently implemented in the game.
So far, we achieved 4 levels of AI : sandbox, challenging, hardcore, impossible. Their only differences lies in how attentive they are to the progression of the leader player (means the closest to achieve its objective) :
Sandbox doesn't care about you, the AI just tries to reach its destination.
Challenging might care about you, if you are at the same distance of the objective as the AI, a random value will allow the computer to annoy you.
Hardcore is always watching you : the leader player become the target. Winning isn't impossible, though. One of the way to win is to keep being at the same distance as the leader (at least for the last moves), which may give you the time to complete the game from 1 or 2 steps of the end if the leader is being pushed away from its path.
Impossible might not be really impossible neither since the AI is not perfect. Still, it will give you a pretty hard time because the target is not only the one who's closer to the goal, but also the one that's getting close to the AI in terms of chances to win. This means the AI will systematically try to be the leader player. Unfortunately this difficulty leads to looooonnng games and without the help of the "powers" it will be boring... Don't worry about this though. We already have designed a bunch of them, it will be fun.
I can't remember the name of the algorithm, i only remember i saw that in on of my courses.
It analyses the labyrinth in depth (which is not 100% optimized but fast to implement, though actually this is not a problem and will be fixed relatively quickly) and "weight" the cells.
Here is how it works :
- Set the default weight of the cells as infinite.
- Set the weight of the cell considering the number of cells you analyzed from the starting point.
- List the accessible cells from the current one.
- For all children cells :
- If no more cells are accessible then it goes back to the parent cell.
- Set the parent of the child cell as the current cell.
- If the weight of the child cell is not set or already set and greater than the one we will apply, go to the second step with child cell as current cell.
Once the cells are weighted, finding your way is easy. Pick a destination and go from parent cells to parent cells to reach the origin. Here is the path!
This is kind of a light AI algo since the pathfinding system doesn't care about the fact we can move the lines. For example, if it is in the top left corner and wants to access the bottom right corner, it will go through all the labyrinth instead of using the lines to access quickly the destination by insertion.
But the AI is still challenging because it's able to mess with the leader player, which gives it enough time to do its way. Moreover, if the way is unreachable it's able to move the lines correctly to reach its destination.
The game will be more interesting with the bonus, even against an AI, and should give the necessary rhythm to keep the player active, even outside his turn.
I'm still an AI amateur, i only do all of this from some websites advices and some logic. Soon (some months) i'll be able to access Intelligent Systems lessons, which will give me better knowledge. This AI will then undergo many improvements.
Stay tunned ;)