Explorer API
Note: walk
, getSpace
, look
and poke
can each take in a direction parameter:
- Direction.RIGHT
- Direction.LEFT
- Direction.DOWN
- Direction.UP
If no Direction is passed in, they will default to Direction.RIGHT.
Mutators / ActionsExplorer can do one action per turn.
walk()
- Moves the explorer forward (to the right) one Space.poke()
- Pokes the next space, causing damage to any Enemy there.recharge()
- Adds 9 to health.
Accessors:
Note that look() and lookAround() can include null cells.look()
- Returns an Array of 3 Spaces in the designated Direction.lookAround()
- Returns an 7x7 Array of Spaces with the Explorer in the center.getSpace()
- Returns the next Space on the board.getHealth()
- returns the value ofhealth
.
Space methods
isEnemy()
- returns true if the Space contains an Enemy, and false otherwise.isKnight()
- returns true if the Space contains a Knight, and false otherwise.isArcher()
- returns true if the Space contains an Archer, and false otherwise.isWall()
- returns true if the Space contains a Wall, and false otherwise.
Hello Again
Premium Content - Free Preview
Now this is not the end. It is not even the beginning of the end. But it is, perhaps, the end of the beginning. Winston Churchill, 1942
Note: In each level, the Java Explorer cannot take more than 130 moves to reach the goal.
The Java Explorer passed through many dangerous lands and finally nears the end of his journey. See the previous challenges to understand the Explorer's powers and enemies.
Explorer Review
The explorer can invoke one action method (mutator) each turn and any number of accessor methods. The 3 main actions are walk
to move, poke
to attack an enemy, and recharge
to restore health. walk
and poke
can take in a Direction enum as a parameter to apply the action in that direction. The explorer can invoke any number of accessor methods each turn, such as getHealth
to check health levels or look
to see a neighboring Space.
The board that the Explorer is on consists of different Spaces. Most Spaces are empty but some contain Walls (▥) or Enemies. This challenge has 2 different enemies: Pawns (♟), which can only attack within one square, and Archers (↢), which can attack up to 3 straight squares away.
Example Game
Here's some code for this challenge where the Explorer almost wins, but unfortunately dies first:
End of Free Content Preview. Please Sign in or Sign up to buy premium content.
Comments
Nima Boscarino
May 26, 4:55 PMI got the question right, and it registered as correct, but after refreshing my answer is no longer the answer I had written before. I am still registered as "correct", but I lost my actual answer :(
Learneroo
May 26, 4:59 PM@Nima, you should be able to see all your previous answers by clicking on "Submissions" above the code editor.