Answered step by step
Verified Expert Solution
Link Copied!

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 auto_pilot_next_step to steer the ship out of danger and still reach the West wing!
Let's understand the function's arguments and return values:
titanic_pos is a list that describes the Titanics coordinates on the ocean, for example, [4,3].
ocean_size 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
get_cell(row, col)
Returns the cell's content in the position [row, col].
get_all_positions()
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!
Hints/Tips
If you fail the test, you can change the Titanic's starting position and the iceberg's starting position to see why!
The get_cell 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

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions