A89: question about connect-4
[Prev][Next][Index][Thread]
A89: question about connect-4
If I was doing connect 4 for my next game would it be better to check every
possible 4 in a row situation...say if for example i have variables named bw1
through bw64 (8X8 grid) and if a white piece is used then you will store 1
into that variable according to where it is placed and if a black piece is
used the you will store 10 into that variable according to where it is
placed...get it? Now everytime I "drop" a chip do i check ALL the possible 4
in a row situations...ie:
the grid will look like this:
bw1 / bw9 / bw17/
bw2 / bw10 / ... /
bw3 / bw11 / /
bw4 / bw12 / /
bw5 / bw13 / /
bw6 / bw14 / /
bw7 / bw15 / /
bw8 / bw16 / / / / / / bw64 /
move.w bw1,d0 ; check if 4 are vertically going down
add.w bw2,d0
add.w bw3,d0
add.w bw4,d0
cmp.w 40,d0
beq BLACK_WINS
cmp.w 4,d0
beq WHITE_WINS
;-------------------------check different section-------------------
move.w bw2,d0 ; check if 4 are vertically down starting at bw2
add.w bw3,d0
add.w bw4,d0
add.w bw5,d0
cmp.w 40,d0
beq BLACK_WINS
cmp.w 4,d0
beq WHITE_WINS
...
...
...
And do I keep doing this about 200 times or do i break it into sections? For
example only check a certain category according to where the chip was placed
ie:
if chip is placed in column 1 then check columns 1-4
if chip is placed in column 2 then check columns 1-5
if chip is placed in column 3 then check columns 1-6
if chip is placed in column 4 then check columns 1-7
if chip is placed in column 5 then check columns 2-8
if chip is placed in column 6 then check columns 3-8
if chip is placed in column 7 then check columns 4-8
if chip is placed in column 8 then check columns 5-8
but does it really matter if i check everything all at once rather than
checking only certain columns??? Would it take less mem to check different
column rather than checking everything??? I know it would be faster checking
the columns but does it really need to be FAST??? Wouldn't it still be PLENTY
fast if i just check everything...i mean it won't slow everything down
right???
thanks
-Steven Reagan
Follow-Ups: