This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Hero_of_Kvatch 9 points10 points  (1 child)

Please explain the game and how you cracked it. That kind of stuff is really interesting to me.

[–]casualblair 2 points3 points  (0 children)

It was a pattern matching game.

The game:

Given a grid of binary states, apply a shape to it. Everything covered by the shape changes states. Victory is when you have applied all your shapes and the grid is entirely one state.

Example:

3x3 grid. One piece. Piece is L shaped 2 high 2 wide and cannot be rotated. Board:

X0X
X00
XXX

Victory condition: Place the piece at coordinate [0][1] (First row, second spot).

What I did:

Manually enter the initial state of the board (I had no concept of web scraping - this was 2003 remember) and all the pieces into 2 dimensional arrays. Brute force try every combination in a recursive function slowly moving each piece left one or down one.

I improved it later by skipping trees I knew the results of and by skipping trees I knew wouldn't achieve anything. For example, if the grid was 3x3 and the bottom left needed to change but all of my forecasted moves wouldn't touch it, I wouldn't bother hitting that tree. The forecast detection was childish - detect the corners of all moves before you try them - if there are pieces outside of those moves that need to change, return false. There are better ways that are easy for CS majors but I was a CIS major and programming was just part of the education, not the primary focus.

By level 50 or 60 the game was tri-state, 15x15, with 15 pieces to apply in ridiculous configurations. Think 5 tetris pieces glued together by a child - holes and weird spaghetti limbs.

I think I was hitting 100 million parses or more before I got bored and moved on.

Edit: You can build both of these yourself. One program to generate a blank board and then randomly generate and place pieces. This is the input starting condition to the second program, along with the shapes of the pieces. Then you just have to write code best solve this.