Advertisement

AI For Puzzle Games

Started by January 15, 2005 09:46 PM
2 comments, last by Nice Coder 19 years, 10 months ago
I'm new to the AI forums, and haven't posted here once. I have taken a course in data structures, and I covered a little searching and I understand A*, if you consider that AI. I'm making a puzzle game, and my AI has been pretty sad so far. Basically, the game play is a lot like tetris, except instead of making rows, the goal is to make different shapes out of triangle-shaped pieces. Basically you have a triangle like:

  //\\ 
 //  \\  
//____\\


and the goal is to make different pieces out of the triangles like squares, pyramids, (more shapes to come), so it the pieces would look like:

______
\    /|
|\  / |
| \/  |
| /\  |
|/  \ |
/____\|
(a square)

      //\\
     //  \\
    //____\\
   //\\    //\\
  //  \\  //  \\
 //____\\//____\\
(a pyramid)






Player play on a regular tetris-like area, but there is also a computer player who will challenge you. The only thing I've been able to come up with is hard-coding the AI, and it worked out pretty good for a square. But I think that hard-coding it is really a bad idea, especially because it will need to be re-implemented for every new shape. Does anyone have any idea as to what sort of AI I should be looking into in order to solve this problem? Any help would be greatly appreciated. [EDIT: Fixed the ASCII ART]
Ok, my take of the game:

You get a triangle, you then transpose it (like shove it upside down), and put it in a spot on the grid.

There is a time limit on that.

heres my take on your solution.

You find out, each possible piece which you can drop. (for eg. an upside down triangle on the 6th square), and you find a value for it.

That value, is the utility, for eg. if you make a shape, it has a heigher utility, then one that doesn't. (you'll ahve to make one, for each possible shape).

Also, if you stop a possible shape, then you give it a lower priority, then one that didn't stop the shape.

Simple maximum, and you've got yourself a goodish bot, for the entirity of 30seconds it took to come up with the design.and the minute it takes to implement it.

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
Advertisement
Quote: Original post by Nice Coder
Ok, my take of the game:

You get a triangle, you then transpose it (like shove it upside down), and put it in a spot on the grid.

There is a time limit on that.

heres my take on your solution.

You find out, each possible piece which you can drop. (for eg. an upside down triangle on the 6th square), and you find a value for it.

That value, is the utility, for eg. if you make a shape, it has a heigher utility, then one that doesn't. (you'll ahve to make one, for each possible shape).

Also, if you stop a possible shape, then you give it a lower priority, then one that didn't stop the shape.

Simple maximum, and you've got yourself a goodish bot, for the entirity of 30seconds it took to come up with the design.and the minute it takes to implement it.

From,
Nice coder

Thanks for the reply. I was thinking I'd need to do something like looking at all of the different possible outcomes and assigning a value to each one, then placing the triangle in the position that has the greatest value. I just wanted someone else's opinion on the matter to see if there was a better way to do it.
You could use A*, just make up a version, which generates the greatest path cost. (ie. nodes have a + weighting, and moving from one to another has a - weighting.).

You then just search for the best path in the time you have (No definite goal, just keep searching).

Then you place it where it needs to go.

With a good enough heuristic, it could search massivelly ahead, and still return moderatly fast. (not in the nanosecond range, just less then a second, The longer you give it, the better the path will be.).

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.

This topic is closed to new replies.

Advertisement