Monthly Archives: May 2013

The Puyo Puyo Puro-gram

Why anybody would put a match-n game like this under the “Puzzle” category confuses me

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.

Some input and output corresponding to the screenshot above

Some input and output corresponding to the screenshot above

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.

Song database, part 1

It works!

It’s been two months already – surely I haven’t been so busy that I’ve been too preoccupied to do any new projects?

Well actually, I have. I think I’ve been having too much fun with these Rhythm Heaven videos. Although, despite saying that, I’ve got about one or two more in progress as of writing.

But anyway, here’s a different project which I just hacked up today. Since I’m doing databases at uni this semester, I decided to make a song database. It’s meant to store all the key signatures, BPMs and time signatures that I would need to know about a song in order to include it in a medley. Currently that info is contained inside an Excel spreadsheet, which is a little inconvenient in terms of searching and sorting.

Setting up the database (I’m on Hostgator) wasn’t too hard, but I had to use the interface of phpMyAdmin since I didn’t know the syntax for MySQL. I’m sure it’s similar to PostgreSQL though, PostgreSQL being the system used by my university. Admittedly I jumped a few steps when setting up – I was too lazy to design the database properly.

After creating the database I tried connecting to it via PHP, and made it generate a table displaying all the songs I had so far in the database. It took a few tries, but the screenshot at the top shows how it turned out. Pretty good. I had to add a few extra things to make the Japanese song names show instead of the previous question marks though – something about UTF-8 character encoding.

Currently, I only have a single table of songs which you can see, although there’s more tables in the database internally. I’m planning on making the songs/artists/origins hyperlinks, so that when you click on them you can get more information. And then I’m adding a search bar so that you can search for songs based on name/artist/origin. If I’m feeling ambitious, I might even make it so that I have my own interface for adding/modifying/deleting songs (phpMyAdmin isn’t great). And if I’m feeling ultra ambitious I might add a feature for creating custom song lists, to help with medley making.

Well, that’s the plan. I don’t know how long that will take though.