Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Cyber Battle Game
Game elements
Main Game Loop
Robot moves
Final game

Instruction

Good! Now, let's create all the possible robot moves. We'll start with the easiest one: turning right.

A robot can face any of the four directions: left <, up ^, right >, or down v. The current direction is stored in the direction key of the robot's dictionary:

robot_a = {'name': 'A', 'direction': '>'}

Exercise

Create a function named turn_right(robot). The function should update the robot's direction value:

  1. > changes to v
  2. v changes to <
  3. < changes to ^
  4. ^ changes to >

Stuck? Here's a hint!

The easiest way to get the new direction is to use the following list:

moves = ['>', 'v', '<', '^', '>']

Next, find the index of the robot's current direction, and then simply increase it by 1.