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

Very good! Now, we'll calculate the robot's new position.

Exercise

Write a function called get_new_position(robot, current_position). This function accepts a robot and its current position, which is expressed as a tuple in the (row, column) format.

The function returns the robot's new position after a move forward from the direction the robot was already facing (<, ^, >, or v). This function won't check if the new field is empty or within the board's borders. It simply calculates the new position. We'll check if the field is empty in a separate function later.

Stuck? Here's a hint!

Inside the function, check robot['direction']. Based on the value, add or subtract 1 from the robot's current row or column.