Post by yoric on Apr 18, 2006 10:49:17 GMT -5
:)Here is the latest on 'Double Cross' from Yoric.
The AI is only 'thinking' at the first level, so the computer is not very difficult to defeat:
dim boardR (9, 9), boardG (9, 9), brdC(9,9)
dim com, bx, by, uu, dd, ll, rr
dim x, y, xl, yl, xd, yd, xc, yc, sc, scp, cl1, cl2
dim char$, start$, Play$, Player$, Result$, Game$, Rdm$
dim xdr, ydr, scr, spr, spg, scg, xdg, ydg, Ox, Oy
dim Pass, up, down, left, right, move, Ca, Cb, Cc
xdr = 2: ydr = 6: spr = 6
xdg =29: ydg = 6: spg = 32
Gosub Open
color (255, 255,255)
locate 12, 0: print "* Double Cross *"
color (0, 0, 255)
locate 4, 2: print "Left-Click a ball for directions"
locate 0, 3: print "Hold Cursor Key and Left-Click Selection"
locate 17, 5: print "score "
locate 10, 23: print "Press return to Esc"
color (255, 0, 0)
for y = 3 to 5
for x = 1 to 7
locate x + xdr, y + ydr: print "O"
next
next
for y = 1 to 7
for x = 3 to 5
locate x + xdr, y + ydr: print "O"
next
next
locate xdr + Ox, ydr + Oy: print "+"
color (0, 255, 0)
for y = 3 to 5
for x = 1 to 7
locate x + xdg, y + ydg: print "O"
next
next
for y = 1 to 7
for x = 3 to 5
locate x + xdg, y + ydg: print "O"
next
next
locate xdg + Ox, ydg + Oy: print "+"
color (0, 0, 255)
locate 11,22: input "Play first R or G"; Player$
locate 12, 18: print "End key to pass"
locate 13, 20: print "Three Passes"
Locate 13, 21: print "Ends the game"
gosub Player
TextMode (TEXT_BUFFERED)
Play:
locate 10,22: ClearLine ()
if Player$ = "r" then color (255, 0, 0)
else color (0, 255, 0) endif
locate 15, 17: print Player$ + " to play"
locate 14, 19: print "Passes = " + pass
gosub brdC
DrawText ()
if Player$ = "g" and com then gosub compute: goto Play endif
while true
if not Mouse_Button (MOUSE_LBUTTON) then
locate x, y
endif
x = Mouse_X () * TextCols ()
y = Mouse_Y () * TextRows ()
xl = x - xd: yl = y - yd
if xl < 0 or xl > 7 or yl < 1 or yl > 7 then xl = 0 endif
if yl < 0 or yl > 7 or xl < 1 or xl > 7 then yl = 0 endif
char$ = CharAt$ (x, y)
locate 13, 16: color (cl1, cl2, 0): print "X = " + xl; " " "Y = " + yl: Sleep (100)
if ScanKeyDown (VK_END) then pass = pass + 1: goto change endif
if ScanKeyDown (VK_RETURN) then goto finish endif
if Mouse_Button (MOUSE_LBUTTON) then gosub Check: endif
DrawText ()
wend
Check:
if Player$ = "r" and x > 20 then return endif
if Player$ = "g" and x < 20 then return endif
if CharAt$(x, y) = "O" and CharAt$(x, y - 1) = "O" and CharAt$(x, y - 2) = "+" then
locate xd, 17: color (0, 0, 255): print "Up OK" : up = true:
else locate xd, 17: color (cl1, cl2, 0): print "Up No": up = false
endif
if CharAt$(x, y) = "O" and CharAt$(x, y + 1) = "O" and CharAt$(x, y + 2) = "+" then
locate xd, 18: color (0, 0, 255): print "Down OK": down = true:
else locate xd, 18: color (cl1, cl2, 0): print "Down No": down = false
endif
if CharAt$(x, y) = "O" and CharAt$(x - 1, y) = "O" and CharAt$(x - 2, y) = "+" then
locate xd, 19: color (0, 0, 255): print "Left OK": left = true:
else locate xd, 19: color (cl1, cl2, 0): print "Left No": left = false
endif
if CharAt$(x, y) = "O" and CharAt$(x + 1, y) = "O" and CharAt$(x + 2, y) = "+" then
locate xd, 20: color (0, 0, 255): print "Right OK": right = true:
else locate xd, 20: color (cl1, cl2, 0): print "Right No": right = false
endif
if not up and not down and not left and not right then move = false
endif
DrawText ()
if com and Player$ ="g" then gosub Score: return endif
Cursor:
color (cl1, cl2, 0)
if ScanKeyDown (VK_END) then pass = pass + 1: goto change endif
if ScanKeyDown (VK_UP) and up then gosub up endif
if ScanKeyDown (VK_DOWN) and down then gosub down endif
if ScanKeyDown (VK_LEFT) and left then gosub left endif
if ScanKeyDown (VK_RIGHT) and right then gosub right endif
if move then gosub Check endif
gosub brdC: gosub Score: return
Score:
locate scp, 5: print sc
if Player$ = "r" then scr = sc endif
if Player$ = "g" then scg = sc endif
DrawText ()
return
up:
if Player$ = "r" then boardR (xl, yl) = 1: boardR (xl, yl - 1) = 1
boardR (xl, yl - 2) = 2: boardG (xl, yl - 1) = 1 endif
if Player$ = "g" then boardG (xl, yl) = 1: boardG (xl, yl - 1) = 1
boardG (xl, yl - 2) = 3: boardR (xl, yl - 1) = 1 endif
locate x, y: print "+": locate x, y - 1: print "+": locate x, y - 2: print "O"
if Player$ = "r" then locate xl + xdg, y - 1: color (0, 255, 0): print "+" endif
if Player$ = "g" then locate xl + xdr, y - 1: color (255, 0, 0): print "+" endif
sc = sc + 1: y = y - 2: yl = yl - 2: pass = 0: gosub brdC
ClearKeys (): Sleep (50): gosub check
if up or down or left or right then move = true: return
else gosub change endif
DrawText ()
return
down:
if Player$ = "r" then boardR (xl, yl) = 1: boardR (xl, yl + 1) = 1
boardR (xl, yl + 2) = 2: boardG (xl, yl + 1) = 1 endif
if Player$ = "g" then boardG (xl, yl) = 1: boardG (xl, yl + 1) = 1
boardG (xl, yl + 2) = 3: boardR (xl, yl + 1) = 1 endif
locate x, y: print "+": locate x, y + 1: print "+": locate x, y + 2: print "O"
if Player$ = "r" then locate xl + xdg, y + 1: color (0, 255, 0): print "+" endif
if Player$ = "g" then locate xl + xdr, y + 1: color (255, 0, 0): print "+" endif
sc = sc + 1: y = y + 2: yl = yl + 2: pass = 0: gosub brdC
ClearKeys (): Sleep (50): gosub check
if up or down or left or right then move = true: return
else gosub change endif
DrawText ()
return
left:
if Player$ = "r" then boardR (xl, yl) = 1: boardR (xl - 1, yl) = 1
boardR (xl - 2, yl) = 2: boardG (xl - 1, yl) = 1 endif
if Player$ = "g" then boardG (xl, yl) = 1: boardG (xl - 1, yl) = 1
boardG (xl - 2, yl) = 3: boardR (xl - 1, yl) = 1 endif
locate x, y: print "+": locate x - 1, y: print "+": locate x - 2, y: print "O"
if Player$ = "r" then locate xl + xdg - 1, y: color (0, 255, 0): print "+" endif
if Player$ = "g" then locate xl + xdr - 1, y: color (255, 0, 0): print "+" endif
sc = sc + 1: x = x - 2: xl = xl - 2: pass = 0: gosub brdC
ClearKeys (): Sleep (50): gosub check
if up or down or left or right then move = true: return
else gosub change endif
DrawText ()
return
right:
if Player$ = "r" then boardR (xl, yl) = 1: boardR (xl + 1, yl) = 1:
boardR (xl + 2, yl) = 2: boardG (xl + 1, yl) = 1: endif
if Player$ = "g" then boardG (xl, yl) = 1: boardG (xl + 1, yl) = 1:
boardG (xl + 2, yl) = 3: boardR (xl + 1, yl) = 1: endif
locate x, y: print "+": locate x + 1, y: print "+": locate x + 2, y: print "O"
if Player$ = "r" then locate xl + xdg + 1, y: color (0, 255, 0): print "+" endif
if Player$ = "g" then locate xl + xdr + 1, y: color (255, 0, 0): print "+" endif
sc = sc + 1: x = x + 2: xl = xl + 2: pass = 0: gosub brdC
ClearKeys (): Sleep (50): gosub check
if up or down or left or right then move = true: return
else gosub change endif
DrawText ()
return
again:
if right then gosub right endif
if left then gosub left endif
if down then gosub down endif
if up then gosub up endif
Gosub brdC
if move then goto again endif
DrawText ()
return
Player:
if Player$ = "r" then xd = xdr: yd = ydr: sc = scr: scp = spr
cl1 = 255: cl2 = 0 endif
if Player$ = "g" then xd = xdg: yd = ydg: sc = scg: scp = spg
cl1 = 0: cl2 = 255 endif
return
Change:
up = false: down = false: left = false: right = false
if Player$ = "r" then Player$ = "g"
else Player$ = "r"
endif
if pass > 2 then goto Result endif
gosub Player: goto Play
Result:
if scr > scg then color (255, 0, 0): Result$ = "Red Victory" endif
if scr < scg then color (0, 255, 0): Result$ = "Green Wins" endif
if scr = scg then color (0, 0, 255): Result$ = "Game Drawn" endif
locate 14, 22: ClearLine ()
locate 14, 22: print Result$
Finish:
color (0, 0, 255): locate 10, 23: ClearLine ()
locate 8, 23: input "play again? (y, or esc)"; Play$
if Play$ = "y" then run
else goto Finish endif
Open:
color (255, 0, 0)
locate 11, 1: print "** Double Cross **"
locate 13, 3: print "Solitaire Duel"
color (255, 255, 255)
locate 0, 6: print "Pieces occupying similar board positions"
locate 5, 7: print "are eliminated simultaneously."
locate 0, 9: print "If the capturing piece is in a position"
locate 0, 10: print "to continue capturing then it may do so."
locate 6, 11: print "Simply use the cursor keys."
color (0, 255, 0)
locate 1, 14: print "The computer plays on the green board."
locate 6, 16: input "Computer Opponent Y or N"; Game$ ' "z" to see brdC() on screen
if Game$ = "y" or Game$ = "z" then com = true endif
color (255, 255, 255)
locate 2, 19: Print "Any key for a blank centre start, or"
locate 6, 21: input "enter R for a random start"; Rdm$
if Rdm$ = "r" then Ox = Rnd()%7+1: Oy = Rnd()%3+3 else Ox = 4: Oy = 4 endif
Board:
for bx = 0 to 8
for by = 0 to 8
boardR (bx, by) = 0
boardG (bx, by) = 0
next
next
for bx = 3 to 5
for by = 1 to 7
boardR (bx, by) = 2
boardG (bx, by) = 3
next
next
for bx = 1 to 7
for by = 3 to 5
boardR (bx, by) = 2
boardG (bx, by) = 3
next
next
boardR (Ox, Oy) = 1
boardG (Ox, Oy) = 1
Sleep (100): cls: return
brdC:
color (0, 0, 0)
if game$ = "z" then color (cl1, cl2, 0) endif
for bx = 0 to 8
for by = 0 to 8
brdC(bx,by) = boardR (bx, by) + boardG (bx, by)
next
next
xc = 15: yc = 6
for bx = 0 to 8
for by = 0 to 8
locate bx + xc, by + yc: print brdC(bx,by)
next
next
for bx = 3 to 5
for by = 1 to 7
locate bx + xc, by + yc: print brdC(bx,by)
next
next
for bx = 1 to 7
for by = 3 to 5
locate bx + xc, by + yc: print brdC(bx,by)
next
next
DrawText ()
color (cl1, cl2, 0)
return
compute:
move = false: uu = 6: dd = 2: ll = 6: rr = 2: gosub compC
if not move then uu = 5: dd = 3: ll = 5: rr = 3: gosub compC endif
if not move then uu = 4: dd = 4: ll = 4: rr = 4: gosub compC endif
if not move then uu = 3: dd = 5: ll = 3: rr = 5: gosub compC endif
gosub Score: gosub Change: gosub Player
return
compC:
Ca = 5: Cb = 5: Cc = 2: gosub compA
if not move then Ca = 4: Cb = 5: Cc = 2: gosub compA endif
if not move then Ca = 5: Cb = 4: Cc = 2: gosub compA endif
if not move then Ca = 4: Cb = 4: Cc = 2: gosub compA endif
if not move then Ca = 5: Cb = 5: Cc = 3: gosub compA endif
if not move then Ca = 4: Cb = 5: Cc = 3: gosub compA endif
if not move then Ca = 5: Cb = 4: Cc = 3: gosub compA endif
if not move then Ca = 4: Cb = 4: Cc = 3: gosub compA endif
return
compA:
for bx = 1 to 7
for by = 7 to uu step -1
if brdC(bx,by)=Ca and brdC(bx,by-1)=Cb and brdC(bx,by-2)=Cc then up = true endif
if up and not move then
x = bx + xdg: y = by + ydg: xl = bx: yl = by: bx = 7: by = uu endif
next
next: if xl = bx and bx > 7 then x = x - 1: xl = xl - 1 endif
if up and yl = by and by < uu then y = y + 1: yl = yl + 1 endif
if up then up = false: gosub up: gosub brdC: move = true endif
if up or down or left or right then gosub again: return endif
for bx = 1 to 7
for by = 1 to dd
if brdC(bx,by)=Ca and brdC(bx,by+1)=Cb and brdC(bx,by+2)=Cc then down = true endif
if down and not move then
x = bx + xdg: y = by + ydg: xl = bx: yl = by: bx = 7: by = dd endif
next
next: if xl = bx and bx > 7 then x = x - 1: xl = xl - 1 endif
if down and yl = by and by > dd then y = y - 1: yl = yl - 1 endif
if down then down = false: gosub down: gosub brdC: move = true endif
if up or down or left or right then gosub again: return endif
for bx = 7 to ll step -1
for by = 1 to 7
if brdC(bx,by)=Ca and brdC(bx-1,by)=Cb and brdC(bx-2,by)=Cc then left = true endif
if left and not move then
x = bx + xdg: y = by + ydg: xl = bx: yl = by: bx = ll: by = 7 endif
next
next: if yl = by and by > 7 then y = y - 1: yl = yl - 1 endif
if left and xl = bx and bx < ll then x = x + 1: xl = xl + 1 endif
if left then left = false: gosub left: gosub brdC: move = true endif
if up or down or left or right then gosub again: return endif
for bx = 1 to rr
for by = 1 to 7
if brdC(bx,by)=Ca and brdC(bx+1,by)=Cb and brdC(bx+2,by)=Cc then right = true endif
if right and not move then
x = bx + xdg: y = by + ydg: xl = bx: yl = by: bx = rr: by = 7 endif
next
next: if yl = by and by > 7 then y = y - 1: yl = yl - 1 endif
if right and xl = bx and bx > rr then x = x - 1: xl = xl - 1 endif
if right then right = false: gosub right: gosub brdC: move = true endif
if up or down or left or right then gosub again: return endif
gosub brdC
return
Enjoy, ;D Yoric
The AI is only 'thinking' at the first level, so the computer is not very difficult to defeat:
dim boardR (9, 9), boardG (9, 9), brdC(9,9)
dim com, bx, by, uu, dd, ll, rr
dim x, y, xl, yl, xd, yd, xc, yc, sc, scp, cl1, cl2
dim char$, start$, Play$, Player$, Result$, Game$, Rdm$
dim xdr, ydr, scr, spr, spg, scg, xdg, ydg, Ox, Oy
dim Pass, up, down, left, right, move, Ca, Cb, Cc
xdr = 2: ydr = 6: spr = 6
xdg =29: ydg = 6: spg = 32
Gosub Open
color (255, 255,255)
locate 12, 0: print "* Double Cross *"
color (0, 0, 255)
locate 4, 2: print "Left-Click a ball for directions"
locate 0, 3: print "Hold Cursor Key and Left-Click Selection"
locate 17, 5: print "score "
locate 10, 23: print "Press return to Esc"
color (255, 0, 0)
for y = 3 to 5
for x = 1 to 7
locate x + xdr, y + ydr: print "O"
next
next
for y = 1 to 7
for x = 3 to 5
locate x + xdr, y + ydr: print "O"
next
next
locate xdr + Ox, ydr + Oy: print "+"
color (0, 255, 0)
for y = 3 to 5
for x = 1 to 7
locate x + xdg, y + ydg: print "O"
next
next
for y = 1 to 7
for x = 3 to 5
locate x + xdg, y + ydg: print "O"
next
next
locate xdg + Ox, ydg + Oy: print "+"
color (0, 0, 255)
locate 11,22: input "Play first R or G"; Player$
locate 12, 18: print "End key to pass"
locate 13, 20: print "Three Passes"
Locate 13, 21: print "Ends the game"
gosub Player
TextMode (TEXT_BUFFERED)
Play:
locate 10,22: ClearLine ()
if Player$ = "r" then color (255, 0, 0)
else color (0, 255, 0) endif
locate 15, 17: print Player$ + " to play"
locate 14, 19: print "Passes = " + pass
gosub brdC
DrawText ()
if Player$ = "g" and com then gosub compute: goto Play endif
while true
if not Mouse_Button (MOUSE_LBUTTON) then
locate x, y
endif
x = Mouse_X () * TextCols ()
y = Mouse_Y () * TextRows ()
xl = x - xd: yl = y - yd
if xl < 0 or xl > 7 or yl < 1 or yl > 7 then xl = 0 endif
if yl < 0 or yl > 7 or xl < 1 or xl > 7 then yl = 0 endif
char$ = CharAt$ (x, y)
locate 13, 16: color (cl1, cl2, 0): print "X = " + xl; " " "Y = " + yl: Sleep (100)
if ScanKeyDown (VK_END) then pass = pass + 1: goto change endif
if ScanKeyDown (VK_RETURN) then goto finish endif
if Mouse_Button (MOUSE_LBUTTON) then gosub Check: endif
DrawText ()
wend
Check:
if Player$ = "r" and x > 20 then return endif
if Player$ = "g" and x < 20 then return endif
if CharAt$(x, y) = "O" and CharAt$(x, y - 1) = "O" and CharAt$(x, y - 2) = "+" then
locate xd, 17: color (0, 0, 255): print "Up OK" : up = true:
else locate xd, 17: color (cl1, cl2, 0): print "Up No": up = false
endif
if CharAt$(x, y) = "O" and CharAt$(x, y + 1) = "O" and CharAt$(x, y + 2) = "+" then
locate xd, 18: color (0, 0, 255): print "Down OK": down = true:
else locate xd, 18: color (cl1, cl2, 0): print "Down No": down = false
endif
if CharAt$(x, y) = "O" and CharAt$(x - 1, y) = "O" and CharAt$(x - 2, y) = "+" then
locate xd, 19: color (0, 0, 255): print "Left OK": left = true:
else locate xd, 19: color (cl1, cl2, 0): print "Left No": left = false
endif
if CharAt$(x, y) = "O" and CharAt$(x + 1, y) = "O" and CharAt$(x + 2, y) = "+" then
locate xd, 20: color (0, 0, 255): print "Right OK": right = true:
else locate xd, 20: color (cl1, cl2, 0): print "Right No": right = false
endif
if not up and not down and not left and not right then move = false
endif
DrawText ()
if com and Player$ ="g" then gosub Score: return endif
Cursor:
color (cl1, cl2, 0)
if ScanKeyDown (VK_END) then pass = pass + 1: goto change endif
if ScanKeyDown (VK_UP) and up then gosub up endif
if ScanKeyDown (VK_DOWN) and down then gosub down endif
if ScanKeyDown (VK_LEFT) and left then gosub left endif
if ScanKeyDown (VK_RIGHT) and right then gosub right endif
if move then gosub Check endif
gosub brdC: gosub Score: return
Score:
locate scp, 5: print sc
if Player$ = "r" then scr = sc endif
if Player$ = "g" then scg = sc endif
DrawText ()
return
up:
if Player$ = "r" then boardR (xl, yl) = 1: boardR (xl, yl - 1) = 1
boardR (xl, yl - 2) = 2: boardG (xl, yl - 1) = 1 endif
if Player$ = "g" then boardG (xl, yl) = 1: boardG (xl, yl - 1) = 1
boardG (xl, yl - 2) = 3: boardR (xl, yl - 1) = 1 endif
locate x, y: print "+": locate x, y - 1: print "+": locate x, y - 2: print "O"
if Player$ = "r" then locate xl + xdg, y - 1: color (0, 255, 0): print "+" endif
if Player$ = "g" then locate xl + xdr, y - 1: color (255, 0, 0): print "+" endif
sc = sc + 1: y = y - 2: yl = yl - 2: pass = 0: gosub brdC
ClearKeys (): Sleep (50): gosub check
if up or down or left or right then move = true: return
else gosub change endif
DrawText ()
return
down:
if Player$ = "r" then boardR (xl, yl) = 1: boardR (xl, yl + 1) = 1
boardR (xl, yl + 2) = 2: boardG (xl, yl + 1) = 1 endif
if Player$ = "g" then boardG (xl, yl) = 1: boardG (xl, yl + 1) = 1
boardG (xl, yl + 2) = 3: boardR (xl, yl + 1) = 1 endif
locate x, y: print "+": locate x, y + 1: print "+": locate x, y + 2: print "O"
if Player$ = "r" then locate xl + xdg, y + 1: color (0, 255, 0): print "+" endif
if Player$ = "g" then locate xl + xdr, y + 1: color (255, 0, 0): print "+" endif
sc = sc + 1: y = y + 2: yl = yl + 2: pass = 0: gosub brdC
ClearKeys (): Sleep (50): gosub check
if up or down or left or right then move = true: return
else gosub change endif
DrawText ()
return
left:
if Player$ = "r" then boardR (xl, yl) = 1: boardR (xl - 1, yl) = 1
boardR (xl - 2, yl) = 2: boardG (xl - 1, yl) = 1 endif
if Player$ = "g" then boardG (xl, yl) = 1: boardG (xl - 1, yl) = 1
boardG (xl - 2, yl) = 3: boardR (xl - 1, yl) = 1 endif
locate x, y: print "+": locate x - 1, y: print "+": locate x - 2, y: print "O"
if Player$ = "r" then locate xl + xdg - 1, y: color (0, 255, 0): print "+" endif
if Player$ = "g" then locate xl + xdr - 1, y: color (255, 0, 0): print "+" endif
sc = sc + 1: x = x - 2: xl = xl - 2: pass = 0: gosub brdC
ClearKeys (): Sleep (50): gosub check
if up or down or left or right then move = true: return
else gosub change endif
DrawText ()
return
right:
if Player$ = "r" then boardR (xl, yl) = 1: boardR (xl + 1, yl) = 1:
boardR (xl + 2, yl) = 2: boardG (xl + 1, yl) = 1: endif
if Player$ = "g" then boardG (xl, yl) = 1: boardG (xl + 1, yl) = 1:
boardG (xl + 2, yl) = 3: boardR (xl + 1, yl) = 1: endif
locate x, y: print "+": locate x + 1, y: print "+": locate x + 2, y: print "O"
if Player$ = "r" then locate xl + xdg + 1, y: color (0, 255, 0): print "+" endif
if Player$ = "g" then locate xl + xdr + 1, y: color (255, 0, 0): print "+" endif
sc = sc + 1: x = x + 2: xl = xl + 2: pass = 0: gosub brdC
ClearKeys (): Sleep (50): gosub check
if up or down or left or right then move = true: return
else gosub change endif
DrawText ()
return
again:
if right then gosub right endif
if left then gosub left endif
if down then gosub down endif
if up then gosub up endif
Gosub brdC
if move then goto again endif
DrawText ()
return
Player:
if Player$ = "r" then xd = xdr: yd = ydr: sc = scr: scp = spr
cl1 = 255: cl2 = 0 endif
if Player$ = "g" then xd = xdg: yd = ydg: sc = scg: scp = spg
cl1 = 0: cl2 = 255 endif
return
Change:
up = false: down = false: left = false: right = false
if Player$ = "r" then Player$ = "g"
else Player$ = "r"
endif
if pass > 2 then goto Result endif
gosub Player: goto Play
Result:
if scr > scg then color (255, 0, 0): Result$ = "Red Victory" endif
if scr < scg then color (0, 255, 0): Result$ = "Green Wins" endif
if scr = scg then color (0, 0, 255): Result$ = "Game Drawn" endif
locate 14, 22: ClearLine ()
locate 14, 22: print Result$
Finish:
color (0, 0, 255): locate 10, 23: ClearLine ()
locate 8, 23: input "play again? (y, or esc)"; Play$
if Play$ = "y" then run
else goto Finish endif
Open:
color (255, 0, 0)
locate 11, 1: print "** Double Cross **"
locate 13, 3: print "Solitaire Duel"
color (255, 255, 255)
locate 0, 6: print "Pieces occupying similar board positions"
locate 5, 7: print "are eliminated simultaneously."
locate 0, 9: print "If the capturing piece is in a position"
locate 0, 10: print "to continue capturing then it may do so."
locate 6, 11: print "Simply use the cursor keys."
color (0, 255, 0)
locate 1, 14: print "The computer plays on the green board."
locate 6, 16: input "Computer Opponent Y or N"; Game$ ' "z" to see brdC() on screen
if Game$ = "y" or Game$ = "z" then com = true endif
color (255, 255, 255)
locate 2, 19: Print "Any key for a blank centre start, or"
locate 6, 21: input "enter R for a random start"; Rdm$
if Rdm$ = "r" then Ox = Rnd()%7+1: Oy = Rnd()%3+3 else Ox = 4: Oy = 4 endif
Board:
for bx = 0 to 8
for by = 0 to 8
boardR (bx, by) = 0
boardG (bx, by) = 0
next
next
for bx = 3 to 5
for by = 1 to 7
boardR (bx, by) = 2
boardG (bx, by) = 3
next
next
for bx = 1 to 7
for by = 3 to 5
boardR (bx, by) = 2
boardG (bx, by) = 3
next
next
boardR (Ox, Oy) = 1
boardG (Ox, Oy) = 1
Sleep (100): cls: return
brdC:
color (0, 0, 0)
if game$ = "z" then color (cl1, cl2, 0) endif
for bx = 0 to 8
for by = 0 to 8
brdC(bx,by) = boardR (bx, by) + boardG (bx, by)
next
next
xc = 15: yc = 6
for bx = 0 to 8
for by = 0 to 8
locate bx + xc, by + yc: print brdC(bx,by)
next
next
for bx = 3 to 5
for by = 1 to 7
locate bx + xc, by + yc: print brdC(bx,by)
next
next
for bx = 1 to 7
for by = 3 to 5
locate bx + xc, by + yc: print brdC(bx,by)
next
next
DrawText ()
color (cl1, cl2, 0)
return
compute:
move = false: uu = 6: dd = 2: ll = 6: rr = 2: gosub compC
if not move then uu = 5: dd = 3: ll = 5: rr = 3: gosub compC endif
if not move then uu = 4: dd = 4: ll = 4: rr = 4: gosub compC endif
if not move then uu = 3: dd = 5: ll = 3: rr = 5: gosub compC endif
gosub Score: gosub Change: gosub Player
return
compC:
Ca = 5: Cb = 5: Cc = 2: gosub compA
if not move then Ca = 4: Cb = 5: Cc = 2: gosub compA endif
if not move then Ca = 5: Cb = 4: Cc = 2: gosub compA endif
if not move then Ca = 4: Cb = 4: Cc = 2: gosub compA endif
if not move then Ca = 5: Cb = 5: Cc = 3: gosub compA endif
if not move then Ca = 4: Cb = 5: Cc = 3: gosub compA endif
if not move then Ca = 5: Cb = 4: Cc = 3: gosub compA endif
if not move then Ca = 4: Cb = 4: Cc = 3: gosub compA endif
return
compA:
for bx = 1 to 7
for by = 7 to uu step -1
if brdC(bx,by)=Ca and brdC(bx,by-1)=Cb and brdC(bx,by-2)=Cc then up = true endif
if up and not move then
x = bx + xdg: y = by + ydg: xl = bx: yl = by: bx = 7: by = uu endif
next
next: if xl = bx and bx > 7 then x = x - 1: xl = xl - 1 endif
if up and yl = by and by < uu then y = y + 1: yl = yl + 1 endif
if up then up = false: gosub up: gosub brdC: move = true endif
if up or down or left or right then gosub again: return endif
for bx = 1 to 7
for by = 1 to dd
if brdC(bx,by)=Ca and brdC(bx,by+1)=Cb and brdC(bx,by+2)=Cc then down = true endif
if down and not move then
x = bx + xdg: y = by + ydg: xl = bx: yl = by: bx = 7: by = dd endif
next
next: if xl = bx and bx > 7 then x = x - 1: xl = xl - 1 endif
if down and yl = by and by > dd then y = y - 1: yl = yl - 1 endif
if down then down = false: gosub down: gosub brdC: move = true endif
if up or down or left or right then gosub again: return endif
for bx = 7 to ll step -1
for by = 1 to 7
if brdC(bx,by)=Ca and brdC(bx-1,by)=Cb and brdC(bx-2,by)=Cc then left = true endif
if left and not move then
x = bx + xdg: y = by + ydg: xl = bx: yl = by: bx = ll: by = 7 endif
next
next: if yl = by and by > 7 then y = y - 1: yl = yl - 1 endif
if left and xl = bx and bx < ll then x = x + 1: xl = xl + 1 endif
if left then left = false: gosub left: gosub brdC: move = true endif
if up or down or left or right then gosub again: return endif
for bx = 1 to rr
for by = 1 to 7
if brdC(bx,by)=Ca and brdC(bx+1,by)=Cb and brdC(bx+2,by)=Cc then right = true endif
if right and not move then
x = bx + xdg: y = by + ydg: xl = bx: yl = by: bx = rr: by = 7 endif
next
next: if yl = by and by > 7 then y = y - 1: yl = yl - 1 endif
if right and xl = bx and bx > rr then x = x - 1: xl = xl - 1 endif
if right then right = false: gosub right: gosub brdC: move = true endif
if up or down or left or right then gosub again: return endif
gosub brdC
return
Enjoy, ;D Yoric