Rock-paper-scissors: Difference between revisions

m
no edit summary
mNo edit summary
mNo edit summary
Line 4,825:
Red [Purpose: "Implement a rock-paper-scissors game with weighted probability"]
 
prior: rejoin choices: ["r" "p" "s"]
prior: ["r" "p" "s"]
win: ["p" "s" "r"]
lose: ["s" "r" "p"]
 
foreverwhile [
printfind choices pchoice: ask "choose rock: r, paper: p, or scissors: s^/"
] [
pchoice: ask ""
print ["AI Draws:" cchoice: random/only prior]
unless any [pchoice = "r" pchoice = "p" pchoice = "s"] [break]
cwin: select "rpsr" pchoice
close: select "rspr" pchoice
print case [
cchoice: random/only prior
pchoice = cchoice [print "tie"]
pindex: index? find choices pchoice
pindexcchoice = cindexcwin [print "you lose"]
cindex: index? find win cchoice
true'else [print "you win"]
case [
pchoice = cchoice [print "tie"]
pindex = cindex [print "you lose"]
true [print "you win"]
]
append prior win/:pindexcwin ;adds what would have beaten player
unless lx = none [remove skipfind prior lx]close ;removes what would have lost to player
lx: none
unless (find prior lose/:pindex) = none [lx: (index? find prior lose/:pindex) - 1]
unless lx = none [remove skip prior lx] ;removes what would have lost to player
]
</lang>
Anonymous user