Rock paper scissors Spock lizard#
You must have played Rock paper scissors in your childhood. In this problem, we will implement a variation with Spock and lizard shapes which we refer to as RPSSL.
Fig. 12 Children in Laos playing rock paper scissors
CC BY-SA 3.0. By Thomas Schoch. Source: Wikimedia Commons#
RPSSL shapes are resolved as in Fig. 13.
Fig. 13 RPSSL resolution diagram. οΈa->b means a wins against b.
CC BY-SA 3.0. By DMacks (talk). Source: Wikimedia Commons#
Example run:
Welcome to πͺ¨ βοΈ ποΈ π π¦ !
(s) Single player
(e) Exit
Select an item: s
Starting game π
Select a shape:
0πͺ¨ || 1π¦ || 2βοΈ || 3ποΈ || 4π : 90
β Shape key 9 does not exist. Try again.
Select a shape:
0πͺ¨ || 1π¦ || 2βοΈ || 3ποΈ || 4π : 0
Agent: 2
π«:π€ 1:0
Select a shape:
0πͺ¨ || 1π¦ || 2βοΈ || 3ποΈ || 4π : 2
Agent: 2
π«:π€ 1:0
Select a shape:
0πͺ¨ || 1π¦ || 2βοΈ || 3ποΈ || 4π : 0
Agent: 4
π«:π€ 1:1
...
Select a shape:
0πͺ¨ || 1π¦ || 2βοΈ || 3ποΈ || 4π : 1
Agent: 0
π«:π€ 2:5
π€ Agent won!
Expectations:
has an entry menu
the agent can play randomly
shows score after each shape comparison
can handle wrong input both in the menu and gameplay, e.g., by showing an error message
in case you know
EOF: you donβt have to handle it
if a player reaches the
WINNING_SCOREthen this player wins
the program exits.
Important
Applies to all problems: you may override expectations and be creative, as long as your design decisions make sense to you and you can explain it.
Activity 21 (Flowchart v1 β overview)
Draw a flowchart for the problem. First focus on the menu and leave the details of a game round (until someone wins) out. In other words, represent a game round with a single process.
Activity 22 (Needed language syntax)
Break the flowchart down into language components. Which syntax from C can we use?