DEV Community

Cover image for My #100daysOfCode Challenge - Python 100 projects in 100 days - Journal Entries - Day 6
Anthony Beckford🚀
Anthony Beckford🚀

Posted on

2

My #100daysOfCode Challenge - Python 100 projects in 100 days - Journal Entries - Day 6

Day 6— Reeborg’s World maze game

This project we used Reeborg's world to learn about function

Instructions:

Reeborg was exploring a dark maze and the battery in its flashlight ran out.
Write a program using an if/elif/else statement so Reeborg can find the exit. The secret is to have Reeborg follow along the right edge of the maze, turning right if it can, going straight ahead if it can’t turn right, or turning left as a last resort.

What you need to know:

  • The functions move() and turn_left().
  • Either the test front_is_clear() or wall_in_front(), right_is_clear() or wall_on_right(), and at_goal().
  • How to use a while loop and if/elif/else statements.
  • It might be useful to know how to use the negation of a test (not in Python).
  • A robot located at (x, y) = (6, 4) carries no objects.

Goal to achieve:

The final position of the robot must be (x, y) = (6, 4)

def turn_right():
turn_left()
turn_left()
turn_left()
while not at_goal():

if right_is_clear():
turn_right()
move()
elif front_is_clear():
move()
else:
turn_left()

Alt Text

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (2)

Collapse
 
badasscoder profile image
Badasscoder

link to this game

Collapse
 
dinusaur profile image
Dinu Bălan

what will happen if you start on (3,3)? wouldn't that cause an infinite loop?

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay