Advertisement
kd2bwzgen

tic tac toe

Nov 15th, 2017
3,317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 1 for i=1 to 40:print "":next i
  2. 2 DIM board$(9)
  3. 10 print "TIC TAC TOE"
  4. 20 print "By MineRobber9000"
  5. 30 print "For AppleSoft BASIC"
  6. 40 print "-------------------"
  7. 44 gosub 1400
  8. 45 goto 90:REM 1 player mode will come later, but for now I can make 2p
  9. 50 print "Mode? (1 = 2 players, 2 = 1 player)"
  10. 60 input a
  11. 70 on a goto 90
  12. 80 print "Invalid mode, try again":goto 50
  13. 90 turn = 0
  14. 100 if turn==1 goto 150
  15. 110 print "Player 1, your move"
  16. 120 gosub 1100
  17. 121 gosub 1200
  18. 130 turn = 1
  19. 140 goto 100
  20. 150 print "Player 2, your move"
  21. 160 gosub 1100
  22. 161 gosub 1200
  23. 170 turn = 0
  24. 180 goto 100
  25. 1000 end
  26. 1100 start = 1
  27. 1110 gosub 1170
  28. 1120 gosub 1180
  29. 1130 start = 4:gosub 1170
  30. 1140 gosub 1180
  31. 1150 start = 7:gosub 1170
  32. 1160 return
  33. 1170 print board$(start);"|";board$(start+1);"|";board$(start+2):return
  34. 1180 print "-+-+-":return
  35. 1200 input "Space?(1-9):";a
  36. 1210 if board$(a)==" " goto 1220
  37. 1215 print "Invalid move, try again":goto 1200
  38. 1220 if turn==0 then let board$(a)="X"
  39. 1230 if turn==1 then let board$(a)="O"
  40. 1240 if board$(1)==" " goto 1250:if board$(1)==board$(2) then if board$(2)==board$(3) then goto 1300
  41. 1250 if board$(4)==" " goto 1260:if board$(4)==board$(5) then if board$(5)==board$(6) then goto 1300
  42. 1260 if board$(7)==" " goto 1270:if board$(7)==board$(8) then if board$(8)==board$(9) then goto 1300
  43. 1270 if board$(1)==" " goto 1280:if board$(1)==board$(4) then if board$(4)==board$(7) then goto 1300
  44. 1280 if board$(2)==" " goto 1290:if board$(2)==board$(5) then if board$(5)==board$(8) then goto 1300
  45. 1290 if board$(3)==" " goto 1292:if board$(3)==board$(6) then if board$(6)==board$(9) then goto 1300
  46. 1292 if board$(1)==" " goto 1294:if board$(1)==board$(5) then if board$(5)==board$(9) then goto 1300
  47. 1294 if board$(7)==" " goto 1295:if board$(7)==board$(5) then if board$(5)==board$(3) then goto 1300
  48. 1295 return
  49. 1300 if board$(a)=="X" then print "Player 1 wins!"
  50. 1310 if board$(a)=="O" then print "Player 2 wins!"
  51. 1320 call 54915
  52. 1325 gosub 1400
  53. 1330 goto 45:REM restart game, TODO: add choice
  54. 1400 for i=1 to 9:let board$(i)=" ":next i:return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement