Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Having problems comparing values
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Frennic




PostPosted: Fri Apr 15, 2005 4:03 pm   Post subject: Having problems comparing values

I am trying to write a Yahtzee-esque game, and I am at a standstill. I have looked through the keyword help for commands that might help, but have found none. Right now, my program will roll five dice, display the graphics, and that's it. I would really appreciate any assistance in finding a command to compare the values of the five vaiables (having it recognize pairs, three-of-a-kinds, etc)

Thanks,
Frennic
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Apr 15, 2005 4:31 pm   Post subject: (No subject)

Even though the following links deal with cards, you might find the ideas from them to be useful.

http://www.compsci.ca/v2/viewtopic.php?t=7651&highlight=cards
http://www.compsci.ca/v2/viewtopic.php?t=7184&highlight=cards
Bored




PostPosted: Sat Apr 16, 2005 1:15 pm   Post subject: (No subject)

Maybe have a function that will return the type of card for example here's one that will see however many of a kind you rolled and return it.
code:

fcn whatRoll (dice : array 1 .. 5 of int) : int
    var returnValue : int := 0
    var currentValue : int := 1
    for i : 1 .. 4
        for t : i + 1 .. 5
            if dice (i) = dice (t) then
                currentValue := currentValue + 1
            end if
        end for
        if currentValue > returnValue then
            returnValue := currentValue
        end if
        currentValue := 1
    end for
    result returnValue
end whatRoll
loop
    var diceRoll : array 1..5 of int
    for i : 1..5
        randint (diceRoll (i),1,6)
    end for
    put "Hand: " ..
    for i : 1..5
        put diceRoll (i), ", "..
    end for
    put ""
    put "Result: ", whatRoll (diceRoll)
    delay (5000)
    cls
end loop
Frennic




PostPosted: Mon Apr 18, 2005 11:56 am   Post subject: (No subject)

Awesome... thanks guys... I'l give these a shot tonight when I get home. I''ll let you know how it goes.

Frennic
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: