mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-08 19:33:31 -08:00
Fix random logic in Nim ports
This commit is contained in:
@@ -4,6 +4,8 @@ var
|
||||
bet, cardA, cardB, cardC, stash: int
|
||||
retry: bool = true
|
||||
|
||||
randomize() # Seed the random number generator
|
||||
|
||||
proc printGreeting() =
|
||||
echo spaces(26),"ACEY DUCEY CARD GAME"
|
||||
echo spaces(15),"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||
|
||||
@@ -10,6 +10,8 @@ var
|
||||
prompt: string
|
||||
stillplaying: bool = true
|
||||
|
||||
randomize() # Seed the random number generator
|
||||
|
||||
# Seed 3 unique random numbers; indicate if they're all unique
|
||||
proc genSeed(): bool =
|
||||
for i in 1..3:
|
||||
|
||||
@@ -4,6 +4,8 @@ var
|
||||
wager, winnings, rollResult: int
|
||||
stillplaying: bool = true
|
||||
|
||||
randomize() # Seed the random number generator
|
||||
|
||||
proc tryAgain(): bool =
|
||||
echo "WANT TO PLAY AGAIN? (YES OR NO)"
|
||||
var answer = readLine(stdin).normalize()
|
||||
|
||||
@@ -6,6 +6,8 @@ var
|
||||
z: string
|
||||
retry: bool = true
|
||||
|
||||
randomize() # Seed the random number generator
|
||||
|
||||
echo spaces(34), "DICE"
|
||||
echo spaces(15), "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||
echo "\n"
|
||||
|
||||
@@ -4,10 +4,11 @@ var
|
||||
carSpeed, diff, err, guess, trainSpeed, carTime: int
|
||||
stillplaying: bool = true
|
||||
|
||||
randomize() # Seed the random number generator
|
||||
|
||||
# Return a tuple that'll be carSpeed, diff, trainSpeed
|
||||
proc randomNumbers(): (int,int,int) =
|
||||
randomize()
|
||||
result = (rand(1..25)+40 , rand(1..15)+5 , rand(1..19)+20)
|
||||
result = (rand(41..65), rand(6..20), rand(21..39))
|
||||
|
||||
# Do we want to play again?
|
||||
proc tryAgain(): bool =
|
||||
|
||||
Reference in New Issue
Block a user