Computer Science Canada

Rock Paper Scissors Game

Author:  amirsonali [ Thu Jan 12, 2006 8:34 pm ]
Post subject:  Rock Paper Scissors Game

Hey I am a new Comp Science student and i have a small task which is almost impossible

I was wondering if anyone can help me with a creation of a rock paper scissors game. The assignment is more for a game based on rock paper sccisors except it has three diffrent objects. And the assingnor would like me to have mouse clicks to choose the objects and animation of one object beating the other ( for example rock crushing scissor)

if you can help me please reply or send email to amirsonali@hotmail.com
thks a bunch

Martin says:Please make more descriptive titles in the future. Carry on.

Author:  Delos [ Thu Jan 12, 2006 8:40 pm ]
Post subject: 

Hello. Welcome.

This post is classified as "Turing Help" since you're asking for help. If you were posting up Source Code, you'd post it there. I've moved it to the appropriate place. You'll get used to this rather simple organisational structure in due time.

Your assignment is by no means impossible. However, you are not going to very much help unless you show us first that you've put some effort into it. Post up some snippets of the code you have, or at least the ideas you have (the pseudocode).
Please bear in mind that if you do post code to:
a) use [code] or [syntax] tags.
b) ensure that the code runs when we press F1
c) indent (F2).
d) attach a file instead if it is long (more than about a page)
e) use meaningful variable names so that we don't have to decypher too much
f) comment where possible

Doing this will greatly increase your chances of having useful help bestowed up you. Don't worry about the emailing, all posts will be put here so as to benefit others as well who may be in similar situations.

Author:  Cervantes [ Thu Jan 12, 2006 8:57 pm ]
Post subject: 

Cervantes, in the other thread wrote:

What specific problems are you having? If you don't know where to begin, try taking a look at the Turing Walkthrough to get you started.

Know that we don't do assignments for people. We'll help, but you have to have tried yourself to deserve that help. What algorithms/code have you got?


person, in the other thread wrote:

please delete this thread, u already have another one asking for the same thing

person, I'm fairly sure he can't delete his own thread. If you're talking to the staff: I don't mean to be rude, but we can think for ourselves. Replying to these threads to say things like that just makes it harder to clean up the mess.

Author:  person [ Thu Jan 12, 2006 9:01 pm ]
Post subject: 

Quote:
person, I'm fairly sure he can't delete his own thread


srry, i didnt know that

Author:  Albrecd [ Fri Jan 13, 2006 9:38 am ]
Post subject: 

Anyway... back to the topic of Rock, Paper, Scissors...

You could use randint to determine what the computer will choose:

code:
var CompSelection : int

randint (CompSelection, 1, 3)
if CompSelection = 1 then
    %Draw Rock
elsif CompSelection = 2 then
    %Draw Paper
else  %(if CompSelection = 3)
    %Draw Scissors
end if

Author:  amirsonali [ Mon Jan 16, 2006 6:34 pm ]
Post subject: 

Hey heres the game playing part of the code, this is just mostly type and select, i am still struggling with using mouse clicks and MOuse.Wait stuff

If some one could just put the code in a loop where by the text doesn't repeat that would be nice, i just can't figure it out. Like where the user enters 3 games, and the comp or user have to win atleast 2 games. the program only plays one game, and if its a tie it just stops. I want it to loop or start another game.

Please Help

Author:  iker [ Mon Jan 16, 2006 6:49 pm ]
Post subject: 

LOOPS

try something like (not copy and paste, because this is an example)
code:

var games,wins, losses, computerchoice, playerchoice : int

put "how many games..."
get games

loop
    put "chose 1,2,3
    get playerchoice
    randint (computerchoice,1,3)
    if playerchoice = 3 and computer choice = 1 then
    wins +=1
    elsif playerchoice = 1 and computer choice = 3 the
    losses +=1
    ..
    ..
    ..
    if wins / games >= .5 or losses / games >= .5 then
        exit
    end if
end loop
put "you won ", wins, " out of ", games, "games"


try putting your code into this 'template' and it should work, if not, just ask and someone or I will see whats wrong

Author:  amirsonali [ Mon Jan 16, 2006 7:52 pm ]
Post subject: 

Hey Thks a bunch, but how do make a the computer choose a random option every game, like right now the user picks 1 and the cpu picks 1 its a tie, and if the user picks 1 again its still a tie, the thing continues

attached-please help

Author:  Rasta Fella [ Mon Jan 16, 2006 8:37 pm ]
Post subject: 

