About a month or so ago, Sega came out with “Puyo Puyo Quest”, a smartphone “Puzzle RPG” from the Puyo Puyo franchise. It has become my latest public transport timekiller.
On the bottom half of the screen, you clear away up to 5 puyos with a swipe (linked horizontally, vertically or diagonally). Gravity influences the remaining puyos, and any blocks of four or more puyos of the same colour (linked horizontally, vertically but not diagonally) are removed, and add to your characters’ attack. Gravity continues to take effect and more puyos fall to fill in the gaps. Repeat.
After playing this for a while, I’ve gotten to the stage where the bosses of each quest have an abnormally high HP (I wonder whether they’re just trying to make you fail in order to pay for “magic stones” that let you continue). Since it’s getting hard to pass normally, I thought I’d try to write a program for this problem.
Basically the program reads in the grid from a text file. It then goes through all possibilities of removing puyos, and simulates the outcome. The program reports back the move which gives the highest “score”, as well as the move with the largest combo.
You may notice that the input file on the left has a few extra lines before the grid. This is because clearing a certain colour only adds attack to characters of that colour. Since I had no purple or blue characters, linking four or more blue/purple puyos together would do nothing. The extra lines of input are meant to represent the attacking power of my party corresponding to each colour, and the “score” of each move is then calculated based on this, along with other factors such as how many puyos of each colour were removed.
There were also a few game-related quirks to be taken into consideration. The heart piece, for example, disappears when an adjacent group of puyos disappear (the heart heals characters). In addition, the row of small coloured circles above the board indicate the next colour to fall in that column. These weren’t particularly hard to deal with, but it did take some thinking.
Currently my program is not very efficient – you’re allowed to remove up to 5 puyos at once, but my program is only fast enough to calculate removing 3 in a reasonable time. On the bright side, that’s good enough for most practical purposes. Although, despite saying that, having to type out the game board into the text file each time is pretty painful.