Sanguin

CMD Tic Tac Toe w/ A.I.

Jan 12th, 2015
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 6.75 KB | None | 0 0
  1. @echo off
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.     ::Code by SKIPP3R::
  15.    ::DONT MAKE THIS CODE URS!::
  16.    ::(but if u do send me the improvments ;D::
  17.    ::Have fun::
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37. cls
  38. title Tic Tac Todesfalle
  39.  
  40. :1random
  41. set /a gab=%random% %%7
  42. if %gab%==1 goto 1schwarz
  43. if %gab%==2 goto 1gelb
  44. if %gab%==3 goto 1magenta
  45. if %gab%==4 goto 1random
  46. if %gab%==5 goto 1weiss
  47. if %gab%==6 goto 1randon
  48.  
  49. :1randon
  50. cls
  51. color %kp%3
  52. set /p gaa=Spieler 1 waehlen sie ihre Farbe[rot/blau/zyan/gruen]:
  53. if /i %gaa%==rot goto 1rot
  54. if /i %gaa%==blau goto 1blau
  55. if /i %gaa%==zyan goto 1zyan
  56. if /i %gaa%==gruen goto 1gruen
  57. goto 1randon
  58.  
  59. :main
  60. color %kp%%ka%
  61. set z1=1
  62. set z2=2
  63. set z3=3
  64. set z4=4
  65. set z5=5
  66. set z6=6
  67. set z7=7
  68. set z8=8
  69. set z9=9
  70. set zreset=reset
  71. set zresetall=resetall
  72. set whois=2
  73. :spieler1
  74.  
  75. cls
  76. echo.
  77. echo programmiert von : mir!
  78. echo.
  79. echo.
  80. echo spieler 1 setzt 0
  81. echo.
  82. echo.
  83. echo              %z1%__%z2%__%z3%
  84. echo              .......
  85. echo              %z4%__%z5%__%z6%
  86. echo              .......
  87. echo              %z7%__%z8%__%z9%
  88. echo.
  89.  
  90. set /p zahl=choose a number
  91. if %zahl%==1 goto 1
  92. if %zahl%==2 goto 2
  93. if %zahl%==3 goto 3
  94. if %zahl%==4 goto 4
  95. if %zahl%==5 goto 5
  96. if %zahl%==6 goto 6
  97. if %zahl%==7 goto 7
  98. if %zahl%==8 goto 8
  99. if %zahl%==9 goto 9
  100. if %zahl%==reset goto main
  101. if %zahl%==resetall goto 1random
  102. goto spieler1
  103.  
  104. :1
  105. if %z1%==x goto Spieler1
  106. if %z1%==0 goto spieler1
  107. set z1=0
  108. set whois=1
  109. goto check
  110.  
  111.  
  112. :2
  113. if %z2%==x goto Spieler1
  114. if %z2%==0 goto spieler1
  115. set z2=0
  116. set whois=1
  117. goto check
  118.  
  119.  
  120. :3
  121. if %z3%==x goto Spieler1
  122. if %z3%==0 goto spieler1
  123. set z3=0
  124. set whois=1
  125. goto check
  126.  
  127.  
  128. :4
  129. if %z4%==x goto Spieler1
  130. if %z4%==0 goto spieler1
  131. set z4=0
  132. set whois=1
  133. goto check
  134.  
  135.  
  136. :5
  137. if %z5%==x goto Spieler1
  138. if %z5%==0 goto spieler1
  139. set z5=0
  140. set whois=1
  141. goto check
  142.  
  143.  
  144. :6
  145. if %z6%==x goto Spieler1
  146. if %z6%==0 goto spieler1
  147. set whois=1
  148. set z6=0
  149. goto check
  150.  
  151.  
  152. :7
  153. if %z7%==x goto Spieler1
  154. if %z7%==0 goto spieler1
  155.  
  156. set whois=1
  157. set z7=0
  158. goto check
  159.  
  160.  
  161. :8
  162. if %z8%==x goto Spieler1
  163. if %z8%==0 goto spieler1
  164. set z8=0
  165. set whois=1
  166. goto check
  167.  
  168.  
  169. :9
  170. if %z9%==x goto Spieler1
  171. if %z9%==0 goto spieler1
  172. set z9=0
  173. set whois=1
  174. goto check
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182. ::         say hello to BOB!
  183. :spieler2
  184.  
  185.  
  186. ::         z1 goes invulnerable
  187. if %z2%==0 if %z3%==0 if %z1%==1 (
  188. set z1=x
  189. set whois=0
  190. goto check
  191. )
  192.  
  193. if %z5%==0 if %z9%==0 if %z1%==1 (
  194. set z1=x
  195. set whois=0
  196. goto check
  197. )
  198.  
  199. if %z4%==0 if %z7%==0 if %z1%==1 (
  200. set z1=x
  201. set whois=0
  202. goto check
  203. )
  204. ::         z2 goes invulnerable
  205. if %z1%==0 if %z3%==0 if %z2%==2 (
  206. set z2=x
  207. set whois=0
  208. goto check
  209. )
  210.  
  211. if %z5%==0 if %z8%==0 if %z2%==2 (
  212. set z2=x
  213. set whois=0
  214. goto check
  215. )
  216. ::         z3 goes invulnerable
  217. if %z6%==0 if %z9%==0 if %z3%==3 (
  218. set z3=x
  219. set whois=0
  220. goto check
  221. )
  222.  
  223. if %z5%==0 if %z7%==0 if %z3%==3 (
  224. set z3=x
  225. set whois=0
  226. goto check
  227. )
  228.  
  229. if %z2%==0 if %z1%==0 if %z3%==3 (
  230. set z3=x
  231. set whois=0
  232. goto check
  233. )
  234. ::         z4 goes invulnerable
  235. if %z1%==0 if %z7%==0 if %z4%==4 (
  236. set z4=x
  237. set whois=0
  238. goto check
  239. )
  240.  
  241. if %z5%==0 if %z6%==0 if %z4%==4 (
  242. set z4=x
  243. set whois=0
  244. goto check
  245. )
  246.  
  247. ::     z5 goes invulnerable
  248. if %z2%==0 if %z8%==0 if %z5%==5 (
  249. set z5=x
  250. set whois=0
  251. goto check
  252. )
  253.  
  254. if %z4%==0 if %z6%==0 if %z5%==5 (
  255. set z5=x
  256. set whois=0
  257. goto check
  258. )
  259.  
  260. if %z1%==0 if %z9%==0 if %z5%==5 (
  261. set z5=x
  262. set whois=0
  263. goto check
  264. )
  265.  
  266. if %z3%==0 if %z7%==0 if %z5%==5 (
  267. set z5=x
  268. set whois=0
  269. goto check
  270. )
  271.  
  272. ::         z6 goes invulnerable
  273.  
  274. if %z3%==0 if %z9%==0 if %z6%==6 (
  275. set z6=x
  276. set whois=0
  277. goto check
  278. )
  279.  
  280. if %z5%==0 if %z4%==0 if %z6%==6 (
  281. set z6=x
  282. set whois=0
  283. goto check
  284. )
  285.  
  286. ::         z7 goes invulnerable
  287.  
  288. if %z1%==0 if %z4%==0 if %z7%==7 (
  289. set z7=x
  290. set whois=0
  291. goto check
  292. )
  293.  
  294. if %z5%==0 if %z3%==0 if %z7%==7 (
  295. set z7=x
  296. set whois=0
  297. goto check
  298. )
  299.  
  300. if %z8%==0 if %z9%==0 if %z7%==7 (
  301. set z7=x
  302. set whois=0
  303. goto check
  304. )
  305.  
  306. ::         z8 goes invulnerable
  307.  
  308. if %z2%==0 if %z5%==0 if %z8%==8 (
  309. set z1=x
  310. set whois=0
  311. goto check
  312. )
  313.  
  314. if %z7%==0 if %z9%==0 if %z8%==8 (
  315. set z8=x
  316. set whois=0
  317. goto check
  318. )
  319.  
  320. ::      z9 goes invulnerable
  321. if %z1%==0 if %z5%==0 if %z9%==9 (
  322. set z9=x
  323. set whois=0
  324. goto check
  325. )
  326.  
  327. if %z3%==0 if %z6%==0 if %z9%==9 (
  328. set z9=x
  329. set whois=0
  330. goto check
  331. )
  332.  
  333. if %z7%==0 if %z8%==0 if %z9%==9 (
  334. set z9=x
  335. set whois=0
  336. goto check
  337. )
  338. ::         BOB is finished after the next code segment :(
  339. :totalynotrdm
  340. set /a nr=%random% %%10
  341. if %z1% neq 1 if %z2% neq 2 if %z3% neq 3 if %z4% neq 4 if %z5% neq 5 if %z6% neq 6 if %z7% neq 7 if %z8% neq 8 if %z9% neq 9 (
  342. goto gs0
  343. )
  344. if %nr%==1 if %z1%==1 (
  345. set z1=x
  346. set whois=0
  347. goto check
  348. )
  349. if %nr%==2 if %z2%==2 (
  350. set z2=x
  351. set whois=0
  352. goto check
  353. )
  354. if %nr%==3 if %z3%==3 (
  355. set z3=x
  356. set whois=0
  357. goto check
  358. )
  359. if %nr%==4 if %z4%==4 (
  360. set z4=x
  361. set whois=0
  362. goto check
  363. )
  364. if %nr%==5 if %z5%==5 (
  365. set z5=x
  366. set whois=0
  367. goto check
  368. )
  369. if %nr%==6 if %z6%==6 (
  370. set z6=x
  371. set whois=0
  372. goto check
  373. )
  374. if %nr%==7 if %z7%==7 (
  375. set z7=x
  376. set whois=0
  377. goto check
  378. )
  379. if %nr%==8 if %z8%==8 (
  380. set z8=x
  381. set whois=0
  382. goto check
  383. )
  384. if %nr%==9 if %z9%==9 (
  385. set z9=x
  386. set whois=0
  387. goto check
  388. )
  389. goto totalynotrdm
  390.  
  391. :check
  392.  
  393. if %z1%==0 if %z2%==0 if %z3%==0 goto gs1
  394. if %z4%==0 if %z5%==0 if %z6%==0 goto gs1
  395. if %z7%==0 if %z8%==0 if %z9%==0 goto gs1
  396. if %z1%==0 if %z4%==0 if %z7%==0 goto gs1
  397. if %z2%==0 if %z5%==0 if %z8%==0 goto gs1
  398. if %z3%==0 if %z6%==0 if %z9%==0 goto gs1
  399. if %z7%==0 if %z5%==0 if %z3%==0 goto gs1
  400. if %z1%==0 if %z5%==0 if %z9%==0 goto gs1
  401.  
  402. if %z1%==x if %z2%==x if %z3%==x goto gs2
  403. if %z4%==x if %z5%==x if %z6%==x goto gs2
  404. if %z7%==x if %z8%==x if %z9%==x goto gs2
  405. if %z1%==x if %z4%==x if %z7%==x goto gs2
  406. if %z2%==x if %z5%==x if %z8%==x goto gs2
  407. if %z3%==x if %z6%==x if %z9%==x goto gs2
  408. if %z7%==x if %z5%==x if %z3%==x goto gs2
  409. if %z1%==x if %z5%==x if %z9%==x goto gs2
  410.  
  411.  
  412. if %whois%==1 goto spieler2
  413. if %whois%==0 goto spieler1
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421. :gs1
  422. echo.
  423. echo spieler 1 hat gewonnen!
  424. echo.
  425. set papapipipopo=0
  426. :gs1.1
  427. set /a papapipipopo=%papapipipopo%+1
  428. if %papapipipopo%==100 goto gs1.2
  429. goto gs1.1
  430. :gs1.2
  431. cls
  432. set /p game=Nochmal? [J/N]:
  433. if /i %game%==J goto main
  434. exit
  435.  
  436. :gs2
  437. echo.
  438. echo spieler 2 hat gewonnen!
  439. echo.
  440. pause
  441. cls
  442. set /p game=Nochmal? [J/N]:
  443. if /i %game%==J goto main
  444. exit
  445.  
  446. :gs0
  447. echo .
  448. echo Niemand hat gewonnen :(
  449. echo.
  450. pause
  451. cls
  452. set /p game=Nochmal? [J/N]:
  453. if /i %game%==J goto main
  454. exit
  455.  
  456. :1schwarz
  457. set kp=0
  458. goto 1randon
  459.  
  460. :1gelb
  461. set kp=e
  462. goto 1randon
  463.  
  464.  
  465. :1magenta
  466. set kp=d
  467. goto 1randon
  468.  
  469. :1weiss
  470. set kp=f
  471. goto 1randon
  472.  
  473. :1gruen
  474. set ka=a
  475. goto main
  476. :1zyan
  477. set ka=b
  478. goto main
  479. :1blau
  480. set ka=9
  481. goto main
  482. :1rot
  483. set ka=c
  484. goto main
Advertisement
Add Comment
Please, Sign In to add comment