Post: Batch file Word Guessing Game
04-21-2012, 11:50 PM #1
~SpongeBob
[move]Winning.[/move]
(adsbygoogle = window.adsbygoogle || []).push({}); Hey guys, well i guess il be the first to post some sort of code, i made it today, out of a whim,
its really simple, its just game where you guess a word.
    @echo off 
set /a num=%random% %%60 +1
setLocal EnableDelayedExpansion
set str=ABCDEFGHIJKLMNOPQRSTUVWXYZ
set /a P1=!random!%%26
set /a P2=!random!%%26
set /a P3=!random!%%26
set /a P4=!random!%%26
set /a P5=!random!%%26
set /a P6=!random!%%26
set /a P7=!random!%%26
set /a P8=!random!%%26
set /a P9=!random!%%26
set /a P10=!random!%%26
set /a P11=!random!%%26
set /a P12=!random!%%26
set /a P13=!random!%%26
set /a P14=!random!%%26
set /a P15=!random!%%26
set /a P16=!random!%%26
set /a P17=!random!%%26
set /a P18=!random!%%26
set /a P19=!random!%%26
set /a P20=!random!%%26
set /a P21=!random!%%26
set /a P22=!random!%%26
set /a P23=!random!%%26
set /a P24=!random!%%26
set /a P25=!random!%%26
set /a P26=!random!%%26

Title Word-Guessing-Game
:beginging
color 9
echo ------------------
echo [ Word Guessing Game ]
echo ------------------
PING 1.1.1.1 -n 1 -w 500 >NUL
cls
color 0A
echo ------------------
echo [ Word Guessing Game ]
echo ------------------
PING 1.1.1.1 -n 1 -w 500 >NUL
cls
color 0C
echo ------------------
echo [ Word Guessing Game ]
echo ------------------
PING 1.1.1.1 -n 1 -w 500 >NUL
cls
color 0D
echo ------------------
echo [ Word Guessing Game ]
echo ------------------
PING 1.1.1.1 -n 1 -w 500 >NUL
cls
color 0E
echo ------------------
echo [ Word Guessing Game ]
echo ------------------
PING 1.1.1.1 -n 1 -w 500 >NUL
:starting1
cls
color 0F
echo ------------------
echo [ Word Guessing Game ]
echo ------------------
echo Please select your dificulty.
echo (1) Easy
echo (2) Medium
echo (3) Hard
echo (4) Imposible
set /p dif=(1-4)
if %dif%==1 goto startE
if %dif%==2 goto startM
if %dif%==3 goto startH
if %dif%==4 goto startI
if NOT %dif%==1 goto starting1
:startE
cls
color 0F
Echo Welcome, You have selected Easy, Are you Ready to play?
set /p input=(Y/N)
if %input%==Y goto clear
if %input%==Yes goto clear
if %input%==yes goto clear
if %input%==y goto clear
if %input%==n goto bye
if %input%==no goto bye
if %input%==N goto bye
if %input%==No goto bye
if NOT %input%==Y goto start
:startM
cls
color 0F
Echo Welcome, You have selected Medium, Are you Ready to play?
set /p input=(Y/N)
if %input%==Y goto clearM
if %input%==Yes goto clearM
if %input%==yes goto clearM
if %input%==y goto clearM
if %input%==n goto bye
if %input%==no goto bye
if %input%==N goto bye
if %input%==No goto bye
if NOT %input%==Y goto start
:startH
cls
color 0F
Echo Welcome, You have selected Hard, Are you Ready to play?
set /p input=(Y/N)
if %input%==Y goto clearH
if %input%==Yes goto clearH
if %input%==yes goto clearH
if %input%==y goto clearH
if %input%==n goto bye
if %input%==no goto bye
if %input%==N goto bye
if %input%==No goto bye
if NOT %input%==Y goto start
:startI
cls
color 0F
Echo Welcome, You have selected Imposible, Are you Ready to play?
set /p input=(Y/N)
if %input%==Y goto clearI
if %input%==Yes goto clearI
if %input%==yes goto clearI
if %input%==y goto clearI
if %input%==n goto bye
if %input%==no goto bye
if %input%==N goto bye
if %input%==No goto bye
if NOT %input%==Y goto start
:clear
cls
goto selector
:clearM
cls
goto selectorM
:clearH
cls
goto selectorH
:clearI
cls
goto selectorI
:selector
title Selecting Word, This may take a second...
set /a num=%random% %%60 +1
if %random% == 1 goto hi1
if %random% == 2 goto hi2
if %random% == 3 goto hi3
if %random% == 4 goto hi1
if %random% == 5 goto hi2
if %random% == 6 goto hi3
if %random% == 7 goto hi1
if %random% == 8 goto hi2
if %random% == 9 goto hi3
if %random% == 10 goto hi1
if %random% == 11 goto hi2
if %random% == 12 goto hi3
if %random% == 13 goto hi1
if %random% == 14 goto hi2
if %random% == 15 goto hi3
if %random% == 16 goto hi1
if %random% == 17 goto hi2
if %random% == 18 goto hi3
if %random% == 19 goto hi1
if %random% == 20 goto hi2
if %random% == 21 goto hi3
if %random% == 22 goto hi1
if %random% == 23 goto hi2
if %random% == 24 goto hi3
if %random% == 25 goto hi1
if %random% == 26 goto hi2
if %random% == 27 goto hi3
if %random% == 28 goto hi1
if %random% == 29 goto hi2
if %random% == 30 goto hi3
if %random% == 31 goto hi1
if %random% == 32 goto hi2
if %random% == 33 goto hi3
if %random% == 34 goto hi1
if %random% == 35 goto hi2
if %random% == 36 goto hi3
if %random% == 37 goto hi1
if %random% == 38 goto hi2
if %random% == 39 goto hi3
if %random% == 40 goto hi1
if %random% == 41 goto hi2
if %random% == 42 goto hi3
if %random% == 43 goto hi1
if %random% == 44 goto hi2
if %random% == 45 goto hi3
if %random% == 46 goto hi1
if %random% == 47 goto hi2
if %random% == 48 goto hi3
if %random% == 49 goto hi1
if %random% == 50 goto hi2
if %random% == 51 goto hi3
if %random% == 52 goto hi1
if %random% == 53 goto hi2
if %random% == 54 goto hi3
if %random% == 55 goto hi1
if %random% == 56 goto hi2
if %random% == 57 goto hi3
if %random% == 58 goto hi1
if %random% == 59 goto hi2
if %random% == 60 goto hi3
if NOT %random% == 1 goto selector
:selectorM
title Selecting Word, This may take a second...
set var1= %random%
if %random% == 1 goto hiM
if %random% == 2 goto hi2M
if %random% == 3 goto hi3M
if %random% == 4 goto hiM
if %random% == 5 goto hi2M
if %random% == 6 goto hi3M
if %random% == 7 goto hiM
if %random% == 8 goto hi2M
if %random% == 9 goto hi3M
if %random% == 10 goto hi1M
if %random% == 11 goto hi2M
if %random% == 12 goto hi3M
if %random% == 13 goto hiM
if %random% == 14 goto hi2M
if %random% == 15 goto hi3M
if %random% == 16 goto hiM
if %random% == 17 goto hi2M
if %random% == 18 goto hi3M
if %random% == 19 goto hiM
if %random% == 20 goto hi2M
if %random% == 21 goto hi3M
if %random% == 22 goto hiM
if %random% == 23 goto hi2M
if %random% == 24 goto hi3M
if %random% == 25 goto hiM
if %random% == 26 goto hi2M
if %random% == 27 goto hi3M
if %random% == 28 goto hiM
if %random% == 29 goto hi2M
if %random% == 30 goto hi3M
if %random% == 31 goto hiM
if %random% == 32 goto hi2M
if %random% == 33 goto hi3M
if %random% == 34 goto hiM
if %random% == 35 goto hi2M
if %random% == 36 goto hi3M
if %random% == 37 goto hiM
if %random% == 38 goto hi2M
if %random% == 39 goto hi3M
if %random% == 40 goto hiM
if %random% == 41 goto hi2M
if %random% == 42 goto hi3M
if %random% == 43 goto hiM
if %random% == 44 goto hi2M
if %random% == 45 goto hi3M
if %random% == 46 goto hiM
if %random% == 47 goto hi2M
if %random% == 48 goto hi3M
if %random% == 49 goto hiM
if %random% == 50 goto hi2M
if %random% == 51 goto hi3M
if %random% == 52 goto hiM
if %random% == 53 goto hi2M
if %random% == 54 goto hi3M
if %random% == 55 goto hiM
if %random% == 56 goto hi2M
if %random% == 57 goto hi3M
if %random% == 58 goto hiM
if %random% == 59 goto hi2M
if %random% == 60 goto hi3M
if NOT %random% == 1 goto selectorM
:selectorH
title Selecting Word, This may take a second...
set /a num=%random% %%60 +1
if %random% == 1 goto hi1
if %random% == 2 goto hi2
if %random% == 3 goto hi3
if %random% == 4 goto hi1
if %random% == 5 goto hi2
if %random% == 6 goto hi3
if %random% == 7 goto hi1
if %random% == 8 goto hi2
if %random% == 9 goto hi3
if %random% == 10 goto hi1
if %random% == 11 goto hi2
if %random% == 12 goto hi3
if %random% == 13 goto hi1
if %random% == 14 goto hi2
if %random% == 15 goto hi3
if %random% == 16 goto hi1
if %random% == 17 goto hi2
if %random% == 18 goto hi3
if %random% == 19 goto hi1
if %random% == 20 goto hi2
if %random% == 21 goto hi3
if %random% == 22 goto hi1
if %random% == 23 goto hi2
if %random% == 24 goto hi3
if %random% == 25 goto hi1
if %random% == 26 goto hi2
if %random% == 27 goto hi3
if %random% == 28 goto hi1
if %random% == 29 goto hi2
if %random% == 30 goto hi3
if %random% == 31 goto hi1
if %random% == 32 goto hi2
if %random% == 33 goto hi3
if %random% == 34 goto hi1
if %random% == 35 goto hi2
if %random% == 36 goto hi3
if %random% == 37 goto hi1
if %random% == 38 goto hi2
if %random% == 39 goto hi3
if %random% == 40 goto hi1
if %random% == 41 goto hi2
if %random% == 42 goto hi3
if %random% == 43 goto hi1
if %random% == 44 goto hi2
if %random% == 45 goto hi3
if %random% == 46 goto hi1
if %random% == 47 goto hi2
if %random% == 48 goto hi3
if %random% == 49 goto hi1
if %random% == 50 goto hi2
if %random% == 51 goto hi3
if %random% == 52 goto hi1
if %random% == 53 goto hi2
if %random% == 54 goto hi3
if %random% == 55 goto hi1
if %random% == 56 goto hi2
if %random% == 57 goto hi3
if %random% == 58 goto hi1
if %random% == 59 goto hi2
if %random% == 60 goto hi3
if NOT %random% == 1 goto selectorH
:selectorI
title Selecting Word, This may take a second...
set /a num=%random% %%60 +1
if %random% == 1 goto hi1
if %random% == 2 goto hi2
if %random% == 3 goto hi3
if %random% == 4 goto hi1
if %random% == 5 goto hi2
if %random% == 6 goto hi3
if %random% == 7 goto hi1
if %random% == 8 goto hi2
if %random% == 9 goto hi3
if %random% == 10 goto hi1
if %random% == 11 goto hi2
if %random% == 12 goto hi3
if %random% == 13 goto hi1
if %random% == 14 goto hi2
if %random% == 15 goto hi3
if %random% == 16 goto hi1
if %random% == 17 goto hi2
if %random% == 18 goto hi3
if %random% == 19 goto hi1
if %random% == 20 goto hi2
if %random% == 21 goto hi3
if %random% == 22 goto hi1
if %random% == 23 goto hi2
if %random% == 24 goto hi3
if %random% == 25 goto hi1
if %random% == 26 goto hi2
if %random% == 27 goto hi3
if %random% == 28 goto hi1
if %random% == 29 goto hi2
if %random% == 30 goto hi3
if %random% == 31 goto hi1
if %random% == 32 goto hi2
if %random% == 33 goto hi3
if %random% == 34 goto hi1
if %random% == 35 goto hi2
if %random% == 36 goto hi3
if %random% == 37 goto hi1
if %random% == 38 goto hi2
if %random% == 39 goto hi3
if %random% == 40 goto hi1
if %random% == 41 goto hi2
if %random% == 42 goto hi3
if %random% == 43 goto hi1
if %random% == 44 goto hi2
if %random% == 45 goto hi3
if %random% == 46 goto hi1
if %random% == 47 goto hi2
if %random% == 48 goto hi3
if %random% == 49 goto hi1
if %random% == 50 goto hi2
if %random% == 51 goto hi3
if %random% == 52 goto hi1
if %random% == 53 goto hi2
if %random% == 54 goto hi3
if %random% == 55 goto hi1
if %random% == 56 goto hi2
if %random% == 57 goto hi3
if %random% == 58 goto hi1
if %random% == 59 goto hi2
if %random% == 60 goto hi3
if NOT %random% == 1 goto selectorI
:hi1
Title Word-Guessing-Game
Echo Word Selected.
Echo Your Word is 6 Letters long, and it has somthing to do with Wrighting.
PING 1.1.1.1 -n 1 -w 4500 >NUL
Cls
Echo The First Letter Could be [!str:~%P1%,1!, P, !str:~%P3%,1!, !str:~%P4%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Second Letter Could be [E, !str:~%P6%,1!, !str:~%P7%,1!, !str:~%P8%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Thrid Letter Could be [!str:~%P9%,1!, !str:~%P12%,1!, N, !str:~%P12%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Fourth Letter Could be [C, !str:~%P14%,1!, !str:~%P15%,1!, !str:~%P16%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Fifth Letter Could be [!str:~%P17%,1!, !str:~%P18%,1!, !str:~%P19%,1!, I]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Sixth Letter Could be [[!str:~%P24%,1!, !str:~%P23%,1!, !str:~%P22%,1!, L]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo What is your Guess?
set /p guess1=
if %guess1% == Pencil goto winner
if %guess1% == pencil goto winner
if NOT %guess1% == Pencil goto Loser
Pause
:hi2
Title Word-Guessing-Game
Echo Word Selected.
Echo Your Word is 7 Letters long, and it has somthing to do with Eyesight.
PING 1.1.1.1 -n 1 -w 4500 >NUL
Cls
Echo The First Letter Could be [!str:~%P1%,1!, G, !str:~%P3%,1!, !str:~%P4%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Second Letter Could be [!str:~%P5%,1!, !str:~%P6%,1!, L, !str:~%P8%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Thrid Letter Could be [A, !str:~%P12%,1!, !str:~%P11%,1!, !str:~%P12%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Fourth Letter Could be [[!str:~%P13%,1!, S, !str:~%P15%,1!, !str:~%P16%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Fifth Letter Could be [!str:~%P17%,1!, !str:~%P18%,1!, !str:~%P19%,1!, S]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Sixth Letter Could be [E, !str:~%P23%,1!, !str:~%P22%,1!, !str:~%P21%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Seventh Letter Could be [!str:~%P22%,1!, !str:~%P23%,1!, !str:~%P24%,1!, S]
Echo What is your Guess?
set /p guess1=
if %guess1% == Glasses goto winner
if %guess1% == glasses goto winner
if NOT %guess1% == glasses goto Loser
:hi3
Title Word-Guessing-Game
Echo Word Selected.
Echo Your Word is 5 Letters long, and it has somthing to do with Clothing.
PING 1.1.1.1 -n 1 -w 4500 >NUL
Cls
Echo The First Letter Could be [P, !str:~%P2%,1!, !str:~%P3%,1!, !str:~%P4%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Second Letter Could be [!str:~%P5%,1!, A, !str:~%P7%,1!, !str:~%P8%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Thrid Letter Could be [!str:~%P9%,1!, !str:~%P12%,1!, N, !str:~%P12%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Fourth Letter Could be [T, !str:~%P14%,1!, !str:~%P15%,1!, !str:~%P16%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Fifth Letter Could be [!str:~%P17%,1!, !str:~%P18%,1!, !str:~%P19%,1!, S]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo What is your Guess?
set /p guess1=
if %guess1% == Pants goto winner
if %guess1% == pants goto winner
if NOT %guess1% == pants goto Loser
:HiM
Title Word-Guessing-Game
Echo Word Selected.
Echo Your Word is 5 Letters long, and it has somthing to do with Clothing.
PING 1.1.1.1 -n 1 -w 4500 >NUL
Cls
Echo The First Letter Could be [!str:~%P1%,1!, G, !str:~%P3%,1!, !str:~%P4%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Second Letter Could be [!str:~%P5%,1!, !str:~%P6%,1!, L, !str:~%P8%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Thrid Letter Could be [A, !str:~%P12%,1!, !str:~%P11%,1!, !str:~%P12%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Fourth Letter Could be [[!str:~%P13%,1!, S, !str:~%P15%,1!, !str:~%P16%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Fifth Letter Could be [!str:~%P17%,1!, !str:~%P18%,1!, !str:~%P19%,1!, S]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Sixth Letter Could be [E, !str:~%P23%,1!, !str:~%P22%,1!, !str:~%P21%,1!]
PING 1.1.1.1 -n 1 -w 2500 >NUL
Echo The Seventh Letter Could be [!str:~%P22%,1!, !str:~%P23%,1!, !str:~%P24%,1!, S]
Echo What is your Guess?
set /p guess1=
if %guess1% == Pants goto winner
if %guess1% == pants goto winner
if NOT %guess1% == pants goto Loser
:bye
Echo Ok then, Bye
Pause
Exit
:winner
cls
Echo Congratz, You Won!
Echo Would you like to play again?
Echo (1) Yes
Echo (2) NO
set /p win=(1 or 2)
if %win%==1 goto starting1
if %win%==2 goto exit
:loser
cls
Echo :: ::
Echo :: ::
Echo :: ::
Echo :::: :: :: ::::
Echo :::: :: :: ::::
Echo.
Echo.
Echo.
Echo :: ::
Echo :: ::
Echo :: ::
Echo :: ::
Echo :: ::
Echo :: ::
Echo :: ::
Echo :: ::
Echo :: ::
Echo ::::::::::::::
Echo.
Echo Better luck next time...
Echo.
Pause
Exit
:exit
exit

I was wondering if you guys had anything in mind to make the selection process faster, i want it to be random also, and if you guys had a good idea for a better winner/loser screen i am all ears ^^
Thanks
~SpongeBob
4/22/2012-Added Title screen, and difficulty selector.
4/24/2012-Made all letters random, need to figure out how to always get the letters i need in it...
4/25/2012-Made it so you constantly can solve it, changed winning screen
(adsbygoogle = window.adsbygoogle || []).push({});
04-22-2012, 04:39 AM #2
not bad...
you should just google how to use random in batch files
you could make a variable of each letter but that would be much harder. unless you used arrays
idk but good luck hope you make something cool
04-22-2012, 05:33 PM #3
~SpongeBob
[move]Winning.[/move]
Originally posted by Darth
not bad...
you should just google how to use random in batch files
you could make a variable of each letter but that would be much harder. unless you used arrays
idk but good luck hope you make something cool

Would you have an idea on how to do that, because i have no idea...
04-22-2012, 07:11 PM #4
Originally posted by SpongeBob View Post
Would you have an idea on how to do that, because i have no idea...


you might be able to do
    
set wordslist[27] = a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z

then you can have a function to pull from the array
idk if that will work for batch but arrays are something like that.
like use the it would probably have something to add like
wordslist[%random%] and it would pull a random letter but that would be to random so you'd have to make it where it with a word list maybe
like
    
set wordslist[2] = ham, taco

then it would pull a word to stick in to the guessing game. idk just a little knowledge for ya.
04-23-2012, 01:24 AM #5
~SpongeBob
[move]Winning.[/move]
Originally posted by Darth
you might be able to do
    
set wordslist[27] = a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z

then you can have a function to pull from the array
idk if that will work for batch but arrays are something like that.
like use the it would probably have something to add like
wordslist[%random%] and it would pull a random letter but that would be to random so you'd have to make it where it with a word list maybe
like
    
set wordslist[2] = ham, taco

then it would pull a word to stick in to the guessing game. idk just a little knowledge for ya.

I tryed the word list, and it just showed wordlist[(randomnumber)].... im going to try a few things, and report back later

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo