我正在尝试为学校项目创建一个Rock Paper Scissors游戏。比较获胜者(至少对我来说)最直接的方法是做以下事情:
int rock = 1, paper = 2, scissors = 3;
int computerChoice = randomNum();
int playerChoice;
if (playerChoice == computerChoice)
return "Tie";
else if (playerChoice == rock and computerChoice == paper)
return "Computer wins";
// And so on
这会很快变得非常大,我想知道是否有更简单的方法吗?