Is this possible

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Is this possible

#16 Post by ShadowThief » 07 Sep 2016 17:25

thefeduke wrote:
explosivedolphin wrote:also is it possible to only allow the entrance of numbers from 1-100 when you a guess a number so you can only guess 1-100
For that, I refer you to http://www.dostips.com/forum/viewtopic.php?p=44274#p44274


Surely it would just be easier to say

Code: Select all

if %guess% GTR 100 goto top

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#17 Post by explosivedolphin » 08 Sep 2016 11:24

thats not what i mean I already made it so it only makes the guessable number 100 but I mean make it so when you type your guess you can only type 3 digits like 1-100 and only numbers but then if you can how would you make it able to put in the backdoor surf33

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#18 Post by explosivedolphin » 08 Sep 2016 11:28

thank you john but can you give me an example of how I would add that to this ? also I need to add the things in :: but need some help

Code: Select all

@echo off
::////////////////COLOR IS BROKEN IT DOESNT CHANGE COLOR FOR LOWER BUT IT DOES FOR HIGHER////////////////
::////////////////WANT TO ADD LIMIT OF 15 TRIES THAT RESETS WHEN YOU GET IT RIGHT////////////////
color 0F
cls
echo Type your name to save your highscore.
set /p "name= "
CLS
::////////////////Fixed bug where when you save the number of guesses in text file doesnt add all of them up////////////////
set /a guessnum=0
::
goto start1

:start2
echo ///Loading///
echo ///Loading///
echo ///Loading///

:start1
color 07
CLS
title Guessing Game Edited By AlternateAlt (and some other people)
set /a answer=%RANDOM%
if %answer% gtr 100 goto start2
::////////////////I want to add these////////////////
set /a extremely_close_low=%anwser%-2
set /a extremely_close_high=%anwser%+2
::////////////////I want to add these////////////////
set /a super_close_high=%answer%+3
set /a super_close_low=%answer%-3
:////////////////I want to add these////////////////
set /a pretty_close_low=%anwser%-15
set /a pretty_close_high=%anwser%+15
::////////////////I want to add these////////////////
set /a kinda_close_high=%answer%+20
set /a kinda_close_low=%answer%-20
set /a not_that_close_high=%answer%+35
set /a not_that_close_low=%answer%-35
set /a not_even_close_high=%answer%+40
set /a not_even_close_low=%answer%-40
set variable1=surf33
for /f %%a in ('show 30') do set "up=%%a"
for /f %%a in ('show 31') do set "down=%%a"
echo "---------------------------------"
colorshow /0B 32 " Welcome," /0F " %name%" /0B ", to the Guessing Game!" 13 10
colorshow 196*49 13 10
colorshow /0B 32 " Try and Guess my Number!: from  1 to 100 ." 13 10
echo "---------------------------------"
ColorBox /0f 0 0 48 4
:top
set /p "guess="
if %guess% lss %not_even_close_low% Set MFSS=07
if %guess% gtr %not_even_close_high% Set MFSS=07
if %guess% gtr %not_even_close_low% if %guess% lss %not_that_close_high% Set MFSS=04
if %guess% lss %not_even_close_high% if %guess% gtr %not_that_close_low% Set MFSS=04
if %guess% gtr %not_that_close_low% if %guess% lss %kinda_close_high% Set MFSS=0C
if %guess% lss %not_that_close_high% if %guess% gtr %kinda_close_low% Set MFSS=0C
if %guess% gtr %kinda_close_low% if %guess% lss %super_close_high% Set MFSS=0A
if %guess% lss %kinda_close_high% if %guess% gtr %super_close_low% Set MFSS=0A
if %guess% gtr %super_close_low% if %guess% lss %super_close_high% Set MFSS=02

if %guess% GTR %answer% Colorshow /%MDSS% " Lower!" 13 10 /0C "%down%" 32
if %guess% LSS %answer% colorshow /%MFSS% " Higher!" 13 10 /0B "%up%" 32
if "%guess%"=="%answer%" set /a right=%right%+1 && goto hello11
set /a guessnum=%guessnum% +1
if "%guess%"=="%variable1%" ECHO Found the backdoor hey? The answer is: %answer%
goto top


:hello11
CLS
color 0C
echo Congratulations, you guessed correctly!!!
echo It took you %guessnum% guesses.
echo You guessed the number correctly this many times: %right%
echo ------------------------------
echo Press 1 To Save Score         
echo ------------------------------
echo Press 2 To Keep Playing.     
echo ------------------------------
echo Press 3 To Check Highscores. 
echo ------------------------------
set /p save=
if %save%==1 goto save
if %save%==2 goto start1
if %save%==3 goto open else goto wrong
pause>nul
goto start1

:save
(
   echo ====================
   echo Player=%name%
   echo Date=%date%
   echo Times Many Guessed Correctly=%right%
   echo Number Of Guesses=%guessnum%
   echo ====================
) >>highscore.txt
goto start1

:wrong
echo Unknown Number. Press Any Key To Return.
pause>nul
goto hello11

:open
notepad highscore.txt
CLS
goto hello11

Aacini
Expert
Posts: 1888
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Is this possible

#19 Post by Aacini » 08 Sep 2016 11:49

explosivedolphin wrote:... I mean make it so when you type your guess you can only type 3 digits like 1-100 and only numbers...

Code: Select all

@echo off
setlocal EnableDelayedExpansion


call :get3digits
echo The number read is: %num%
goto :EOF


:get3digits
set /P "=Enter a number with 3 digits (use left zeros): " < NUL
set "num=0"
for /L %%i in (1,1,3) do (
   choice /C 0123456789 /N > NUL
   set /A "digit=!errorlevel!-1, num=num*10+digit"
   set /P "=!digit!" < NUL
)
echo/
exit /B

Antonio

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#20 Post by explosivedolphin » 08 Sep 2016 12:19

how would I put that in the game?

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#21 Post by explosivedolphin » 08 Sep 2016 12:36

Ok I think I added it in but the thing is you can still type a number higher than 100 like 199 but it does limit to 3 digits so that works but can we make it so you can either only under a number from 1-100 or make it so when you type a 1 digit number it automaticly adds the zeros like if you type 1 it will automaticly make it 001 is that possible ?? because I dont think people would know to put the zeros there and also the formating is off when you enter the first guess can someone help me fix that?

Code: Select all

@echo off
::WANT TO ADD LIMIT OF 15 TRIES THAT RESETS WHEN YOU GET IT RIGHT
color 0F
cls
echo Type your name to save your highscore.
set /p "name= "
CLS
::Fixed bug where when you save the number of guesses in text file doesnt add all of them up
set /a guessnum=0
::
goto start1

:start2
echo ///Loading///
echo ///Loading///
echo ///Loading///

:start1
color 07
CLS
title Guessing Game Edited By AlternateAlt (and some other people)
set /a answer=%RANDOM%
if %answer% gtr 100 goto start2
::I want to add these
set /a extremely_close_low=%anwser%-2
set /a extremely_close_high=%anwser%+2
::I want to add these
set /a super_close_high=%answer%+3
set /a super_close_low=%answer%-3
:I want to add these
set /a pretty_close_low=%anwser%-15
set /a pretty_close_high=%anwser%+15
::I want to add these
set /a kinda_close_high=%answer%+20
set /a kinda_close_low=%answer%-20
set /a not_that_close_high=%answer%+35
set /a not_that_close_low=%answer%-35
set /a not_even_close_high=%answer%+40
set /a not_even_close_low=%answer%-40
set variable1=surf33
for /f %%a in ('show 30') do set "up=%%a"
for /f %%a in ('show 31') do set "down=%%a"
echo "---------------------------------"
colorshow /0B 32 " Welcome," /0F " %name%" /0B ", to the Guessing Game!" 13 10
colorshow 196*49 13 10
colorshow /0B 32 " Try and Guess my Number!: from  1 to 100 ." 13 10
echo "---------------------------------"
ColorBox /0f 0 0 48 4
:top
setlocal EnableDelayedExpansion




:get3digits
set /P "guess=" < NUL
set "num=0"
for /L %%i in (1,1,3) do (
   choice /C 0123456789 /N > NUL
   set /A "digit=!errorlevel!-1, guess=num*10+digit"
   set /P "=!digit!" < NUL
)



if %guess% lss %not_even_close_low% Set MFSS=07
if %guess% gtr %not_even_close_high% Set MFSS=07
if %guess% gtr %not_even_close_low% if %guess% lss %not_that_close_high% Set MFSS=04
if %guess% lss %not_even_close_high% if %guess% gtr %not_that_close_low% Set MFSS=04
if %guess% gtr %not_that_close_low% if %guess% lss %kinda_close_high% Set MFSS=0C
if %guess% lss %not_that_close_high% if %guess% gtr %kinda_close_low% Set MFSS=0C
if %guess% gtr %kinda_close_low% if %guess% lss %super_close_high% Set MFSS=0A
if %guess% lss %kinda_close_high% if %guess% gtr %super_close_low% Set MFSS=0A
if %guess% gtr %super_close_low% if %guess% lss %super_close_high% Set MFSS=02

if %guess% GTR %answer% Colorshow /%MDSS% " Lower!" 13 10 /0C "%down%" 32
if %guess% LSS %answer% colorshow /%MFSS% " Higher!" 13 10 /0B "%up%" 32
if "%guess%"=="%answer%" set /a right=%right%+1 && goto hello11
set /a guessnum=%guessnum% +1
if "%guess%"=="%variable1%" ECHO Found the backdoor hey? The answer is: %answer%
goto top


:hello11
CLS
color 0C
echo Congratulations, you guessed correctly!!!
echo It took you %guessnum% guesses.
echo You guessed the number correctly this many times: %right%
echo ------------------------------
echo Press 1 To Save Score         
echo ------------------------------
echo Press 2 To Keep Playing.     
echo ------------------------------
echo Press 3 To Check Highscores. 
echo ------------------------------
set /p save=
if %save%==1 goto save
if %save%==2 goto start1
if %save%==3 goto open else goto wrong
pause>nul
goto start1

:save
(
   echo ====================
   echo Player=%name%
   echo Date=%date%
   echo Times Many Guessed Correctly=%right%
   echo Number Of Guesses=%guessnum%
   echo ====================
) >>highscore.txt
goto start1