amirsonali, if you correctly use Iker's template and post the attachment it will help us figure the syntax error(if you are) getting. In Iker's template is says var "computerchoice" use that as a variable and make a randint.

Author:  amirsonali [ Mon Jan 16, 2006 8:47 pm ]
Post subject: 

Rasta Fella wrote:
amirsonali, if you correctly use Iker's template and post the attachment it will help us figure the syntax error(if you are) getting. In Iker's template is says var "computerchoice" use that as a variable and make a randint.


he said use it as a guidline (example) so i did, but all i want is for the loop too change the random integer everytime the program runs the loop

Author:  amirsonali [ Mon Jan 16, 2006 8:49 pm ]
Post subject: 

amirsonali wrote:
Rasta Fella wrote:
amirsonali, if you correctly use Iker's template and post the attachment it will help us figure the syntax error(if you are) getting. In Iker's template is says var "computerchoice" use that as a variable and make a randint.


he said use it as a guidline (example) so i did, but all i want is for the loop too change the random integer everytime the program runs the loop


nvm

how do u unsend?

Author:  chrispminis [ Mon Jan 16, 2006 10:40 pm ]
Post subject: 

unsend... as in delete your previous posts? no can do, not in the help section. We keep these topics alive so that others may search the forum for topics related to their questions. So what you may consider useless, might be the same mistakes someone else is trying to correct.

Author:  Albrecd [ Tue Jan 17, 2006 8:43 am ]
Post subject: 

If you want the computer to pick at random, use:

code:
randint (computerChoice, 1, 3)
if computerChoice = 1 then
%Computer chooses paper
elsif computerChoice = 2 then
%Computer chooses rock
elsif computerChoice = 3 then
%Computer chooses scissors
end if

Author:  Cervantes [ Tue Jan 17, 2006 1:59 pm ]
Post subject: 

Albrecd wrote:
If you want the computer to pick at random, use:

code:
randint (computerChoice, 1, 3)
...


wtd wrote:

Someday the world will realize the evils of procedures and learn to embrace functions. Mutable state is something that should be avoided when possible.


code:

computerChoice := Rand.Int (1, 3)

Author:  iker [ Tue Jan 17, 2006 5:51 pm ]
Post subject: 

I actualy went along and made a rock paper scissers game in like 3 minutes, directly from my template, and it does exactly what you want it to do.. It randomizes the computers choice every time..

Author:  amirsonali [ Sun Jan 22, 2006 1:41 pm ]
Post subject: 

ye
so now i have to add an animation to the game and (attached) is my annimation, its just everytime i press any key besides (c) which is the key to continue, it loops, which is what its supposed to do, but however after one repeat, i press c and it loops again before quitting, i want it to quit as soon as the user presses c

------------------------------------

const CKEY:="c"

var key4:char

loop
cls
Pic.ScreenLoad ("human.bmp", 400, 0, picCopy)
Pic.ScreenLoad ("snowman.bmp", 100, 0, picCopy)
colorback(red)
color (blue)
delay (500)
cls
Pic.ScreenLoad ("human.bmp", 300, 0, picCopy)
Pic.ScreenLoad ("snowman.bmp", 100, 0, picCopy)
delay (500)
cls
Pic.ScreenLoad ("snowmanvshuman1.bmp", 100, 0, picCopy)
delay (500)
cls
Pic.ScreenLoad ("snowmanvshuman2.bmp", 100, 0, picCopy)
put "press (c) to continue or press any other key to play again"
get key4
exit when key4=CKEY


end loop

Author:  Rasta Fella [ Sun Jan 22, 2006 5:47 pm ]
Post subject: 

First, please use [code.] tags this makes evrything easier to read. Also when attaching more than 1 file please make sure to zip or rar your files(makes everything easier).

Now to your question do something like this:

code:

if chars (KEY_C) then %or whatever the key function is
exit %this will exit your loop you are in
end if

Author:  amirsonali [ Mon Jan 23, 2006 10:06 am ]
Post subject: 

Thks for the tip
but it still doesn't work, what i want is for it to loop when i press any key besides 'c' and when i press 'c' i want it to exit right away. It exits when i press it the first time, but if i press (example) 'a' and then press 'c' it loops once after pressing 'c' and then closes. I wish it would close right when i press 'c' plz help

Author:  amirsonali [ Mon Jan 23, 2006 8:31 pm ]
Post subject: 

K i figured it out, and here is my almost final product, the only problem now is thati can't get the animation to play when the user/computer wins
here is the file, plz help, i only have 8 hours


: