Follow us on Twitter!
I'd prefer to die standing, than to live on my knees - Che Guevara
Monday, April 21, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 28
Guests Online: 25
Members Online: 3

Registered Members: 82857
Newest Member: varshith_kh
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Need batch help..again


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 28-10-06 01:40
Ok, well i found someone elses C++ code for playing Rock Paper Scissors, and wanted to make my own for batch.
1. How do i configure it so that the computer picks a random option?
2. What is wrong with the code so far? I can go through it fine until i come across the :rock portion, becuse no matter what i pick, it always goes to rock..any help?

Code
@echo off
title Rock, Paper, Scissors!
echo Welcome to Rock, Paper, Scissors.
echo If you do not know how to play, read the instructions. I suggest you do to learn what keys are for what option.
pause
set /p info=Would you like to read the instructions? (y or n)
if %info% equ y goto info
if %info% equ n goto game

:game
cls
echo Ok, when you are ready to start the game, press either 0, 1, or 2.
set /p 012=What will you choose?
if %012% equ 0 goto rock
if %012% equ 1 goto scissors
if %012% equ 2 goto paper

:rock
cls
echo You picked rock, press any key to see what the computer will choose.
pause
goto game

:scissors
cls
echo You picked scissors, press any key to see what the other play will choose.
pause
goto game

:paper
cls
echo You picked paper, press any key to see what the computer will choose.
pause
goto game

:info
cls
echo To play this game, you type 0 for rock, 1 for paper, and 2 for scissors.
pause
echo Rock will beat scissors, scissors will be paper, and paper will beat rock.
pause
echo To continue to the game, press any key.
pause
goto game




Thank you


Author

RE: Need batch help..again


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 28-10-06 03:22
Well, I know what the problem is, but I don't exactly know why it is a problem, lol.
I don't really know the features of the set command too well, but apparently the problem is the %012% part. I changed:

Code
set /p 012=What will you choose?
if %012% equ 0 goto rock
if %012% equ 1 goto scissors
if %012% equ 2 goto paper




to:

Code
set /p num=What will you choose?
if %num% equ 0 goto rock
if %num% equ 1 goto scissors
if %num% equ 2 goto paper




And selecting each number worked. Although, I don't see how the computer picks a number on the second time round, since all it does is go back to asking you what you want to pick :whoa:

But, I'm pretty sure it was the numbers giving you the trouble :)




Edited by on 28-10-06 03:23
Author

RE: Need batch help..again


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 28-10-06 04:01
Oh ok thank you, and i didnt get too far yet, so i didnt add teh computer choice thing..i just layed it all out.


Author

RE: Need batch help..again

Uber0n
Member



Posts: 1963
Location: Sweden‭‮
Joined: 13.06.06
Rank:
Hacker Level 3
Posted on 28-10-06 10:30
I don't even think it's possible making random numbers in batch..?

I think you should learn some C++ and you'll find your problems a lot easier to solve Wink


img230.imageshack.us/img230/724/uber0nsig3hj6.gif
http://uber0n.web. . .
Nope http://uber0n.webs.com/
Author

RE: Need batch help..again


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 28-10-06 15:56
aww that sucks...but C++ is waay too complicated atm, so ill stick to learning perl


Author

RE: Need batch help..again

bl4ckc4t
Member

Your avatar

Posts: 591
Location: /etc/
Joined: 07.03.06
Rank:
Wiseman
Posted on 28-10-06 18:25
Ponguile wrote:
aww that sucks...but C++ is waay too complicated atm, so ill stick to learning perl



Perl is your best bet for decent programming without complications.
(or Python)


BC


Author

RE: Need batch help..again


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 28-10-06 18:41
Should i learn perl or python first? Becuase before i even stumbled upon this website, i tried to learn python..but i only used it for math problems..


Author

RE: Need batch help..again

bl4ckc4t
Member

Your avatar

Posts: 591
Location: /etc/
Joined: 07.03.06
Rank:
Wiseman
Posted on 28-10-06 19:02
I learned Perl first and Perl is quite easy. It will help you to learn other languages. like C and PHP.

Bl4ckC4t


Author

RE: Need batch help..again


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 28-10-06 19:27
Well it may be quite easy, but i have nothing to do with it..and I know a little php, but only the include function, for websites


Author

RE: Need batch help..again

Uber0n
Member



Posts: 1963
Location: Sweden‭‮
Joined: 13.06.06
Rank:
Hacker Level 3
Posted on 29-10-06 09:24
You have to be a beginner in the beginning Wink

You'll learn fast if you try.


img230.imageshack.us/img230/724/uber0nsig3hj6.gif
http://uber0n.web. . .
Nope http://uber0n.webs.com/
Author

RE: Need batch help..again


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 29-10-06 19:58
Ok thanks for the encouragement!


Author

RE: randoms


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 04-11-06 02:42
Uber0n wrote:
I don't even think it's possible making random numbers in batch..?

I think you should learn some C++ and you'll find your problems a lot easier to solve Wink


if you want to do randoms in bat uyou use this function__ %random% __

but it generates a number in the 32000's or something. so i figured if you use a "set /a" function you could divide it into a smaller number like this:

set /a a=%random%
set /a a=%random% / 8000
if %a% equ 1 goto p1
if %a% equ 2 goto p1
if %a% equ 3 goto p1
if %a% equ 0 goto p0

by dividing by 8000 it gave 4 random choices(you can of course divide by other numbers)

"this is a clip from a small batch rpg game I am working on if anyone would like me to i'll post it when i'm for other people to test and enjoy"Grin