:wrong
echo Unknown Number. Press Any Key To Return.
pause>nul
goto hello11

:open
notepad highscore.txt
CLS
goto hello11

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#22 Post by explosivedolphin » 08 Sep 2016 13:33

actually that was a smart Idea

Code: Select all

@echo off
::WANT TO ADD LIMIT OF 15 TRIES THAT RESETS WHEN YOU GET IT RIGHT
color 0F
cls
echo Type your name to save your highscore.
set /p "name= "
CLS
::Fixed bug where when you save the number of guesses in text file doesnt add all of them up
set /a guessnum=0
::
goto start1

:start2
echo ///Loading///
echo ///Loading///
echo ///Loading///

:start1
color 07
CLS
title Guessing Game Edited By AlternateAlt (and some other people)
set /a answer=%RANDOM%
if %answer% gtr 100 goto start2
::I want to add these
set /a extremely_close_low=%anwser%-2
set /a extremely_close_high=%anwser%+2
::I want to add these
set /a super_close_high=%answer%+3
set /a super_close_low=%answer%-3
:I want to add these
set /a pretty_close_low=%anwser%-15
set /a pretty_close_high=%anwser%+15
::I want to add these
set /a kinda_close_high=%answer%+20
set /a kinda_close_low=%answer%-20
set /a not_that_close_high=%answer%+35
set /a not_that_close_low=%answer%-35
set /a not_even_close_high=%answer%+40
set /a not_even_close_low=%answer%-40
set variable1=surf33
:top2
for /f %%a in ('show 30') do set "up=%%a"
for /f %%a in ('show 31') do set "down=%%a"
echo "---------------------------------"
colorshow /0B 32 " Welcome," /0F " %name%" /0B ", to the Guessing Game!" 13 10
colorshow 196*49 13 10
colorshow /0B 32 " Try and Guess my Number!: from  1 to 100 ." 13 10
echo "---------------------------------"
ColorBox /0f 0 0 48 4
:top
set /p "guess="
if %guess% GTR 100 goto error1
if %guess% lss %not_even_close_low% Set MFSS=07
if %guess% gtr %not_even_close_high% Set MFSS=07
if %guess% gtr %not_even_close_low% if %guess% lss %not_that_close_high% Set MFSS=04
if %guess% lss %not_even_close_high% if %guess% gtr %not_that_close_low% Set MFSS=04
if %guess% gtr %not_that_close_low% if %guess% lss %kinda_close_high% Set MFSS=0C
if %guess% lss %not_that_close_high% if %guess% gtr %kinda_close_low% Set MFSS=0C
if %guess% gtr %kinda_close_low% if %guess% lss %super_close_high% Set MFSS=0A
if %guess% lss %kinda_close_high% if %guess% gtr %super_close_low% Set MFSS=0A
if %guess% gtr %super_close_low% if %guess% lss %super_close_high% Set MFSS=02

if %guess% GTR %answer% Colorshow /%MDSS% " Lower!" 13 10 /0C "%down%" 32
if %guess% LSS %answer% colorshow /%MFSS% " Higher!" 13 10 /0B "%up%" 32
if "%guess%"=="%answer%" set /a right=%right%+1 && goto hello11
set /a guessnum=%guessnum% +1
if "%guess%"=="%variable1%" ECHO Found the backdoor hey? The answer is: %answer%
goto top


:hello11
CLS
color 0C
echo Congratulations, you guessed correctly!!!
echo It took you %guessnum% guesses.
echo You guessed the number correctly this many times: %right%
echo ------------------------------
echo Press 1 To Save Score         
echo ------------------------------
echo Press 2 To Keep Playing.     
echo ------------------------------
echo Press 3 To Check Highscores. 
echo ------------------------------
set /p save=
if %save%==1 goto save
if %save%==2 goto start1
if %save%==3 goto open else goto wrong
pause>nul
goto start1

:save
(
   echo ====================
   echo Player=%name%
   echo Date=%date%
   echo Times Many Guessed Correctly=%right%
   echo Number Of Guesses=%guessnum%
   echo ====================
) >>highscore.txt
goto start1

:wrong
echo Unknown Number. Press Any Key To Return.
pause>nul
goto hello11

:open
notepad highscore.txt
CLS
goto hello11
:error1
echo Please Pick A Number Between 1 and 100.
goto top

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#23 Post by explosivedolphin » 08 Sep 2016 13:40

ok so now I want to add a limit of 15 tries that resets when you get it right or decreases from 100 the first time and on the fifth time you get it right down to 15 or something just a limit on trys that resets when you get it right or maybe every time you get it right it adds five to the trys idk tell me if any of those are possible I used the idea

Code: Select all

if %guess% grt 100 goto error1
and that was a really good idea thanks to who said that heres the updated code so far and if we could clean up the code that makes it change colors as you get closer or farther from the number that would be great because its not 100% functional

Code: Select all

@echo off
::WANT TO ADD LIMIT OF 15 TRIES THAT RESETS WHEN YOU GET IT RIGHT
color 0F
cls
echo Type your name to save your highscore.
set /p "name= "
CLS
::Fixed bug where when you save the number of guesses in text file doesnt add all of them up
set /a guessnum=0
::
goto start1

:start2
echo ///Loading///
echo ///Loading///
echo ///Loading///

:start1
color 07
CLS
title Guessing Game Edited By AlternateAlt (and some other people)
set /a answer=%RANDOM%
if %answer% gtr 100 goto start2
::I want to add these
set /a extremely_close_low=%anwser%-2
set /a extremely_close_high=%anwser%+2
::I want to add these
set /a super_close_high=%answer%+3
set /a super_close_low=%answer%-3
:I want to add these
set /a pretty_close_low=%anwser%-15
set /a pretty_close_high=%anwser%+15
::I want to add these
set /a kinda_close_high=%answer%+20
set /a kinda_close_low=%answer%-20
set /a not_that_close_high=%answer%+35
set /a not_that_close_low=%answer%-35
set /a not_even_close_high=%answer%+40
set /a not_even_close_low=%answer%-40
set variable1=surf33
:top2
for /f %%a in ('show 30') do set "up=%%a"
for /f %%a in ('show 31') do set "down=%%a"
echo "---------------------------------"
colorshow /0B 32 " Welcome," /0F " %name%" /0B ", to the Guessing Game!" 13 10
colorshow 196*49 13 10
colorshow /0B 32 " Try and Guess my Number!: from  1 to 100 ." 13 10
echo "---------------------------------"
ColorBox /0f 0 0 48 4
:top
set /p "guess="
if "%guess%"=="%variable1%" goto people && ECHO Found the backdoor hey? The answer is: %answer%
if %guess% GTR 100 goto error1
if %guess% lss %not_even_close_low% Set MFSS=07
if %guess% gtr %not_even_close_high% Set MFSS=07
if %guess% gtr %not_even_close_low% if %guess% lss %not_that_close_high% Set MFSS=04
if %guess% lss %not_even_close_high% if %guess% gtr %not_that_close_low% Set MFSS=04
if %guess% gtr %not_that_close_low% if %guess% lss %kinda_close_high% Set MFSS=0C
if %guess% lss %not_that_close_high% if %guess% gtr %kinda_close_low% Set MFSS=0C
if %guess% gtr %kinda_close_low% if %guess% lss %super_close_high% Set MFSS=0A
if %guess% lss %kinda_close_high% if %guess% gtr %super_close_low% Set MFSS=0A
if %guess% gtr %super_close_low% if %guess% lss %super_close_high% Set MFSS=02

if %guess% GTR %answer% Colorshow /%MDSS% " Lower!" 13 10 /0C "%down%" 32
if %guess% LSS %answer% colorshow /%MFSS% " Higher!" 13 10 /0B "%up%" 32
if "%guess%"=="%answer%" set /a right=%right%+1 && goto hello11
set /a guessnum=%guessnum% +1
:people
if "%guess%"=="%variable1%" ECHO Found the backdoor hey? The answer is: %answer%

goto top


:hello11
CLS
echo Congratulations, you guessed correctly!!!
echo It took you %guessnum% guesses.
echo You guessed the number correctly this many times: %right%
echo ------------------------------
echo Press 1 To Save Score         
echo ------------------------------
echo Press 2 To Keep Playing.     
echo ------------------------------
echo Press 3 To Check Highscores. 
echo ------------------------------
set /p save=
if %save%==1 goto save
if %save%==2 goto start1
if %save%==3 goto open else goto wrong
pause>nul
goto start1

:save
(
   echo ====================
   echo Player=%name%
   echo Date=%date%
   echo Times Many Guessed Correctly=%right%
   echo Number Of Guesses=%guessnum%
   echo ====================
) >>highscore.txt
goto start1

:wrong
echo Unknown Number. Press Any Key To Return.
pause>nul
goto hello11

:open
notepad highscore.txt
CLS
goto hello11
:error1
echo Please Pick A Number Between 1 and 100.
goto top

thefeduke
Posts: 211
Joined: 05 Apr 2015 13:06
Location: MA South Shore, USA

Re: Is this possible

#24 Post by thefeduke » 08 Sep 2016 14:07

Stepping back in time:
explosivedolphin wrote:Hay I Made a small change making it so the highest number is 100
Had you introduced this change to your ramdomizer at that time

Code: Select all

Set /A "answer=(%random%*100)/32768+1"
You would have saved considerable effort doing your "///LOADING///" loop. It does seem to be in the spirit of dressing up your game, but can be tedious to watch, since the chances of qualifying are slightly less than a thousand to one. I worked up something yesterday, but I think that the changes could still apply to that part of the code in your later versions. It adds a bit of color for showmanship to the ///LOADING/// loop, but bails out to the above randomizer on a threshold to prevent boredom. So, you can leave it the same, perk it up with the change or strip out the loading part completely.

Code: Select all

set /a guessnum=0
::
::  =========================================
title Guessing Game Edited By AlternateAlt (and some other people)
Set "LoadCtr=0"
Set "LoadColor=7"
Set "LoadColors=0123456789ABCDEF"
goto start1

:start2
echo ///Loading///
echo ///Loading///
echo ///Loading///

