samedi 26 septembre 2015

The scenes in the Asn2 Scenes link on the Web Page represents an island (yellow squares) surrounded by water

The scenes in the Asn2 Scenes link on the Web Page represents an island (yellow squares) surrounded by water (blue squares). There is a cat on the island (brown square) and a bridge leading to safety (black square). A drunk mouse is placed in the center of the island. The motion of the mouse is guided by the following rules: • The mouse is allowed to move one square at a time, either horizontally or vertically (no diagonal moves). • A random number between 0 and 3 inclusive is used to define the direction of the next move (0 for North, 1 for East, 2 for South and 3 for West). • The mouse drowns if it : o hits water, o dies of starvation if it makes more than 100 moves, or o gets eaten by the cat. • The mouse escapes if it hopefully crosses the bridge. Write a program to make the mouse move randomly across the island. The program should run from the start several times (random number of runs) to count the number of times the mouse drowns, escapes or dies. Your program should produce a histogram representing the statistics of the runs.




Aucun commentaire:

Enregistrer un commentaire