Having problems comparing values
Author |
Message |
Frennic
|
Posted: 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
|
|
|
Tony
|
|
|
|
|
Bored
|
Posted: 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
|
Posted: 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 |
|
|
|
|
|
|
|