Use the Autoplay toggle to switch between automatic and manual move progression. If Autoplay is disabled, use the spacebar to progress.
This is an AI that I have programmed to play Slices, a mobile game created by Midnite and Good Job. AFAIK, this is the first time someone has done this. I used to play this game on my phone all the time, and I developed a great strategy. But before I can explain my strategy , I have to first explain how Slices works. There are 6 circles (or pies) forming a ring around a circle in the center. Each circle is divided into 6 parts (or slices). The circle in the center shows the current slice. The slice can contain up to 3 smaller slices. These smaller slices will always be adjacent to each other. The player's goal is to determine which pie the current slice should be inserted into. The slice cannot be rotated, so the pie in question must have an empty spot that matches the current slice. If there are no pies that can accept the slice, the game is over. For every slice that is successfully inserted into a pie, the score increases. Points are awarded based on how many smaller slices were in the inserted slice (Ex: if the inserted slice is made up of 2 smaller slices, 2 points are awarded). If a pie is full of slices, it will be cleared and will increase the score by 6 (for each slice). It will also clear the pies adjacent to it, and will increase the score further based on the number of slices in the adjacent pies (Ex: if a pie is completed that has a 5-slice pie and a 3-slice pie next to it, the score will be increase by 6+5+3, or 14). Because the current slice is randomly determined, the game could last anywhere from a few seconds to an exponential amount of time. The lowest score you can get is 6, and the highest score I've ever seen was about 670. Alternate modes award points based on how many pies you have completed. In the original game, there's a feature that shows you what the next slice will be (similar to the way Tetris shows you the next tetromino), but I couldn't think of any way to implement that into the AI's algorithm. That reminds me, I haven't explained how the AI works yet! OK, so there are three filters, or layers, that the AI sorts the pie list (basically just a list of the six pies and the slices that they have) through. The first layer is the most simple. All it does is find the pies that can accept the current slice. If there are none, the game ends. If there is only one pie, the slice is sorted into that pie. But if there is more than one pie, the next filter is fired up. The second filter is a bit more complex. This filter determines the amount of slices in each open pie. The pies that have the most slices are gathered up and added to a new list. If there is only a single pie in the new list, then the slice is sorted into that pie. If there are several pies in the new list, the final filter is activated. The third filter is the most complex of the three. This one calculates the total number of slices in neighboring pies for each pie in the previous filter's list. The pie who's adjacent pies have the most slices wins. If more than one pies have the same number of adjacent slices, then the pie that the slice is sorted into is chosen at random. Keep in mind that even with a perfect AI, this is still a game of luck. Using this method will, on average, result in significantly higher scores than just random choices, but it's still just up to chance. Please report any bugs, and Love/Favorite this project if you liked it. Production time: 8 hours (or so)