Rock-paper-scissors: Difference between revisions
m
→{{header|Sidef}}: updated code
m (→{{header|Haskell}}: hlint, hindent, type signatures, specified import) |
m (→{{header|Sidef}}: updated code) |
||
Line 4,352:
]
say <<"EOT"
\n>> Rock Paper Scissors <<\n
** Enter 'r', 'p', or 's' as your play.
Line 4,363:
var pScore = 0
var pcf = [0,0,0] # pcf = player choice frequency
var aChoice =
loop {
Line 4,380:
# show result of play
">> My play:
given ((aChoice - pChoice + 3) % 3) {
when (0) { say "Tie." }
when (1) { "%-*s
when (2) { "%-*s
}
Line 4,392:
# compute ai choice for next play
given (plays.
case (rn < pcf[0]) { aChoice = 1 }
case (pcf[0]+pcf[1] > rn) { aChoice = 2 }
|