Rock-paper-scissors: Difference between revisions
m
→{{header|Vlang}}
Line 6,510:
Semi-translation of Go version:
<syntaxhighlight lang="vlang">
import rand
import os
const
rps = 'rps'
'Rock breaks scissors',s
'Paper covers rock',
'Scissors cut paper'
]
)
fn main() {
Line 6,529 ⟶ 6,532:
mut a_choice := rand.intn(3) or {0} // ai choice for first play is completely random
for _ in 0..6 {
p_choice := rps.index_any(pi)
if p_choice < 0 {break}
Line 6,546 ⟶ 6,549:
println('$p_score : $a_score')
// compute ai choice for next play
}
}
}
{{out}}
|