21 lines
566 B
Plaintext
21 lines
566 B
Plaintext
import Prelude;
|
|
|
|
rel[str, str] whatbeats = {<"Rock", "Scissors">, <"Scissors", "Paper">, <"Paper", "Rock">};
|
|
|
|
list[str] ComputerChoices = ["Rock", "Paper", "Scissors"];
|
|
|
|
str CheckWinner(a, b){
|
|
if(b == getOneFrom(whatbeats[a]))
|
|
return a;
|
|
elseif(a == getOneFrom(whatbeats[b]))
|
|
return b;
|
|
else return "Nobody";
|
|
}
|
|
|
|
public str RPS(human){
|
|
computer = getOneFrom(ComputerChoices);
|
|
x = if(human == "Rock") "Paper"; elseif(human == "Paper") "Scissors"; else "Rock";
|
|
ComputerChoices += x;
|
|
return "Computer played <computer>. <CheckWinner(human, computer)> wins!";
|
|
}
|