Advertisement
Guest User

hi

a guest
Jan 18th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.30 KB | None | 0 0
  1. @echo off
  2.  
  3. qais ,s Tic Tac Toe
  4.  
  5. title Noughts and Crosses
  6.  
  7. setlocal enabledelayedexpansion
  8.  
  9. ::~ ^^^ Stops all commands appearing on screen, sets the title and enables the use of ! for environment variable
  10.  
  11. :menu
  12.  
  13. cls
  14.  
  15. echo Main Menu
  16.  
  17. echo To Play A 1-Player Game, Enter 1
  18.  
  19. echo To Play A 2-Player Game, Enter 2
  20.  
  21. echo To Exit, Enter 3
  22.  
  23. set /p menu=
  24.  
  25. if not defined menu goto menu
  26.  
  27. if /i %menu% equ 1 (
  28.  
  29. set menu=
  30.  
  31. cls
  32.  
  33. goto 1p
  34.  
  35. )
  36.  
  37. if /i %menu% equ 2 (
  38.  
  39. set menu=
  40.  
  41. cls
  42.  
  43. goto 2p
  44.  
  45. )
  46.  
  47. if /i %menu% equ 3 (
  48.  
  49. goto end
  50.  
  51. )
  52.  
  53. set menu=
  54.  
  55. goto menu
  56.  
  57. ::~ ^^ The menu system, gives all the options, allows the user to input a number using "set /p menu="
  58.  
  59. :~ If the user didn't enter a value, it 'goto's back to ask again.
  60.  
  61. ::~ Checks the Menu variable, tests to see if it matches 1, 2 or 3, then 'goto's the appropriate place.
  62.  
  63. :1p
  64.  
  65. set turns=0
  66.  
  67. set x1=0
  68.  
  69. set x2=0
  70.  
  71. set x3=0
  72.  
  73. set x4=0
  74.  
  75. set x5=0
  76.  
  77.  
  78.  
  79. set x6=0
  80.  
  81.  
  82.  
  83. set x7=0
  84.  
  85.  
  86.  
  87. set x8=0
  88.  
  89.  
  90.  
  91. set x9=0
  92.  
  93.  
  94.  
  95. set o1=0
  96.  
  97.  
  98.  
  99. set o2=0
  100.  
  101.  
  102.  
  103. set o3=0
  104.  
  105.  
  106.  
  107. set o4=0
  108.  
  109.  
  110.  
  111. set o5=0
  112.  
  113.  
  114.  
  115. set o6=0
  116.  
  117.  
  118.  
  119. set o7=0
  120.  
  121.  
  122.  
  123. set o8=0
  124.  
  125.  
  126.  
  127. set o9=0
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137. ::~ Sets the number of turns taken so far to 0
  138.  
  139.  
  140.  
  141. ::~ Sets all the places on the noughts and crosses grid to 0
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157. set d1=1
  158.  
  159.  
  160.  
  161. set d2=2
  162.  
  163.  
  164.  
  165. set d3=3
  166.  
  167.  
  168.  
  169. set d4=4
  170.  
  171.  
  172.  
  173. set d5=5
  174.  
  175.  
  176.  
  177. set d6=6
  178.  
  179.  
  180.  
  181. set d7=7
  182.  
  183.  
  184.  
  185. set d8=8
  186.  
  187.  
  188.  
  189. set d9=9
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199. ::~ Sets the display characters for game to their appropriate number
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209. set rnumber=%random%
  210.  
  211.  
  212.  
  213. set rnumber2=%rnumber%
  214.  
  215.  
  216.  
  217. set /a rnumber= %rnumber% / 2
  218.  
  219.  
  220.  
  221. set /a rnumber= %rnumber% * 2
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231. ::~ Sets a variable "rnumber" to a random number
  232.  
  233.  
  234.  
  235. ::~ Sets a variable "rnumber2" to the same number as "rnumber"
  236.  
  237.  
  238.  
  239. ::~ Divides "rnumber" by two, then multiplies by two.
  240.  
  241.  
  242.  
  243. ::~ If the number was even, it would be equal to "rnumber2", if it was odd it would end up one less than "rnumber2"
  244.  
  245.  
  246.  
  247. ::~ This is the method I use to create a 50% chance, as there's a 50% that a random number will be odd or even
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263. if %rnumber%==%rnumber2% (
  264.  
  265.  
  266.  
  267. echo Crosses go first
  268.  
  269.  
  270.  
  271. echo You are noughts
  272.  
  273.  
  274.  
  275. pause>nul
  276.  
  277.  
  278.  
  279. set rnumber=
  280.  
  281.  
  282.  
  283. set rnumber2=
  284.  
  285.  
  286.  
  287. set go=1xgame
  288.  
  289.  
  290.  
  291. goto 1display
  292.  
  293.  
  294.  
  295. ) else (
  296.  
  297.  
  298.  
  299. echo Noughts go first
  300.  
  301.  
  302.  
  303. echo You are noughts
  304.  
  305.  
  306.  
  307. pause>nul
  308.  
  309.  
  310.  
  311. set rnumber=
  312.  
  313.  
  314.  
  315. set rnumber2=
  316.  
  317.  
  318.  
  319. set go=1ogame
  320.  
  321.  
  322.  
  323. goto 1display
  324.  
  325.  
  326.  
  327. )
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337. ::~ This tests to see if the numbers are equal, then sets the "go" variable to whichever possibility came out and deletes the "rnumber" variables
  338.  
  339.  
  340.  
  341. ::~ Then 'Goto's the display
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351. :1display
  352.  
  353.  
  354.  
  355. cls
  356.  
  357.  
  358.  
  359. echo %d1% %d2% %d3%
  360.  
  361.  
  362.  
  363. echo %d4% %d5% %d6%
  364.  
  365.  
  366.  
  367. echo %d7% %d8% %d9%
  368.  
  369.  
  370.  
  371. if /i %turns% equ 9 (goto draw)
  372.  
  373.  
  374.  
  375. echo.
  376.  
  377.  
  378.  
  379. echo Your Turn
  380.  
  381.  
  382.  
  383. echo.
  384.  
  385.  
  386.  
  387. goto %go%
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397. ::~ ^^ Displays the current status of each place in the grid. At the start these will all just be numbers.
  398.  
  399.  
  400.  
  401. ::~ Checks that the turns hasn't reach nine. If it has, all the spaces on the grid have been used up and nobody has won, so the game is a draw.
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411. :1ogame
  412.  
  413.  
  414.  
  415. echo Choose the number of the space you'd like to choose
  416.  
  417.  
  418.  
  419. set guess=
  420.  
  421.  
  422.  
  423. set /p guess=
  424.  
  425.  
  426.  
  427. if not defined guess goto 1display
  428.  
  429.  
  430.  
  431. set guess=%guess:~0,1%
  432.  
  433.  
  434.  
  435. if /i not %guess% leq 9 goto 1display
  436.  
  437.  
  438.  
  439. if /i not %guess% gtr 0 goto 1display
  440.  
  441.  
  442.  
  443. if /i !d%guess%! neq %guess% goto 1display
  444.  
  445.  
  446.  
  447. goto 1o%guess%
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457. ::~ Asks the user to input the number of the space they want to choose and allows them to using "Set /p"
  458.  
  459.  
  460.  
  461. ::~ If the user didn't input or entered something that wasn't a number between 1 and 9, it 'goto's back, to ask again
  462.  
  463.  
  464.  
  465. ::~ Checks that the number hasn't been already chosen by checking that !d%guess%! is equal to guess. This works becauseif the user guesses 1, d1 should equal 1.
  466.  
  467.  
  468.  
  469. ::~ If it has already been chosen, d1 would be a O or a X, so it would not be equal.
  470.  
  471.  
  472.  
  473. ::~ 'Goto's the number chosen.
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483. :1o1
  484.  
  485.  
  486.  
  487. set o1=1
  488.  
  489.  
  490.  
  491. set x1=1000
  492.  
  493.  
  494.  
  495. set d1=O
  496.  
  497.  
  498.  
  499. goto 1oprocess
  500.  
  501.  
  502.  
  503. :1o2
  504.  
  505.  
  506.  
  507. set o2=10
  508.  
  509.  
  510.  
  511. set x2=1000
  512.  
  513.  
  514.  
  515. set d2=O
  516.  
  517.  
  518.  
  519. goto 1oprocess
  520.  
  521.  
  522.  
  523. :1o3
  524.  
  525.  
  526.  
  527. set o3=100
  528.  
  529.  
  530.  
  531. set x3=1000
  532.  
  533.  
  534.  
  535. set d3=O
  536.  
  537.  
  538.  
  539. goto 1oprocess
  540.  
  541.  
  542.  
  543. :1o4
  544.  
  545.  
  546.  
  547. set o4=1
  548.  
  549.  
  550.  
  551. set x4=1000
  552.  
  553.  
  554.  
  555. set d4=O
  556.  
  557.  
  558.  
  559. goto 1oprocess
  560.  
  561.  
  562.  
  563. :1o5
  564.  
  565.  
  566.  
  567. set o5=10
  568.  
  569.  
  570.  
  571. set x5=1000
  572.  
  573.  
  574.  
  575. set d5=O
  576.  
  577.  
  578.  
  579. goto 1oprocess
  580.  
  581.  
  582.  
  583. :1o6
  584.  
  585.  
  586.  
  587. set o6=100
  588.  
  589.  
  590.  
  591. set x6=1000
  592.  
  593.  
  594.  
  595. set d6=O
  596.  
  597.  
  598.  
  599. goto 1oprocess
  600.  
  601.  
  602.  
  603. :1o7
  604.  
  605.  
  606.  
  607. set o7=1
  608.  
  609.  
  610.  
  611. set x7=1000
  612.  
  613.  
  614.  
  615. set d7=O
  616.  
  617.  
  618.  
  619. goto 1oprocess
  620.  
  621.  
  622.  
  623. :1o8
  624.  
  625.  
  626.  
  627. set o8=10
  628.  
  629.  
  630.  
  631. set x8=1000
  632.  
  633.  
  634.  
  635. set d8=O
  636.  
  637.  
  638.  
  639. goto 1oprocess
  640.  
  641.  
  642.  
  643. :1o9
  644.  
  645.  
  646.  
  647. set o9=100
  648.  
  649.  
  650.  
  651. set x9=1000
  652.  
  653.  
  654.  
  655. set d9=O
  656.  
  657.  
  658.  
  659. goto 1oprocess
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669. ::~ The space of the number chosen on the display grid is changed to the correct letter (X or O) and a number is added to the %x-% grid and the %o-% grid.
  670.  
  671.  
  672.  
  673. ::~ These two grids are used to work out whether someone has won, and allows the computer to work out which place to go next.
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695. :1oprocess
  696.  
  697.  
  698.  
  699. set /a line1= %o1% + %o2% + %o3%
  700.  
  701.  
  702.  
  703. if /i %line1% equ 111 (goto owin)
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713. set /a line2= %o4% + %o5% + %o6%
  714.  
  715.  
  716.  
  717. if /i %line2% equ 111 (goto owin)
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727. set /a line3= %o7% + %o8% + %o9%
  728.  
  729.  
  730.  
  731. if /i %line3% equ 111 (goto owin)
  732.  
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741. set /a line4= %o1% + %o5% + %o9%
  742.  
  743.  
  744.  
  745. if /i %line4% equ 111 (goto owin)
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755. set /a line5= %o3% + %o5% + %o7%
  756.  
  757.  
  758.  
  759. if /i %line5% equ 111 (goto owin)
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769. set /a line6= %o1% + %o4% + %o7%
  770.  
  771.  
  772.  
  773. if /i %line6% equ 3 (goto owin)
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783. set /a line7= %o2% + %o5% + %o8%
  784.  
  785.  
  786.  
  787. if /i %line7% equ 30 (goto owin)
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797. set /a line8= %o3% + %o6% + %o9%
  798.  
  799.  
  800.  
  801. if /i %line8% equ 300 (goto owin)
  802.  
  803.  
  804.  
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811. ::~ This section of code adds up all of the possible winning combinations on the %o-% grid i.e. each row, column and diagional, to check if the player has got three Os in a row. If so 'goto's the owin section.
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821. set go=1xgame
  822.  
  823.  
  824.  
  825. set guess=
  826.  
  827.  
  828.  
  829. set /a turns= %turns% + 1
  830.  
  831.  
  832.  
  833. goto 1display
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843. ::~ Sets the go to the computer's and adds one to the number of turns taken
  844.  
  845.  
  846.  
  847. ::~ 'Goto's the display.
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887. :1xgame
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897. set /a line1= %x1% + %x2% + %x3%
  898.  
  899.  
  900.  
  901. if /i %line1% equ 11 (
  902.  
  903.  
  904.  
  905. set guess=3
  906.  
  907.  
  908.  
  909. goto 1ac
  910.  
  911.  
  912.  
  913. )
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923. set /a line1= %x1% + %x2% + %x3%
  924.  
  925.  
  926.  
  927. if /i %line1% equ 101 (
  928.  
  929.  
  930.  
  931. set guess=2
  932.  
  933.  
  934.  
  935. goto 1ac
  936.  
  937.  
  938.  
  939. )
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949. set /a line1= %x1% + %x2% + %x3%
  950.  
  951.  
  952.  
  953. if /i %line1% equ 110 (
  954.  
  955.  
  956.  
  957. set guess=1
  958.  
  959.  
  960.  
  961. goto 1ac
  962.  
  963.  
  964.  
  965. )
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981. set /a line1= %x4% + %x5% + %x6%
  982.  
  983.  
  984.  
  985. if /i %line1% equ 11 (
  986.  
  987.  
  988.  
  989. set guess=6
  990.  
  991.  
  992.  
  993. goto 1ac
  994.  
  995.  
  996.  
  997. )
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007. set /a line1= %x4% + %x5% + %x6%
  1008.  
  1009.  
  1010.  
  1011. if /i %line1% equ 101 (
  1012.  
  1013.  
  1014.  
  1015. set guess=5
  1016.  
  1017.  
  1018.  
  1019. goto 1ac
  1020.  
  1021.  
  1022.  
  1023. )
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033. set /a line1= %x4% + %x5% + %x6%
  1034.  
  1035.  
  1036.  
  1037. if /i %line1% equ 110 (
  1038.  
  1039.  
  1040.  
  1041. set guess=4
  1042.  
  1043.  
  1044.  
  1045. goto 1ac
  1046.  
  1047.  
  1048.  
  1049. )
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059. set /a line1= %x7% + %x8% + %x9%
  1060.  
  1061.  
  1062.  
  1063. if /i %line1% equ 11 (
  1064.  
  1065.  
  1066.  
  1067. set guess=9
  1068.  
  1069.  
  1070.  
  1071. goto 1ac
  1072.  
  1073.  
  1074.  
  1075. )
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085. set /a line1= %x7% + %x8% + %x9%
  1086.  
  1087.  
  1088.  
  1089. if /i %line1% equ 101 (
  1090.  
  1091.  
  1092.  
  1093. set guess=8
  1094.  
  1095.  
  1096.  
  1097. goto 1ac
  1098.  
  1099.  
  1100.  
  1101. )
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111. set /a line1= %x7% + %x8% + %x9%
  1112.  
  1113.  
  1114.  
  1115. if /i %line1% equ 110 (
  1116.  
  1117.  
  1118.  
  1119. set guess=7
  1120.  
  1121.  
  1122.  
  1123. goto 1ac
  1124.  
  1125.  
  1126.  
  1127. )
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137. set /a line1= %x1% + %x5% + %x9%
  1138.  
  1139.  
  1140.  
  1141. if /i %line1% equ 11 (
  1142.  
  1143.  
  1144.  
  1145. set guess=9
  1146.  
  1147.  
  1148.  
  1149. goto 1ac
  1150.  
  1151.  
  1152.  
  1153. )
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163. set /a line1= %x1% + %x5% + %x9%
  1164.  
  1165.  
  1166.  
  1167. if /i %line1% equ 101 (
  1168.  
  1169.  
  1170.  
  1171. set guess=5
  1172.  
  1173.  
  1174.  
  1175. goto 1ac
  1176.  
  1177.  
  1178.  
  1179. )
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189. set /a line1= %x1% + %x5% + %x9%
  1190.  
  1191.  
  1192.  
  1193. if /i %line1% equ 110 (
  1194.  
  1195.  
  1196.  
  1197. set guess=1
  1198.  
  1199.  
  1200.  
  1201. goto 1ac
  1202.  
  1203.  
  1204.  
  1205. )
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215. set /a line1= %x3% + %x5% + %x7%
  1216.  
  1217.  
  1218.  
  1219. if /i %line1% equ 11 (
  1220.  
  1221.  
  1222.  
  1223. set guess=3
  1224.  
  1225.  
  1226.  
  1227. goto 1ac
  1228.  
  1229.  
  1230.  
  1231. )
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241. set /a line1= %x3% + %x5% + %x7%
  1242.  
  1243.  
  1244.  
  1245. if /i %line1% equ 101 (
  1246.  
  1247.  
  1248.  
  1249. set guess=5
  1250.  
  1251.  
  1252.  
  1253. goto 1ac
  1254.  
  1255.  
  1256.  
  1257. )
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267. set /a line1= %x3% + %x5% + %x7%
  1268.  
  1269.  
  1270.  
  1271. if /i %line1% equ 110 (
  1272.  
  1273.  
  1274.  
  1275. set guess=7
  1276.  
  1277.  
  1278.  
  1279. goto 1ac
  1280.  
  1281.  
  1282.  
  1283. )
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293. set /a line1= %x1% + %x4% + %x7%
  1294.  
  1295.  
  1296.  
  1297. if /i %line1% equ 2 (
  1298.  
  1299.  
  1300.  
  1301. if /i %d1% equ 1 (
  1302.  
  1303.  
  1304.  
  1305. set guess=1
  1306.  
  1307.  
  1308.  
  1309. goto 1ac
  1310.  
  1311.  
  1312.  
  1313. )
  1314.  
  1315.  
  1316.  
  1317. if /i %d4% equ 4 (
  1318.  
  1319.  
  1320.  
  1321. set guess=4
  1322.  
  1323.  
  1324.  
  1325. goto 1ac
  1326.  
  1327.  
  1328.  
  1329. )
  1330.  
  1331.  
  1332.  
  1333. if /i %d7% equ 7 (
  1334.  
  1335.  
  1336.  
  1337. set guess=7
  1338.  
  1339.  
  1340.  
  1341. goto 1ac
  1342.  
  1343.  
  1344.  
  1345. )
  1346.  
  1347.  
  1348.  
  1349. )
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359. set /a line1= %x2% + %x5% + %x8%
  1360.  
  1361.  
  1362.  
  1363. if /i %line1% equ 20 (
  1364.  
  1365.  
  1366.  
  1367. if /i %d2% equ 2 (
  1368.  
  1369.  
  1370.  
  1371. set guess=2
  1372.  
  1373.  
  1374.  
  1375. goto 1ac
  1376.  
  1377.  
  1378.  
  1379. )
  1380.  
  1381.  
  1382.  
  1383. if /i %d5% equ 5 (
  1384.  
  1385.  
  1386.  
  1387. set guess=5
  1388.  
  1389.  
  1390.  
  1391. goto 1ac
  1392.  
  1393.  
  1394.  
  1395. )
  1396.  
  1397.  
  1398.  
  1399. if /i %d8% equ 8 (
  1400.  
  1401.  
  1402.  
  1403. set guess=8
  1404.  
  1405.  
  1406.  
  1407. goto 1ac
  1408.  
  1409.  
  1410.  
  1411. )
  1412.  
  1413.  
  1414.  
  1415. )
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425. set /a line1= %x3% + %x6% + %x9%
  1426.  
  1427.  
  1428.  
  1429. if /i %line1% equ 200 (
  1430.  
  1431.  
  1432.  
  1433. if /i %d3% equ 3 (
  1434.  
  1435.  
  1436.  
  1437. set guess=3
  1438.  
  1439.  
  1440.  
  1441. goto 1ac
  1442.  
  1443.  
  1444.  
  1445. )
  1446.  
  1447.  
  1448.  
  1449. if /i %d6% equ 6 (
  1450.  
  1451.  
  1452.  
  1453. set guess=6
  1454.  
  1455.  
  1456.  
  1457. goto 1ac
  1458.  
  1459.  
  1460.  
  1461. )
  1462.  
  1463.  
  1464.  
  1465. if /i %d9% equ 9 (
  1466.  
  1467.  
  1468.  
  1469. set guess=9
  1470.  
  1471.  
  1472.  
  1473. goto 1ac
  1474.  
  1475.  
  1476.  
  1477. )
  1478.  
  1479.  
  1480.  
  1481. )
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497. ::~ ^^^ These sections add up all the %x-% grid and checks to see if there is a way the computer can win this turn.
  1498.  
  1499.  
  1500.  
  1501. ::~ If so, it sets the guess to the correct number and 'goto's the 1ac section.
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.  
  1541. set /a line1= %o1% + %o2% + %o3%
  1542.  
  1543.  
  1544.  
  1545. if /i %line1% equ 11 (
  1546.  
  1547.  
  1548.  
  1549. set guess=3
  1550.  
  1551.  
  1552.  
  1553. goto 1ac
  1554.  
  1555.  
  1556.  
  1557. )
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567. set /a line1= %o1% + %o2% + %o3%
  1568.  
  1569.  
  1570.  
  1571. if /i %line1% equ 101 (
  1572.  
  1573.  
  1574.  
  1575. set guess=2
  1576.  
  1577.  
  1578.  
  1579. goto 1ac
  1580.  
  1581.  
  1582.  
  1583. )
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593. set /a line1= %o1% + %o2% + %o3%
  1594.  
  1595.  
  1596.  
  1597. if /i %line1% equ 110 (
  1598.  
  1599.  
  1600.  
  1601. set guess=1
  1602.  
  1603.  
  1604.  
  1605. goto 1ac
  1606.  
  1607.  
  1608.  
  1609. )
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625. set /a line1= %o4% + %o5% + %o6%
  1626.  
  1627.  
  1628.  
  1629. if /i %line1% equ 11 (
  1630.  
  1631.  
  1632.  
  1633. set guess=6
  1634.  
  1635.  
  1636.  
  1637. goto 1ac
  1638.  
  1639.  
  1640.  
  1641. )
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651. set /a line1= %o4% + %o5% + %o6%
  1652.  
  1653.  
  1654.  
  1655. if /i %line1% equ 101 (
  1656.  
  1657.  
  1658.  
  1659. set guess=5
  1660.  
  1661.  
  1662.  
  1663. goto 1ac
  1664.  
  1665.  
  1666.  
  1667. )
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677. set /a line1= %o4% + %o5% + %o6%
  1678.  
  1679.  
  1680.  
  1681. if /i %line1% equ 110 (
  1682.  
  1683.  
  1684.  
  1685. set guess=4
  1686.  
  1687.  
  1688.  
  1689. goto 1ac
  1690.  
  1691.  
  1692.  
  1693. )
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703. set /a line1= %o7% + %o8% + %o9%
  1704.  
  1705.  
  1706.  
  1707. if /i %line1% equ 11 (
  1708.  
  1709.  
  1710.  
  1711. set guess=9
  1712.  
  1713.  
  1714.  
  1715. goto 1ac
  1716.  
  1717.  
  1718.  
  1719. )
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729. set /a line1= %o7% + %o8% + %o9%
  1730.  
  1731.  
  1732.  
  1733. if /i %line1% equ 101 (
  1734.  
  1735.  
  1736.  
  1737. set guess=8
  1738.  
  1739.  
  1740.  
  1741. goto 1ac
  1742.  
  1743.  
  1744.  
  1745. )
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755. set /a line1= %o7% + %o8% + %o9%
  1756.  
  1757.  
  1758.  
  1759. if /i %line1% equ 110 (
  1760.  
  1761.  
  1762.  
  1763. set guess=7
  1764.  
  1765.  
  1766.  
  1767. goto 1ac
  1768.  
  1769.  
  1770.  
  1771. )
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781. set /a line1= %o1% + %o5% + %o9%
  1782.  
  1783.  
  1784.  
  1785. if /i %line1% equ 11 (
  1786.  
  1787.  
  1788.  
  1789. set guess=9
  1790.  
  1791.  
  1792.  
  1793. goto 1ac
  1794.  
  1795.  
  1796.  
  1797. )
  1798.  
  1799.  
  1800.  
  1801.  
  1802.  
  1803.  
  1804.  
  1805.  
  1806.  
  1807. set /a line1= %o1% + %o5% + %o9%
  1808.  
  1809.  
  1810.  
  1811. if /i %line1% equ 101 (
  1812.  
  1813.  
  1814.  
  1815. set guess=5
  1816.  
  1817.  
  1818.  
  1819. goto 1ac
  1820.  
  1821.  
  1822.  
  1823. )
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833. set /a line1= %o1% + %o5% + %o9%
  1834.  
  1835.  
  1836.  
  1837. if /i %line1% equ 110 (
  1838.  
  1839.  
  1840.  
  1841. set guess=1
  1842.  
  1843.  
  1844.  
  1845. goto 1ac
  1846.  
  1847.  
  1848.  
  1849. )
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859. set /a line1= %o3% + %o5% + %o7%
  1860.  
  1861.  
  1862.  
  1863. if /i %line1% equ 11 (
  1864.  
  1865.  
  1866.  
  1867. set guess=3
  1868.  
  1869.  
  1870.  
  1871. goto 1ac
  1872.  
  1873.  
  1874.  
  1875. )
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883.  
  1884.  
  1885. set /a line1= %o3% + %o5% + %o7%
  1886.  
  1887.  
  1888.  
  1889. if /i %line1% equ 101 (
  1890.  
  1891.  
  1892.  
  1893. set guess=5
  1894.  
  1895.  
  1896.  
  1897. goto 1ac
  1898.  
  1899.  
  1900.  
  1901. )
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911. set /a line1= %o3% + %o5% + %o7%
  1912.  
  1913.  
  1914.  
  1915. if /i %line1% equ 110 (
  1916.  
  1917.  
  1918.  
  1919. set guess=7
  1920.  
  1921.  
  1922.  
  1923. goto 1ac
  1924.  
  1925.  
  1926.  
  1927. )
  1928.  
  1929.  
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937. set /a line1= %o1% + %o4% + %o7%
  1938.  
  1939.  
  1940.  
  1941. if /i %line1% equ 2 (
  1942.  
  1943.  
  1944.  
  1945. if /i %d1% equ 1 (
  1946.  
  1947.  
  1948.  
  1949. set guess=1
  1950.  
  1951.  
  1952.  
  1953. goto 1ac
  1954.  
  1955.  
  1956.  
  1957. )
  1958.  
  1959.  
  1960.  
  1961. if /i %d4% equ 4 (
  1962.  
  1963.  
  1964.  
  1965. set guess=4
  1966.  
  1967.  
  1968.  
  1969. goto 1ac
  1970.  
  1971.  
  1972.  
  1973. )
  1974.  
  1975.  
  1976.  
  1977. if /i %d7% equ 7 (
  1978.  
  1979.  
  1980.  
  1981. set guess=7
  1982.  
  1983.  
  1984.  
  1985. goto 1ac
  1986.  
  1987.  
  1988.  
  1989. )
  1990.  
  1991.  
  1992.  
  1993. )
  1994.  
  1995.  
  1996.  
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  
  2002.  
  2003. set /a line1= %o2% + %o5% + %o8%
  2004.  
  2005.  
  2006.  
  2007. if /i %line1% equ 20 (
  2008.  
  2009.  
  2010.  
  2011. if /i %d2% equ 2 (
  2012.  
  2013.  
  2014.  
  2015. set guess=2
  2016.  
  2017.  
  2018.  
  2019. goto 1ac
  2020.  
  2021.  
  2022.  
  2023. )
  2024.  
  2025.  
  2026.  
  2027. if /i %d5% equ 5 (
  2028.  
  2029.  
  2030.  
  2031. set guess=5
  2032.  
  2033.  
  2034.  
  2035. goto 1ac
  2036.  
  2037.  
  2038.  
  2039. )
  2040.  
  2041.  
  2042.  
  2043. if /i %d8% equ 8 (
  2044.  
  2045.  
  2046.  
  2047. set guess=8
  2048.  
  2049.  
  2050.  
  2051. goto 1ac
  2052.  
  2053.  
  2054.  
  2055. )
  2056.  
  2057.  
  2058.  
  2059. )
  2060.  
  2061.  
  2062.  
  2063.  
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069. set /a line1= %o3% + %o6% + %o9%
  2070.  
  2071.  
  2072.  
  2073. if /i %line1% equ 200 (
  2074.  
  2075.  
  2076.  
  2077. if /i %d3% equ 3 (
  2078.  
  2079.  
  2080.  
  2081. set guess=3
  2082.  
  2083.  
  2084.  
  2085. goto 1ac
  2086.  
  2087.  
  2088.  
  2089. )
  2090.  
  2091.  
  2092.  
  2093. if /i %d6% equ 6 (
  2094.  
  2095.  
  2096.  
  2097. set guess=6
  2098.  
  2099.  
  2100.  
  2101. goto 1ac
  2102.  
  2103.  
  2104.  
  2105. )
  2106.  
  2107.  
  2108.  
  2109. if /i %d9% equ 9 (
  2110.  
  2111.  
  2112.  
  2113. set guess=9
  2114.  
  2115.  
  2116.  
  2117. goto 1ac
  2118.  
  2119.  
  2120.  
  2121. )
  2122.  
  2123.  
  2124.  
  2125. )
  2126.  
  2127.  
  2128.  
  2129.  
  2130.  
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141. ::~ This section checks that there is no way the noughts can win next turn by adding up the %o-% grid. If so it sets the guess to the right number and 'goto's 1ac.
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151. set guess=%time:~9,1%
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161. ::~ If there is no way that the computer OR the player can win next turn, the computer chooses a random number as its guess. The random number I use is the millisecond digit of the clock.
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171. :1ac
  2172.  
  2173.  
  2174.  
  2175. if /i %guess% equ 0 goto 1display
  2176.  
  2177.  
  2178.  
  2179. echo !d%guess%!
  2180.  
  2181.  
  2182.  
  2183. if /i NOT !d%guess%!==%guess% goto 1display
  2184.  
  2185.  
  2186.  
  2187. goto 1x%guess%
  2188.  
  2189.  
  2190.  
  2191.  
  2192.  
  2193.  
  2194.  
  2195.  
  2196.  
  2197. ::~ Checks that the place hasn't already been taken (as explained above) and 'goto's the corresponding place below.
  2198.  
  2199.  
  2200.  
  2201.  
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207. :1x1
  2208.  
  2209.  
  2210.  
  2211. set x1=1
  2212.  
  2213.  
  2214.  
  2215. set o1=1000
  2216.  
  2217.  
  2218.  
  2219. set d1=X
  2220.  
  2221.  
  2222.  
  2223. goto 1xprocess
  2224.  
  2225.  
  2226.  
  2227. :1x2
  2228.  
  2229.  
  2230.  
  2231. set x2=10
  2232.  
  2233.  
  2234.  
  2235. set o2=1000
  2236.  
  2237.  
  2238.  
  2239. set d2=X
  2240.  
  2241.  
  2242.  
  2243. goto 1xprocess
  2244.  
  2245.  
  2246.  
  2247. :1x3
  2248.  
  2249.  
  2250.  
  2251. set x3=100
  2252.  
  2253.  
  2254.  
  2255. set o3=1000
  2256.  
  2257.  
  2258.  
  2259. set d3=X
  2260.  
  2261.  
  2262.  
  2263. goto 1xprocess
  2264.  
  2265.  
  2266.  
  2267. :1x4
  2268.  
  2269.  
  2270.  
  2271. set x4=1
  2272.  
  2273.  
  2274.  
  2275. set o4=1000
  2276.  
  2277.  
  2278.  
  2279. set d4=X
  2280.  
  2281.  
  2282.  
  2283. goto 1xprocess
  2284.  
  2285.  
  2286.  
  2287. :1x5
  2288.  
  2289.  
  2290.  
  2291. set x5=10
  2292.  
  2293.  
  2294.  
  2295. set o5=1000
  2296.  
  2297.  
  2298.  
  2299. set d5=X
  2300.  
  2301.  
  2302.  
  2303. goto 1xprocess
  2304.  
  2305.  
  2306.  
  2307. :1x6
  2308.  
  2309.  
  2310.  
  2311. set x6=100
  2312.  
  2313.  
  2314.  
  2315. set o6=1000
  2316.  
  2317.  
  2318.  
  2319. set d6=X
  2320.  
  2321.  
  2322.  
  2323. goto 1xprocess
  2324.  
  2325.  
  2326.  
  2327. :1x7
  2328.  
  2329.  
  2330.  
  2331. set x7=1
  2332.  
  2333.  
  2334.  
  2335. set o7=1000
  2336.  
  2337.  
  2338.  
  2339. set d7=X
  2340.  
  2341.  
  2342.  
  2343. goto 1xprocess
  2344.  
  2345.  
  2346.  
  2347. :1x8
  2348.  
  2349.  
  2350.  
  2351. set x8=10
  2352.  
  2353.  
  2354.  
  2355. set o8=1000
  2356.  
  2357.  
  2358.  
  2359. set d8=X
  2360.  
  2361.  
  2362.  
  2363. goto 1xprocess
  2364.  
  2365.  
  2366.  
  2367. :1x9
  2368.  
  2369.  
  2370.  
  2371. set x9=100
  2372.  
  2373.  
  2374.  
  2375. set o9=1000
  2376.  
  2377.  
  2378.  
  2379. set d9=X
  2380.  
  2381.  
  2382.  
  2383. goto 1xprocess
  2384.  
  2385.  
  2386.  
  2387.  
  2388.  
  2389.  
  2390.  
  2391.  
  2392.  
  2393.  
  2394.  
  2395.  
  2396.  
  2397.  
  2398.  
  2399.  
  2400.  
  2401.  
  2402.  
  2403.  
  2404.  
  2405. ::~ This section, as for the noughts, changes the display character of the chosen place, and adds numbers to the %x-% grid.
  2406.  
  2407.  
  2408.  
  2409.  
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415. :1xprocess
  2416.  
  2417.  
  2418.  
  2419. set /a line1= %x1% + %x2% + %x3%
  2420.  
  2421.  
  2422.  
  2423. if /i %line1% equ 111 (goto xwin)
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433. set /a line2= %x4% + %x5% + %x6%
  2434.  
  2435.  
  2436.  
  2437. if /i %line2% equ 111 (goto xwin)
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447. set /a line3= %x7% + %x8% + %x9%
  2448.  
  2449.  
  2450.  
  2451. if /i %line3% equ 111 (goto xwin)
  2452.  
  2453.  
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461. set /a line4= %x1% + %x5% + %x9%
  2462.  
  2463.  
  2464.  
  2465. if /i %line4% equ 111 (goto xwin)
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475. set /a line5= %x3% + %x5% + %x7%
  2476.  
  2477.  
  2478.  
  2479. if /i %line5% equ 111 (goto xwin)
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489. set /a line6= %x1% + %x4% + %x7%
  2490.  
  2491.  
  2492.  
  2493. if /i %line6% equ 3 (goto xwin)
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503. set /a line7= %x2% + %x5% + %x8%
  2504.  
  2505.  
  2506.  
  2507. if /i %line7% equ 30 (goto xwin)
  2508.  
  2509.  
  2510.  
  2511.  
  2512.  
  2513.  
  2514.  
  2515.  
  2516.  
  2517. set /a line8= %x3% + %x6% + %x9%
  2518.  
  2519.  
  2520.  
  2521. if /i %line8% equ 300 (goto xwin)
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531. set go=1ogame
  2532.  
  2533.  
  2534.  
  2535. set /a turns= %turns% + 1
  2536.  
  2537.  
  2538.  
  2539. goto 1display
  2540.  
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549. ::~ Sets the turn to the player, increases the turns variable by one. 'Goto's the display.
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582.  
  2583.  
  2584.  
  2585.  
  2586.  
  2587.  
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595.  
  2596.  
  2597.  
  2598.  
  2599.  
  2600.  
  2601.  
  2602.  
  2603.  
  2604.  
  2605.  
  2606.  
  2607.  
  2608.  
  2609.  
  2610.  
  2611.  
  2612.  
  2613.  
  2614.  
  2615.  
  2616.  
  2617.  
  2618.  
  2619. ::#######################################################
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.  
  2645.  
  2646.  
  2647.  
  2648.  
  2649.  
  2650.  
  2651.  
  2652.  
  2653.  
  2654.  
  2655.  
  2656.  
  2657.  
  2658.  
  2659. ::~ Two player is exactly the same as one player, apart from the computer is replaced by a second player, the code is otherwise identical and does not need explaining again.
  2660.  
  2661.  
  2662.  
  2663.  
  2664.  
  2665.  
  2666.  
  2667.  
  2668.  
  2669.  
  2670.  
  2671.  
  2672.  
  2673.  
  2674.  
  2675. :2p
  2676.  
  2677. set turns=0
  2678.  
  2679. set x1=0
  2680.  
  2681. set x2=0
  2682.  
  2683. set x3=0
  2684.  
  2685. set x4=0
  2686.  
  2687. set x5=0
  2688.  
  2689. set x6=0
  2690.  
  2691. set x7=0
  2692.  
  2693. set x8=0
  2694.  
  2695. set x9=0
  2696.  
  2697. set o1=0
  2698.  
  2699. set o2=0
  2700.  
  2701. set o3=0
  2702.  
  2703. set o4=0
  2704.  
  2705. set o5=0
  2706.  
  2707. set o6=0
  2708.  
  2709. set o7=0
  2710.  
  2711. set o8=0
  2712.  
  2713. set o9=0
  2714.  
  2715. set d1=1
  2716.  
  2717. set d2=2
  2718.  
  2719. set d3=3
  2720.  
  2721. set d4=4
  2722.  
  2723. set d5=5
  2724.  
  2725. set d6=6
  2726.  
  2727. set d7=7
  2728.  
  2729. set d8=8
  2730.  
  2731. set d9=9
  2732.  
  2733. set rnumber=%random%
  2734.  
  2735. set rnumber2=rnumber
  2736.  
  2737. set /a rnumber= %rnumber% / 2
  2738.  
  2739. set /a rnumber= %rnumber% * 2
  2740.  
  2741. if %rnumber%==%rnumber2% (
  2742.  
  2743.  
  2744.  
  2745. echo Crosses go first
  2746.  
  2747.  
  2748.  
  2749. pause>nul
  2750.  
  2751.  
  2752.  
  2753. set rnumber=
  2754.  
  2755.  
  2756.  
  2757. set rnumber2=
  2758.  
  2759.  
  2760.  
  2761. set go=2xgame
  2762.  
  2763.  
  2764.  
  2765. goto 2display
  2766.  
  2767. ) else (
  2768.  
  2769. echo Noughts go first
  2770.  
  2771. pause>nul
  2772.  
  2773. set rnumber=
  2774.  
  2775. set rnumber2=
  2776.  
  2777. set go=2ogame
  2778.  
  2779. goto 2display
  2780.  
  2781. )
  2782.  
  2783. :2display
  2784.  
  2785. cls
  2786.  
  2787. echo %d1% %d2% %d3%
  2788.  
  2789. echo %d4% %d5% %d6%
  2790.  
  2791. echo %d7% %d8% %d9%
  2792.  
  2793. if /i %turns% equ 9 (goto draw)
  2794.  
  2795. echo.
  2796.  
  2797. if /i "%go%"=="2ogame" (
  2798.  
  2799. echo Nought's Turn
  2800.  
  2801. ) ELSE (
  2802.  
  2803. echo Cross's Turn
  2804.  
  2805. )
  2806.  
  2807. echo.
  2808.  
  2809.  
  2810.  
  2811. goto %go%
  2812.  
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821. :2ogame
  2822.  
  2823.  
  2824.  
  2825. echo Choose the number of the space you'd like to choose
  2826.  
  2827.  
  2828.  
  2829. set guess=
  2830.  
  2831.  
  2832.  
  2833. set /p guess=
  2834.  
  2835.  
  2836.  
  2837. if not defined guess goto 2display
  2838.  
  2839.  
  2840.  
  2841. set guess=%guess:~0,1%
  2842.  
  2843.  
  2844.  
  2845. if /i not %guess% leq 9 goto 2display
  2846.  
  2847.  
  2848.  
  2849. if /i not %guess% gtr 0 goto 2display
  2850.  
  2851.  
  2852.  
  2853. if /i !d%guess%! neq %guess% goto 2display
  2854.  
  2855.  
  2856.  
  2857. goto 2o%guess%
  2858.  
  2859.  
  2860.  
  2861.  
  2862.  
  2863.  
  2864.  
  2865.  
  2866.  
  2867.  
  2868.  
  2869.  
  2870.  
  2871.  
  2872.  
  2873. :2o1
  2874.  
  2875.  
  2876.  
  2877. set o1=1
  2878.  
  2879.  
  2880.  
  2881. set d1=O
  2882.  
  2883.  
  2884.  
  2885. goto 2oprocess
  2886.  
  2887.  
  2888.  
  2889. :2o2
  2890.  
  2891.  
  2892.  
  2893. set o2=10
  2894.  
  2895.  
  2896.  
  2897. set d2=O
  2898.  
  2899.  
  2900.  
  2901. goto 2oprocess
  2902.  
  2903.  
  2904.  
  2905. :2o3
  2906.  
  2907.  
  2908.  
  2909. set o3=100
  2910.  
  2911.  
  2912.  
  2913. set d3=O
  2914.  
  2915.  
  2916.  
  2917. goto 2oprocess
  2918.  
  2919.  
  2920.  
  2921. :2o4
  2922.  
  2923. set o4=1
  2924.  
  2925. set d4=O
  2926.  
  2927. goto 2oprocess
  2928.  
  2929. :2o5
  2930.  
  2931.  
  2932.  
  2933. set o5=10
  2934.  
  2935.  
  2936.  
  2937. set d5=O
  2938.  
  2939.  
  2940.  
  2941. goto 2oprocess
  2942.  
  2943.  
  2944.  
  2945. :2o6
  2946.  
  2947.  
  2948.  
  2949. set o6=100
  2950.  
  2951.  
  2952.  
  2953. set d6=O
  2954.  
  2955.  
  2956.  
  2957. goto 2oprocess
  2958.  
  2959.  
  2960.  
  2961. :2o7
  2962.  
  2963.  
  2964.  
  2965. set o7=1
  2966.  
  2967.  
  2968.  
  2969. set d7=O
  2970.  
  2971.  
  2972.  
  2973. goto 2oprocess
  2974.  
  2975.  
  2976.  
  2977. :2o8
  2978.  
  2979.  
  2980.  
  2981. set o8=10
  2982.  
  2983.  
  2984.  
  2985. set d8=O
  2986.  
  2987.  
  2988.  
  2989. goto 2oprocess
  2990.  
  2991.  
  2992.  
  2993. :2o9
  2994.  
  2995.  
  2996.  
  2997. set o9=100
  2998.  
  2999.  
  3000.  
  3001. set d9=O
  3002.  
  3003.  
  3004.  
  3005. goto 2oprocess
  3006.  
  3007.  
  3008.  
  3009.  
  3010.  
  3011.  
  3012.  
  3013.  
  3014.  
  3015. :2oprocess
  3016.  
  3017.  
  3018.  
  3019. set /a line1= %o1% + %o2% + %o3%
  3020.  
  3021.  
  3022.  
  3023. if /i %line1% equ 111 (goto owin)
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033. set /a line2= %o4% + %o5% + %o6%
  3034.  
  3035.  
  3036.  
  3037. if /i %line2% equ 111 (goto owin)
  3038.  
  3039.  
  3040.  
  3041.  
  3042.  
  3043.  
  3044.  
  3045.  
  3046.  
  3047. set /a line3= %o7% + %o8% + %o9%
  3048.  
  3049.  
  3050.  
  3051. if /i %line3% equ 111 (goto owin)
  3052.  
  3053.  
  3054.  
  3055.  
  3056.  
  3057.  
  3058.  
  3059.  
  3060.  
  3061. set /a line4= %o1% + %o5% + %o9%
  3062.  
  3063.  
  3064.  
  3065. if /i %line4% equ 111 (goto owin)
  3066.  
  3067.  
  3068.  
  3069.  
  3070.  
  3071.  
  3072.  
  3073.  
  3074.  
  3075. set /a line5= %o3% + %o5% + %o7%
  3076.  
  3077.  
  3078.  
  3079. if /i %line5% equ 111 (goto owin)
  3080.  
  3081.  
  3082.  
  3083.  
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089. set /a line6= %o1% + %o4% + %o7%
  3090.  
  3091.  
  3092.  
  3093. if /i %line6% equ 3 (goto owin)
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.  
  3100.  
  3101.  
  3102.  
  3103. set /a line7= %o2% + %o5% + %o8%
  3104.  
  3105.  
  3106.  
  3107. if /i %line7% equ 30 (goto owin)
  3108.  
  3109.  
  3110.  
  3111.  
  3112.  
  3113.  
  3114.  
  3115.  
  3116.  
  3117. set /a line8= %o3% + %o6% + %o9%
  3118.  
  3119.  
  3120.  
  3121. if /i %line8% equ 300 (goto owin)
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127.  
  3128.  
  3129.  
  3130.  
  3131. set go=2xgame
  3132.  
  3133.  
  3134.  
  3135. set guess=
  3136.  
  3137.  
  3138.  
  3139. set /a turns= %turns% + 1
  3140.  
  3141.  
  3142.  
  3143. goto 2display
  3144.  
  3145.  
  3146.  
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174.  
  3175.  
  3176.  
  3177.  
  3178.  
  3179.  
  3180.  
  3181.  
  3182.  
  3183.  
  3184.  
  3185.  
  3186.  
  3187.  
  3188.  
  3189.  
  3190.  
  3191.  
  3192.  
  3193.  
  3194.  
  3195. :2xgame
  3196.  
  3197.  
  3198.  
  3199. echo Choose the number of the space you'd like to choose
  3200.  
  3201.  
  3202.  
  3203. set guess=
  3204.  
  3205.  
  3206.  
  3207. set /p guess=
  3208.  
  3209.  
  3210.  
  3211. if not defined guess goto 2display
  3212.  
  3213.  
  3214.  
  3215. set guess=%guess:~0,1%
  3216.  
  3217.  
  3218.  
  3219. if /i not %guess% leq 9 goto 2display
  3220.  
  3221.  
  3222.  
  3223. if /i not %guess% gtr 0 goto 2display
  3224.  
  3225.  
  3226.  
  3227. if /i !d%guess%! neq %guess% goto 2display
  3228.  
  3229.  
  3230.  
  3231. goto 2x%guess%
  3232.  
  3233. :2x1
  3234.  
  3235. set x1=1
  3236.  
  3237. set d1=X
  3238.  
  3239. goto 2xprocess
  3240.  
  3241. :2x2
  3242.  
  3243. set x2=10
  3244.  
  3245. set d2=X
  3246.  
  3247. goto 2xprocess
  3248.  
  3249. :2x3
  3250.  
  3251. set x3=100
  3252.  
  3253. set d3=X
  3254.  
  3255. goto 2xprocess
  3256.  
  3257. :2x4
  3258.  
  3259. set x4=1
  3260.  
  3261. set d4=X
  3262.  
  3263. goto 2xprocess
  3264.  
  3265. :2x5
  3266.  
  3267. set x5=10
  3268.  
  3269. set d5=X
  3270.  
  3271. goto 2xprocess
  3272.  
  3273. :2x6
  3274.  
  3275. set x6=100
  3276.  
  3277. set d6=X
  3278.  
  3279. goto 2xprocess
  3280.  
  3281. :2x7
  3282.  
  3283. set x7=1
  3284.  
  3285. set d7=X
  3286.  
  3287. goto 2xprocess
  3288.  
  3289. :2x8
  3290.  
  3291. set x8=10
  3292.  
  3293. set d8=X
  3294.  
  3295. goto 2xprocess
  3296.  
  3297. :2x9
  3298.  
  3299. set x9=100
  3300.  
  3301. set d9=X
  3302.  
  3303. goto 2xprocess
  3304.  
  3305. :2xprocess
  3306.  
  3307. set /a line1= %x1% + %x2% + %x3%
  3308.  
  3309. if /i %line1% equ 111 (goto xwin)
  3310.  
  3311. set /a line2= %x4% + %x5% + %x6%
  3312.  
  3313. if /i %line2% equ 111 (goto xwin)
  3314.  
  3315. set /a line3= %x7% + %x8% + %x9%
  3316.  
  3317. if /i %line3% equ 111 (goto xwin)
  3318.  
  3319. set /a line4= %x1% + %x5% + %x9%
  3320.  
  3321. if /i %line4% equ 111 (goto xwin)
  3322.  
  3323. set /a line5= %x3% + %x5% + %x7%
  3324.  
  3325. if /i %line5% equ 111 (goto xwin)
  3326.  
  3327. set /a line6= %x1% + %x4% + %x7%
  3328.  
  3329. if /i %line6% equ 3 (goto xwin)
  3330.  
  3331. set /a line7= %x2% + %x5% + %x8%
  3332.  
  3333. if /i %line7% equ 30 (goto xwin)
  3334.  
  3335. set /a line8= %x3% + %x6% + %x9%
  3336.  
  3337. if /i %line8% equ 300 (goto xwin)
  3338.  
  3339. set go=2ogame
  3340.  
  3341. set /a turns= %turns% + 1
  3342.  
  3343. goto 2display
  3344.  
  3345. :draw
  3346.  
  3347. echo.
  3348.  
  3349. Echo It's A Draw!
  3350.  
  3351. pause>nul
  3352.  
  3353. goto menu
  3354.  
  3355. :owin
  3356.  
  3357. cls
  3358.  
  3359. echo %d1% %d2% %d3%
  3360.  
  3361. echo %d4% %d5% %d6%
  3362.  
  3363. echo %d7% %d8% %d9%
  3364.  
  3365. Echo Noughts Win!
  3366.  
  3367. pause>nul
  3368.  
  3369. goto menu
  3370.  
  3371. :xwin
  3372.  
  3373. cls
  3374.  
  3375. echo %d1% %d2% %d3%
  3376.  
  3377. echo %d4% %d5% %d6%
  3378.  
  3379. echo %d7% %d8% %d9%
  3380.  
  3381. Echo Crosses Win!
  3382.  
  3383. Pause>nul
  3384.  
  3385. goto menu
  3386.  
  3387. :end
  3388.  
  3389. set d1=
  3390.  
  3391. set d2=
  3392.  
  3393. set d3=
  3394.  
  3395. set d4=
  3396.  
  3397. set d5=
  3398.  
  3399. set d6=
  3400.  
  3401. set d7=
  3402.  
  3403. set d8=
  3404.  
  3405. set d9=
  3406.  
  3407. set o1=
  3408.  
  3409. set o2=
  3410.  
  3411. set o3=
  3412.  
  3413. set o4=
  3414.  
  3415. set o5=
  3416.  
  3417. set o6=
  3418.  
  3419. set o7=
  3420.  
  3421. set o8=
  3422.  
  3423. set o9=
  3424.  
  3425. set x1=
  3426.  
  3427. set x2=
  3428.  
  3429. set x3=
  3430.  
  3431. set x4=
  3432.  
  3433. set x5=
  3434.  
  3435. set x6=
  3436.  
  3437. set x7=
  3438.  
  3439. set x8=
  3440.  
  3441. set x9=
  3442.  
  3443. set guess=
  3444.  
  3445. set turns=
  3446.  
  3447. set line1=
  3448.  
  3449. set line2=
  3450.  
  3451. set line3=
  3452.  
  3453. set line4=
  3454.  
  3455. set line5=
  3456.  
  3457. set line6=
  3458.  
  3459. set line7=
  3460.  
  3461. set line8=
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement