Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Currently, the Titanic is on a direct impact route with the iceberg. But you can change this! You have the ability to modify the behavior
Currently, the Titanic is on a direct impact route with the iceberg.
But you can change this! You have the ability to modify the behavior of autopilotnextstep to steer the ship out of danger and still reach the West wing!
Let's understand the function's arguments and return values:
titanicpos is a list that describes the Titanics coordinates on the ocean, for example,
oceansize is an integer that represents the size of the grid of the ocean.
The function can only return the following values: WEST, EAST, SOUTH, NORTH.
To locate the iceberg, you should use the following Ocean functions:
Function
Description
getcellrow col
Returns the cell's content in the position row col
getallpositions
Used to iterate on all of the positions of the grid in a for loop. In each iteration, returns row, col.
During each turn, the game engine will call your function. It will provide the current position of the Titanic and the size of the ocean. Your function should decide which direction the Titanic should navigate in based on this information.
Remember the goal is to reach the West side of the ocean.
Save the Titanic!
HintsTips
If you fail the test, you can change the Titanic's starting position and the iceberg's starting position to see why!
The getcell value will return when the cell is iceberg
All of your code, except for the initial Titanic and iceberg positions, must be written inside functions. You can create additional functions if necessary, but any code that runs outside of a function may not function properly.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started