:start1
SetLocal EnableDelayedExpansion
set /A "RandomColor=%random%*16/32768"
Set "LoadColor=!LoadColors:~%RandomColor%,1!"
color 0%LoadColor%
EndLocal
ping -n 2 -w 500 127.0.0.1>NUL
Set /A "LoadCtr+=1"
CLS
set /a answer=%RANDOM%
if %answer% gtr 100 (
    if "%LoadCtr%" EQU "33" (set /A "answer=(%random%*100)/32768+1" & goto :start3)
    goto start2
)
:start3
color 07
::I want to add these
::  =========================================
::
set /a extremely_close_low=%anwser%-2
Just replace everything between the top and bottom lines.

John A.

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#25 Post by explosivedolphin » 08 Sep 2016 17:55

I like it but can it be take a shorter time because if you hit play again its gonna get repetitive to watch that for like 15 seconds and also I wanted to add these things
ok so now I want to add a limit of 15 tries that resets when you get it right or decreases from 100 the first time and on the fifth time you get it right down to 15 or something just a limit on trys that resets when you get it right or maybe every time you get it right it adds five to the trys idk tell me if any of those are possible I used the idea

so far here's the code

Code: Select all

@echo off
::WANT TO ADD LIMIT OF 15 TRIES THAT RESETS WHEN YOU GET IT RIGHT
color 0F
cls
echo Type your name to save your highscore.
set /p "name= "
CLS
::Fixed bug where when you save the number of guesses in text file doesnt add all of them up
set /a guessnum=0
::
::  =========================================
title Guessing Game Edited By AlternateAlt (and some other people)
Set "LoadCtr=0"
Set "LoadColor=7"
Set "LoadColors=0123456789ABCDEF"
goto start1

:start2
echo ///Loading///
echo ///Loading///
echo ///Loading///

:start1
SetLocal EnableDelayedExpansion
set /A "RandomColor=%random%*16/32768"
Set "LoadColor=!LoadColors:~%RandomColor%,1!"
color 0%LoadColor%
EndLocal
ping -n 2 -w 500 127.0.0.1>NUL
Set /A "LoadCtr+=1"
CLS
set /a answer=%RANDOM%
if %answer% gtr 100 (
    if "%LoadCtr%" EQU "33" (set /A "answer=(%random%*100)/32768+1" & goto :start3)
    goto start2
)
:start3
color 07
::I want to add these
::  =========================================
::
set /a extremely_close_low=%anwser%-2
set /a extremely_close_high=%anwser%+2
::I want to add these
set /a super_close_high=%answer%+3
set /a super_close_low=%answer%-3
:I want to add these
set /a pretty_close_low=%anwser%-15
set /a pretty_close_high=%anwser%+15
::I want to add these
set /a kinda_close_high=%answer%+20
set /a kinda_close_low=%answer%-20
set /a not_that_close_high=%answer%+35
set /a not_that_close_low=%answer%-35
set /a not_even_close_high=%answer%+40
set /a not_even_close_low=%answer%-40
set variable1=surf33
:top2
for /f %%a in ('show 30') do set "up=%%a"
for /f %%a in ('show 31') do set "down=%%a"
echo "---------------------------------"
colorshow /0B 32 " Welcome," /0F " %name%" /0B ", to the Guessing Game!" 13 10
colorshow 196*49 13 10
colorshow /0B 32 " Try and Guess my Number!: from  1 to 100 ." 13 10
echo "---------------------------------"
ColorBox /0f 0 0 48 4
:top
set /p "guess="
if %guess% GTR 100 goto error1
if %guess% lss %not_even_close_low% Set MFSS=07
if %guess% gtr %not_even_close_high% Set MFSS=07
if %guess% gtr %not_even_close_low% if %guess% lss %not_that_close_high% Set MFSS=04
if %guess% lss %not_even_close_high% if %guess% gtr %not_that_close_low% Set MFSS=04
if %guess% gtr %not_that_close_low% if %guess% lss %kinda_close_high% Set MFSS=0C
if %guess% lss %not_that_close_high% if %guess% gtr %kinda_close_low% Set MFSS=0C
if %guess% gtr %kinda_close_low% if %guess% lss %super_close_high% Set MFSS=0A
if %guess% lss %kinda_close_high% if %guess% gtr %super_close_low% Set MFSS=0A
if %guess% gtr %super_close_low% if %guess% lss %super_close_high% Set MFSS=02

if %guess% GTR %answer% Colorshow /%MDSS% " Lower!" 13 10 /0C "%down%" 32
if %guess% LSS %answer% colorshow /%MFSS% " Higher!" 13 10 /0B "%up%" 32
if "%guess%"=="%answer%" set /a right=%right%+1 && goto hello11
set /a guessnum=%guessnum% +1
if "%guess%"=="%variable1%" ECHO Found the backdoor hey? The answer is: %answer%
goto top


:hello11
CLS
color 0C
echo Congratulations, you guessed correctly!!!
echo It took you %guessnum% guesses.
echo You guessed the number correctly this many times: %right%
echo ------------------------------
echo Press 1 To Save Score         
echo ------------------------------
echo Press 2 To Keep Playing.     
echo ------------------------------
echo Press 3 To Check Highscores. 
echo ------------------------------
set /p save=
if %save%==1 goto save
if %save%==2 goto start1
if %save%==3 goto open else goto wrong
pause>nul
goto start1

:save
(
   echo ====================
   echo Player=%name%
   echo Date=%date%
   echo Times Many Guessed Correctly=%right%
   echo Number Of Guesses=%guessnum%
   echo ====================
) >>highscore.txt
goto start1

:wrong
echo Unknown Number. Press Any Key To Return.
pause>nul
goto hello11

:open
notepad highscore.txt
CLS
goto hello11
:error1
echo Please Pick A Number Between 1 and 100.
goto top2

thanks

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#26 Post by explosivedolphin » 08 Sep 2016 18:05

thanks john I really like that little bit of spice that loading screen add too it

EDIT
you should be able to choose difficulty's easy 20 try resets when you get it right medium 10 trys resets when you get it right and hard you only get 10 but when you get it right it doesn't reset it just gives you plus 5 trys
EDIT

figured out how to speed it up

Code: Select all

ping  -w 10 -n 2 -1 1 127.0.0.1>NUL
changed the ping command alittle now all we need to add is
ok so now I want to add a limit of 15 tries that resets when you get it right or decreases from 100 the first time and on the fifth time you get it right down to 15 or something just a limit on trys that resets when you get it right or maybe every time you get it right it adds five to the trys idk tell me if any of those are possible I used the idea

code so far
====================================================

Code: Select all

@echo off
::WANT TO ADD LIMIT OF 15 TRIES THAT RESETS WHEN YOU GET IT RIGHT
color 0F
cls
echo Type your name to save your highscore.
set /p "name= "
CLS
::Fixed bug where when you save the number of guesses in text file doesnt

add all of them up
set /a guessnum=0
::
::  =========================================
title Guessing Game Edited By AlternateAlt (and some other people)
Set "LoadCtr=0"
Set "LoadColor=7"
Set "LoadColors=0123456789ABCDEF"
goto start1

:start2
echo ///Loading///
echo ///Loading///
echo ///Loading///

:start1
SetLocal EnableDelayedExpansion
set /A "RandomColor=%random%*16/32768"
Set "LoadColor=!LoadColors:~%RandomColor%,1!"
color 0%LoadColor%
EndLocal
ping  -w 10 -n 2 -1 3 127.0.0.1>NUL
Set /A "LoadCtr+=1"
CLS
set /a answer=%RANDOM%
if %answer% gtr 100 (
    if "%LoadCtr%" EQU "33" (set /A "answer=(%random%*100)/32768+1" & goto

:start3)
    goto start2
)
:start3
color 07
::I want to add these
::  =========================================
::
set /a extremely_close_low=%anwser%-2
set /a extremely_close_high=%anwser%+2
::I want to add these
set /a super_close_high=%answer%+3
set /a super_close_low=%answer%-3
:I want to add these
set /a pretty_close_low=%anwser%-15
set /a pretty_close_high=%anwser%+15
::I want to add these
set /a kinda_close_high=%answer%+20
set /a kinda_close_low=%answer%-20
set /a not_that_close_high=%answer%+35
set /a not_that_close_low=%answer%-35
set /a not_even_close_high=%answer%+40
set /a not_even_close_low=%answer%-40
set variable1=surf33
for /f %%a in ('show 30') do set "up=%%a"
for /f %%a in ('show 31') do set "down=%%a"
echo "---------------------------------"
colorshow /0B 32 " Welcome," /0F " %name%" /0B ", to the Guessing Game!"

13 10
colorshow 196*49 13 10
colorshow /0B 32 " Try and Guess my Number!: from  1 to 100 ." 13 10
echo "---------------------------------"
ColorBox /0f 0 0 48 4
:top
:top2
set /p "guess="
if "%guess%"=="%variable1%"  ECHO Found the backdoor hey? The answer is:

%answer% && goto top
if %guess% GTR 100 goto error1
if %guess% lss %not_even_close_low% Set MFSS=07
if %guess% gtr %not_even_close_high% Set MFSS=07
if %guess% gtr %not_even_close_low% if %guess% lss %not_that_close_high%

Set MFSS=04
if %guess% lss %not_even_close_high% if %guess% gtr %not_that_close_low%

Set MFSS=04
if %guess% gtr %not_that_close_low% if %guess% lss %kinda_close_high% Set

MFSS=0C
if %guess% lss %not_that_close_high% if %guess% gtr %kinda_close_low% Set

MFSS=0C
if %guess% gtr %kinda_close_low% if %guess% lss %super_close_high% Set

MFSS=0A
if %guess% lss %kinda_close_high% if %guess% gtr %super_close_low% Set

MFSS=0A
if %guess% gtr %super_close_low% if %guess% lss %super_close_high% Set

MFSS=02

if %guess% GTR %answer% Colorshow /%MDSS% " Lower!" 13 10 /0C "%down%" 32
if %guess% LSS %answer% colorshow /%MFSS% " Higher!" 13 10 /0B "%up%" 32
if "%guess%"=="%answer%" set /a right=%right%+1 && goto hello11
set /a guessnum=%guessnum% +1

goto top


:hello11
CLS
color 0F
echo Congratulations, you guessed correctly!!!
echo It took you %guessnum% guesses.
echo You guessed the number correctly this many times: %right%
echo ------------------------------
echo Press 1 To Save Score         
echo ------------------------------
echo Press 2 To Keep Playing.     
echo ------------------------------
echo Press 3 To Check Highscores. 
echo ------------------------------
echo Press 4 To Exit.
echo ------------------------------
set /p save=
if %save%==1 goto save else goto wrong
if %save%==2 goto start1 else goto wrong
if %save%==3 goto open else goto wrong
if %save%==4 exit else goto wrong
pause>nul
goto start1

:save
(
   echo ====================
   echo Player=%name%
   echo Date=%date%
   echo Times Many Guessed Correctly=%right%
   echo Number Of Guesses=%guessnum%
   echo ====================
) >>highscore.txt
goto hello11

:wrong
echo Unknown Number. Press Any Key To Return.
pause>nul
goto hello11

:open
notepad highscore.txt
CLS
goto hello11
:error1
echo Please Pick A Number Between 1 and 100.
goto top2

thefeduke
Posts: 211
Joined: 05 Apr 2015 13:06
Location: MA South Shore, USA

Re: Is this possible

#27 Post by thefeduke » 09 Sep 2016 01:59

explosivedolphin wrote:and if we could clean up the code that makes it change colors as you get closer or farther from the number that would be great because its not 100% functional
I found a typo in what I gave you.

Code: Select all

if %guess% GTR %answer% Colorshow /%MDSS% " Lower!" 13 10 /0C "%down%" 32
should have read as

Code: Select all

if %guess% GTR %answer% Colorshow /%MFSS% " Lower!" 13 10 /0C "%down%" 32

I introduced some enhancements to the code in your last post. There were quite a few lines broken in your formatting, but after I fixed those, I found too many logic errors in your changes to test properly.
explosivedolphin wrote: but then if you can how would you make it able to put in the backdoor surf33
While I regroup, here is an improvement for the backdoor

Code: Select all

if "%guess%"=="%variable1%" (ECHO Found the backdoor hey? The answer is: %answer% & Set "guess=%answer%") 
If you move that line to just before you check for valid numbers, everything will check out as if the correct number was entered in the normal flow.

Edit: The last line in your script should goto top , not top2, so as not to redo the starting box.

I shall apply my code changes to your second last code block. and post them.

John A.

explosivedolphin
Posts: 24
Joined: 06 Sep 2016 13:39

Re: Is this possible

#28 Post by explosivedolphin » 09 Sep 2016 07:40

EDIT
you should be able to choose difficulty's easy 20 try resets when you get it right medium 10 trys resets when you get it right and hard you only get 10 but when you get it right it doesn't reset it just gives you plus 5 trys
EDIT

I want this to be added

thefeduke
Posts: 211
Joined: 05 Apr 2015 13:06
Location: MA South Shore, USA

Re: Is this possible

#29 Post by thefeduke » 09 Sep 2016 18:51

thefeduke wrote:I shall apply my code changes to your second last code block. and post them.
Have a good weekend. I tried to give you a solid visual framework within which you can add your wish list. I think that I got the fixes in and I moved things around to improve when things get initialized and reset. I mangled your label names so I could follow it. I reworked your 1,2,3,(4 to exit) menu so it no longer jumps to a new game if that is not what was chosen. Most dramatically, the title bar now communicates status and hints. Adding the difficulty level should be easier now.

I got a little carried away because it was so much fun, so I hope that you like this:

Code: Select all

@echo off
::  rebuilding changes from second last post
::WANT TO ADD LIMIT OF 15 TRIES THAT RESETS WHEN YOU GET IT RIGHT
color 0F
cls
echo Type your name to save your highscore.
set /p "name= "
CLS
Set "title1=Guessing Game Edited By AlternateAlt (and some other people)"
title %title1%
Set "LoadColor=7"
Set "LoadLimit=27"
Set "LoadColors=0123456789ABCDEF"
set "variable1=surf33"
for /f %%a in ('show 30') do set "up=%%a"
for /f %%a in ('show 31') do set "down=%%a"
:StartNewGame
Set "LoadCtr=0"
set "guessnum=0"

:PickAnswer
echo ///Loading///
echo ///Loading///
echo.
echo ///Loading///
echo ///Loading///

