Computer Science Canada

DICE Help

Author:  Kira [ Thu Nov 01, 2007 8:40 pm ]
Post subject:  DICE Help

I'm new to turing, and I need LOTS of help =( . Anyways, here is the problem I been figuring it out for hours....I just wanted the program to tell how many times the dice gets rolled continuously in order to get the same number.... but when I try the second time and third time and etc.....The times the dice gets rolled is added to the previous one....is there a way that it doesn't add the previous number of times rolled?

Turing:

var number, Result, count : int := 0
var reply1, reply2 : string
loop
    randint (number, 1, 6)
    put "Do you want to play a dice game? (y/n) " ..
    get reply1
    exit when reply1 not= "y"
    put "This will be your randomly chosen number from 1-6: ", number
    delay (500)
    loop
        randint (Result, 1, 6)
        delay (500)
        put "It rolled ", Result
        count := count + 1
        if Result = number
                then
            put "It rolled ", count, " time(s) to get the same number."
            put "Do you want to try again? answer y or n " ..
            get reply2
            exit when reply2 not= "y"
            randint (number, 1, 6)
            put "This will be your randomly chosen number from 1-6: ", number
            delay (500)
        end if
    end loop
end loop

Author:  Nick [ Thu Nov 01, 2007 8:44 pm ]
Post subject:  RE:DICE Help

just reset count

count:=0

Author:  Kira [ Thu Nov 01, 2007 8:52 pm ]
Post subject:  RE:DICE Help

um, sorry....how do i rest count? do i enter count:=0 at the top?? ><

Author:  Tony [ Thu Nov 01, 2007 8:56 pm ]
Post subject:  RE:DICE Help

You use that line at whatever point in the program, where you want the count to be reset.

It would probably make sense to do something like this, right before the game begins.

Author:  Clayton [ Thu Nov 01, 2007 8:56 pm ]
Post subject:  RE:DICE Help

After you finish your embedded loop, (the one where you roll your "dice") just set count to zero again.

Author:  Kira [ Thu Nov 01, 2007 9:05 pm ]
Post subject:  RE:DICE Help

OMG THANKS SO MUCH... o yes one more thing....I got these dice faces pictures I wanted the program to show when a specific number on the dice pops up, is there a command that could make this happen? If so, what do I use and where do I input it in??

Author:  Tony [ Thu Nov 01, 2007 9:24 pm ]
Post subject:  RE:DICE Help

You should look into the proper usage of Pic.Draw()


: