Jump to content
  • entries
    53
  • comments
    536
  • views
    68,391

Four-Play with simple AI


Guest

621 views

I've applied the classic minimax search to Four-Play, and I'm pleased with the results. The program will anticipate any traps within 7 moves and act accordingly. I was concerned that it might take a long time to search 7 moves ahead, but it turned out not to be too bad.The AI is not terribly difficult to beat at this point because the heuristics are simple. The search just checks whether there is a winning position or not. The next step will be to apply some more sophisticated heuristics, and then the game should be challenging.At the present time, you can only play red, and the Atari plays blue. Have fun!post-4261-1067814904_thumb.jpg

9 Comments


Recommended Comments

Pretty nice. How are you doing the four-in-a-row checks? And how many cycles per 'loop' does your AI take?

 

Keeping vertical sync while 'thinking' is nice if you can manage it? Z26 shows 265 lines during the thought process. If you're kinda sorta keeping vertical sync (but off by a few lines) it might be nice to also show a 'thinking' message or progress indication. Don't want to do anything that would take too much CPU time of course, but something quick might be nice.

Link to comment
Pretty nice.  How are you doing the four-in-a-row checks?  And how many cycles per 'loop' does your AI take?

 

Keeping vertical sync while 'thinking' is nice if you can manage it?  Z26 shows 265 lines during the thought process.  If you're kinda sorta keeping vertical sync (but off by a few lines) it might be nice to also show a 'thinking' message or progress indication.  Don't want to do anything that would take too much CPU time of course, but something quick might be nice.

The method for checking for 4 in a row is straightforward. A 49 byte block of RAM represents the board with one byte for each cell. Every time a new piece falls in, the computer scans the row, column, and two diagonal lines that intersect the piece's position. Of course it keeps a count of the number of pieces in a row it finds. Scanning the column is fastest because it only needs to check the 3 pieces immediately underneath.

 

You're right about the vertical sync. I've seen z26 report 48 and 999 line frames, and the picture jumps badly on my TV. The 265 line frames are not bad; in fact Video Chess displays the same number of lines during its thinking state.

Link to comment

Very impressive work, and it looks like you are still using only around 2K! I assume it will be possible to vary the depth of the search to enable different skill levels? As pointed out previously, the loss of sync while thinking is slightly annoying. If it is not possible to fit everything between screen refreshes, then you could set a timer, and check it periodically during the thinking time to see if the screen needs to be refreshed? I am looking forward to seeing this completed. At this rate you will soon be able to release a minigame cart containing just your puzzle games!

 

Chris

Link to comment
I'm just no good at this game.  Lost my first match, too.  Fun, though, and nicely done.  :)

 

Here's a hint. It's impossible to get a horizontal or diagonal win without a piece in the center column.

Link to comment
BTW: Why are there 7 rows? The ones I know have only 6.

The short answer is, why not? The long answer is I wanted to set up a framework for future games, and more games are played on a 7x7 board than 7x6.

 

One interesting result is a change in the advantage for red. On a 7x6 board, it has been shown that with perfect play, red can force a win. For 7x7, red can only force a draw. Source. Note that making unbeatable AI is beyond the scope of the project.

Link to comment
Here's a hint. It's impossible to get a horizontal or diagonal win without a piece in the center column.

Hehe, I know how to play this game. Actually I lost my first game (probably unestimating the AI strength) and only one more game after that. :)

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...