SetLocal EnableDelayedExpansion
set /A "RandomColor=%random%*16/32768"
Set "LoadColor=!LoadColors:~%RandomColor%,1!"
color 0%LoadColor%
EndLocal
ping  -w 10 -n 2 -1 3 127.0.0.1>NUL
Set /A "LoadCtr+=1"
CLS
set /a answer=%RANDOM%
if %answer% gtr 100 (
    if "%LoadCtr%" EQU "%LoadLimit%" (set /A "answer=(%random%*100)/32768+1" & goto :ChoseAnswer)
    goto PickAnswer
)
:ChoseAnswer
::  Reduce countdown with experience and add progress status to title
Set /A "LoadLimit=1+LoadLimit/3"
color 07
::I want to add these
set /a extremely_close_low=%anwser%-2
set /a extremely_close_high=%anwser%+2
::I want to add these
set /a super_close_high=%answer%+3
set /a super_close_low=%answer%-3
::I want to add these
set /a pretty_close_low=%anwser%-15
set /a pretty_close_high=%anwser%+15
::I want to add these
set /a kinda_close_high=%answer%+20
set /a kinda_close_low=%answer%-20
set /a not_that_close_high=%answer%+35
set /a not_that_close_low=%answer%-35
set /a not_even_close_high=%answer%+40
set /a not_even_close_low=%answer%-40
:top_Welcome
Set "title2=----+----1----+----2----+----3----+----4----+----5"
Set "title2=%title2%----+----6----+----7----+----8----+----9----+----"
title %title1% %title3%
echo "---------------------------------"
colorshow /0B 32 " Welcome," /0F " %name%" /0B ", to the Guessing Game!" 13 10
colorshow 196*49 13 10
colorshow /0B 32 " Try and Guess my Number!: from  1 to 100 ." 13 10
echo "---------------------------------"
ColorBox /0f 0 0 48 4
colorshow /0F 16 32
:top_Guess
set /p "guess="
if "%guess%"=="%variable1%" (ECHO Found the backdoor hey? The answer is: %answer% & Set "guess=%answer%")
if %guess% GTR 100 goto error1
if %guess% lss %not_even_close_low% Set ColorHint=07
if %guess% gtr %not_even_close_high% Set ColorHint=07
if %guess% gtr %not_even_close_low% if %guess% lss %not_that_close_high% Set ColorHint=04
if %guess% lss %not_even_close_high% if %guess% gtr %not_that_close_low% Set ColorHint=04
if %guess% gtr %not_that_close_low% if %guess% lss %kinda_close_high% Set ColorHint=0C
if %guess% lss %not_that_close_high% if %guess% gtr %kinda_close_low% Set ColorHint=0C
if %guess% gtr %kinda_close_low% if %guess% lss %super_close_high% Set ColorHint=0A
if %guess% lss %kinda_close_high% if %guess% gtr %super_close_low% Set ColorHint=0A
if %guess% gtr %super_close_low% if %guess% lss %super_close_high% Set ColorHint=02
SetLocal EnableDelayedExpansion
    Set /A "ProgPos=%guess%-1
    Set "Progress1=!Title2:~0,%ProgPos%!"
    Set "Progress2=!Title2:~%guess%!"
if %guess% GTR %answer% (
    Set "Hint=Lower"
    Colorshow /%ColorHint% "!Hint!" 13 10 /0C "%down%" 32
    Set "Title2=%progress1%L%Progress2%"
)
if %guess% LSS %answer% (
    Set "Hint=Higher"
    Colorshow /%ColorHint% "!Hint!" 13 10 /0B "%up%" 32
    Set "Title2=%progress1%H%Progress2%"
)
title Guessing HINTS___+0%title2%100+___%Hint%
if "%guess%"=="%answer%" (
    set /a guessnum=%guessnum% +1
    set /a right=%right%+1
    colorshow /0C 32 03 32 /0E"SUCCESS!" 13 10
    Set "Hint=Exact"
    Set "title3=[Guesses - !Guessnum!] - [Times Right - !right!]
    Set "Title2=%progress1%#%Progress2%"
    title Guessing HINTS___+0!title2!100+___!Hint!
    goto :hello11
)
(EndLocal & rem.Save values for reruns
    Set "right=%right%"
    Set "Title2=%Title2%"
    Set "Title3=%Title3%"
)
set /a guessnum=%guessnum% +1
goto :top_Guess


:hello11
CLS
color 0C
echo Congratulations, you guessed correctly!!!
echo It took you %guessnum% guesses to find %guess%.
echo You guessed the number correctly this many times: %right%
echo ------------------------------
echo Press 1 To Save Score
echo ------------------------------
echo Press 2 To Keep Playing.
echo ------------------------------
echo Press 3 To Check Highscores.
echo ------------------------------
echo Press 4 To Exit.
echo ------------------------------
CHOICE /C 1234 /N /M [1,2,3,4]?
Set "save=%ErrorLevel%"
if %save%==1 (call :save "%name%" %right% %Guessnum% & Goto :hello11)
if %save%==2 goto :StartNewGame
if %save%==3 (call :open & Goto :hello11)
if %save%==4 (title %title1% & Exit /B)

:save
(
   echo ====================
   echo Player=%~1
   echo Date=%date%
   echo Times Many Guessed Correctly=%2
   echo Number Of Guesses=%3
   echo ====================
) >>highscore.txt
Exit /B

:open
Start "" highscore.txt
rem.notepad highscore.txt
Exit /B

:error1
echo Please Pick A Number Between 1 and 100.
goto :top_Guess
Please feed back bugs.

Edit: This bug fed itself and altered the above code to:

Code: Select all

::  Reduce countdown with experience and add progress status to title
Set /A "LoadLimit=1+LoadLimit/3"


John A.

thefeduke
Posts: 211
Joined: 05 Apr 2015 13:06
Location: MA South Shore, USA

Re: Is this possible

#30 Post by thefeduke » 10 Sep 2016 07:24

Edited previous post:

Code: Select all

Set /A "LoadLimit=1+LoadLimit/3"

John A.

Post Reply