Advertisement

game ai?

Started by September 05, 2002 10:33 AM
4 comments, last by Pipo DeClown 22 years ago
Can someone help me with this: Making a game called "4 op een rij" in Dutch, dont know in English... The main goal is too fill 4 gaps with your color:

x 0 x x x x x             x x x x x x x
x $ 0 x x x x             x x x x x x x
x $ $ 0 x x 0             x x x $ $ $ x
x $ $ $ 0 x 0             x x 0 0 0 0 x
   
... where 0 wins... Well, having problems with win-checking. Anyone have any idea how this should be handled? BTW: whats the phreakin name in English? [edited by - pipo declown on September 5, 2002 11:44:34 AM]
I think it is Connect Four.

You connect four horizontal, vertical or diagonal spots with your chips/icons/etc and you win.

Simple way to check is to just start from the top left spot and go to the right. If you come across a 0, then check to the right until either you find an x, a $, or the end of the row. If you get four 0 before that, then 0 is the winner. Otherwise, no winner.

If you come across a $, then you do the same for that.
You must also check down, and also down/left and down/right.


-------------------------GBGames' Blog: An Indie Game Developer's Somewhat Interesting ThoughtsStaff Reviewer for Game Tunnel
Advertisement
How should I store the checked spot''s info?
how about this:

After each turn do the following:

check the row*, to see if there is 4 of a kind. This is done by passing through the row keeping count of peices belonging to last player until you hit an empty block or peices belonging to opposing player. THen you stop counting and reset to zero and continue looking till end of the row. if you find four in a row without hitting zero, then the last player has won.

do the same for the column and diagonals. Diagonals are gonna be tricky. they basically start at (x-min(x,y),y-min(x,y)) and on each step increase both x and y by 1.

*: by row, column and diagonal i mean the row/column/diagonal where the last player placed his/her peice. and x,y is the position on the game grid where the peices were placed.



[edited by - SporadicFire on September 5, 2002 1:30:40 PM]
Okay, I made the graphics part!



hmm, doesnt seem to work?


But Im still working on the problem...
Plz tip me orsomething!


[edited by - pipo declown on September 12, 2002 3:50:26 PM]
use src="" instead of source=""

We'll probably need to pipe it through an anonymizer, but my memory fails there:


EDIT: seem to work now

[edited by - CWizard on September 12, 2002 3:59:47 PM]

This topic is closed to new replies.

Advertisement