Hello Explorer


Collapse Content

You are in charge of a robot, the Java Explorer (♖), which will be on its own in a dangerous world. In each challenge, you need to fill in the Java method play, which will be invoked on every turn of the game. The Explorer will be able to do one action each turn, and needs to reach the Goal (☆) within a certain number of turns.

Exploration Rover

Previously, the Java Explorer navigated a a simple 1-dimensional world, and could only go in 2 directions. Now it faces a 2D world and can go in 4 directions.

▥▥▥▥▥▥▥▥▥▥
▥♖.......▥
▥........▥
▥........▥
▥........▥
▥........▥
▥........▥
▥........▥
▥.......☆▥
▥▥▥▥▥▥▥▥▥▥

As mentioned in Attack and Retreat, you can specify the Direction to move by passing an Enum Direction parameter to walk(). This is the enum Direction:

enum Direction {
    LEFT, RIGHT, UP, DOWN;
} 

This code would move the Explorer down:

 explorer.walk(Direction.DOWN);

To get started use explorer.walk() to get to the Goal. You can check if the next Space is a Wall with Space's method isWall(), which returns true or false:

explorer.getSpace().isWall()

Challenge

Get the Explorer to the Goal!

Please sign in or sign up to submit answers.

Alternatively, you can try out Learneroo before signing up.

Contact Us
Sign in or email us at [email protected]