Rock-paper-scissors: Difference between revisions
Content added Content deleted
mNo edit summary |
mNo edit summary |
||
Line 4,825: | Line 4,825: | ||
Red [Purpose: "Implement a rock-paper-scissors game with weighted probability"] |
Red [Purpose: "Implement a rock-paper-scissors game with weighted probability"] |
||
choices: ["r" "p" "s"] |
prior: rejoin choices: ["r" "p" "s"] |
||
prior: ["r" "p" "s"] |
|||
win: ["p" "s" "r"] |
|||
lose: ["s" "r" "p"] |
|||
while [ |
|||
find choices pchoice: ask "choose rock: r, paper: p, or scissors: s^/" |
|||
] [ |
|||
pchoice: ask "" |
|||
⚫ | |||
unless any [pchoice = "r" pchoice = "p" pchoice = "s"] [break] |
|||
cwin: select "rpsr" pchoice |
|||
close: select "rspr" pchoice |
|||
⚫ | |||
⚫ | |||
⚫ | |||
pindex: index? find choices pchoice |
|||
⚫ | |||
cindex: index? find win cchoice |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
] |
] |
||
append prior |
append prior cwin ;adds what would have beaten player |
||
⚫ | |||
lx: none |
|||
unless (find prior lose/:pindex) = none [lx: (index? find prior lose/:pindex) - 1] |
|||
⚫ | |||
] |
] |
||
</lang> |
</lang> |