首页 > > 详细

辅导 FIT9136 Task 2 - Robbie the Explorer讲解 R编程

Task 2 - Robbie the Explorer

Background

Thanks to your code, Robbie is now able to load data, display the map, and get information about geological features. It is now time for Robbie to explore Mars.

Because Mars is a sphere, Robbie is able to wrap around the map. That means:

· If Robbie is at location (0, 0) and he moves left, his new location will be (0, n_cols - 1).

· If Robbie is at location (0, n_cols - 1) and he moves right his new location will be (0, 0).

· The same applies for columns.

Robbie has some moving rules:

· Robbie's initial location is (0, 0).

· It will take 1 day for Robbie to move from one location to another adjacent location.

· Robbie prefers to move horizontally than vertically. Especially, he hates (and will never do) diagonal moves.

· Robbie always selects the path with least moves. He also prefers a path with wrapping to the one without wrapping if it does not increase the number of moves required.

If Robbie reaches a location that exists a geological feature, he can also explore this feature.

· The time it takes for Robbie to explore the feature depends on his exploration speed and the feature's size.

· Robbie's initial exploration speed is given in the table below.

+------------------+--Mountain------------+--Lake---------------+--Crater-----------------+

| Robbie the Robot | 6 (height unit/day)  | 8 (depth unit/day)  | 10 (perimeter unit/day) |

+------------------+----------------------+---------------------+-------------------------+

· If he finishes exploring a feature before the end of the day, he will take a rest until the end of the day. For example, if a feature requires him 1.3 days to explore, then after having explored this feature, he will rest until the end of the day, which means 2 days in total.

· Once he finishes exploring a geological feature, he gains more skills and experiences. As a result, his exploration speed for this type of feature will increase by 20%.

Your tasks

You will write the code in the following files to help Robbie.

# geo_features.py

You may make changes to the classes GeoFeature , Mountain, Lake, and Crater as you need.

# robot.py

The robot.py module provides the class Robot, of which Robbie is an instance.

# task2.py

In addition to the commands in task 1, you need to add the following commands:

· The user can input moveto  where  and  are integers corresponding to a location (Y,X) that Robbie wants to move to (see example 1).

· The user can input explore to explore the current location. If there is no geological feature at this location, Robbie will do nothing (and it costs him no time). Otherwise, he will explore the feature in a number of days required (see examples 2 and 3).

· The user can input display journey to display what Robbie have done so far (see the examples 1-3).

You can assume that and correspond to a valid location on the map.

You can assume that all user inputs are valid.

You are allowed to modify the import statements in the scaffold, but you are not allowed to import any modules which were not originally imported in the scaffold.




联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!