Batch processing of the implementation of Gobang human-computer vs game _dos/bat

Source: Internet
Author: User
Tags goto
Effect Chart:

Core code:
Copy Code code as follows:

@echo off&setlocal enabledelayedexpansion
Set Li0=┌───────────────────┐
Set li1=│┌┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┐│1
FOR/L%%a in (2,1,18) do (set li%%a=│├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤│%%a)
Set li19=│└┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┘│19
Set Li20=└───────────────────┘
Set li21= A B C D E F G H I J K L M N O P Q R S
For%%a in (%li21%) do (set/a. +=1,%%a=.&set z!.! =%%A)
Set z0= &set z20= &set "z21="

Set li5=!li5! Five chess player vs.
Set li7=!li7! Batch Processing
Set li9=!li9! Computer Level Medium
Set li12=!li12! Written and completed by Netbenton
Set li14=!li14! The chessboard design refers to the Batman
Title Batch Gobang


Set str=###################
Set. =0
FOR/L%%a in (1,1,19) do (
Set He%%a=!str!&set sh%%a=!str!
FOR/L%%b in (1,1,19) do set [%%a.%%b=0
)

Set. =33
FOR/L%%a in (5,1,19) do (
Set Pi%%a=!str:~,%%a!&set ni%%a=!str:~,%%a!
Set PI!.! =!str:~,%%a!&set ni!.! =!str:~,%%a!
set/a.-=1
)


Set =0&set a = computer
set0= &set a0= Player

:: Set Up Computer IQ
Set idea=@@@@ zzfcthotfixz #@@@@5 @#@@@4 @@@#@2 @@#@@3 $#$$$4 $$#$$3 $$$#$2 $ $ #1 #$$$$5 #$$#$ #3 #$#$$ #4 #@@@# #2 ##@@@ zzfcthotfixz #@@#@ #3 #@# @@ ZZFCTHOTFIXZ #@@@ Zzfcthotfixz
Set idea=!idea! ##@@@4 @@@# #2 ##$$$ #5 #$$$# #2 #$$$ #1 ##@@ zzfcthotfixz #@@# #2 ##$$ #4 #$$# #2 #$#$ #3 @@## #3 ###@@3
Set idea=!idea! ##@# #2 ###@ #3 #@## #3 @### #4 ####@2 ############# #7 ########## #6 ####### #4 #3 ### #2
Set ttr=!idea:@=!&set ttr=!ttr:$=0!
For%%a in (!ttr!) do (set Var=%%a&set!var:~,-1!=!var:~-1!&set idea=!idea!!var:~,-1!)
Set ttr=
:: Set Up Computer IQ

: Restart
FOR/L%%a in (0,1,21) do (Echo!z%%a!! li%%a!)
Setlocal enabledelayedexpansion
Set li21=!li21! Reboot starts again, exit exits.
set/p var= Select who first [W, player D, PC Q, exit]:
if/i "!var!" equ "Q" goto:eof
if/i "!var!" equ "W" (set zhi=) Else (set zhi=0)
Echo.


: Loop
If%zhi% equ goto:men
Set. =&set put1=
For%%a in (!idea!) do (
For%%b in (him sh) do (
FOR/L%%c in (1,1,19) do (
If "!%%b%%c:%%a=!" Neq "!%%b%%c!" set/a. +=1&set put!.! =%%b%%c
)        )
For%%b in (Pi ni) do (
FOR/L%%c in (5,1,33) do (
If "!%%b%%c:%%a=!" Neq "!%%b%%c!" set/a. +=1&set put!.! =%%b%%c
)        )
If defined PUT1 set Put=%%a&goto:get
)

Echo. It's draw.
Pause
Goto:restart

: Men
FOR/L%%a in (0,1,21) do (Echo!z%%a!! li%%a!)
set/p before user=[column, after line]:
Echo.
If "!user!" equ "reboot" Endlocal&goto:restart
If "!user!" equ "Exit" exit
set/a pos=!user:~0,1!,poh=!user:~1,2!,var=pos-1 2>nul
If not defined [!poh!.! Pos! echo input point does not exist &goto:men
If "!he%poh%:~%var%,1!" NEQ "#" echo that point already has a son &goto men
Goto:getok

: Get
set/a. =!random!%%.+1
Set put=!put%.%!!put!
:: Random Take the best way

for/f "Tokens=1-3"%%a in ("%put%") Do (
Set VAR=!%%A%%B:*%%C=!SRQPONMLKJIHGFEDCBA0
set/a var=!var:~19,1!+%%c
If "%%a" equ "he" (set/a Poh=%%b,pos=20-var)
If "%%a" equ "sh" (set/a poh=20-var,pos=%%b)
If%%b LSS (set/a var=%%b-var+1) Else (set/a var=38-%%b-var+1)
If "%%a" Equ "PI" (If%%b LSS (set/a pos=var,poh=%%b-var+1) Else (set/a Poh=20-var,pos=%%b-19+var))
If "%%a" Equ "ni" (If%%b LSS (set/a pos=var,poh=19-%%b+var) Else (set/a Poh=var,pos=%%b-19+var))
)
Echo Computer last in:!z%pos%!! z%poh%! (%poh%)

: Getok
Set Zhi=!%zhi%!&set win=!zhi!! zhi!! zhi!! zhi!! zhi!
set/a Piph=poh+pos-1,lips=pos+1,niph=19+pos-poh

If!piph! LSS (set/a pips=pos) Else (set/a Pips=20-poh)
If!niph! LSS (set/a nips=pos) Else (set/a Nips=poh)


For%%a in ("Li!poh!!lips!" "He!poh!!pos!" "Sh!pos!!poh!" "Pi!piph!!pips!" "Ni!niph!!nips!") Do (
for/f "tokens=1,2"%%b in (%%a) do (
If defined%%b (
set/a. =%%c-1
For%%d in (!.!) do (set%%b=!%%b:~0,%%d!%zhi%!%%b:~%%c!)
If "!%%b:%win%=!" NEQ "!%%b!" set win=y
)
)
)
set/a asc%zhi%+=1
If!win! Neq y Goto:loop
FOR/L%%a in (0,1,21) do (Echo!z%%a!! li%%a!)
set/p=!a%zhi%! %zhi%!asc%zhi%! the hand of Victory <nul
Pause
Endlocal&goto:restart

Because the code is more, the special package provides download Wuziqi_dos_jb51.rar
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.