Question: Can anyone help me to answer this Java problem using the Monte Carlo method? Thank you very much for the help! A mouse is trying
Can anyone help me to answer this Java problem using the Monte Carlo method? Thank you very much for the help!


A mouse is trying to escape from a maze where it starts moving from the top-left corner (0,0) to the exit in the bottom-right corner (6,6). It moves according to the following rules: o o o o o The mouse has 40% chance to go forward along the same direction. The mouse has 30% chance to turn left and 30% chance to turn right. The initial moving direction is indicated by the pointer. So, if the mouse chooses to go forward, it will reach (1,0) in the next step. The new position must be within the boundaries of the maze. The new position must not have been visited previously. If the new position does not fulfil the criteria above, the mouse will try another move again. Every decision is independent of the others. If the mouse reaches a dead-end - all directions are not enterable, it fails to leave the maze. The mouse continues to move until it reaches the exit. o o a (0,0) DEAD END Exit (6,6) Write a simulation program using the Monte Carlo method to estimate the probability (P) of the mouse successfully escaping from the maze. The simulation should run one million times. Your program should print out the simulation results clearly and round the success rate P to 3 digits after the decimal point as follow: The Monte Carlo simulation result of one million runs: No. of successful escape: 279451 Success Rate P: 0.279 The acceptable range of the success rate is 0.278 - 0.281 and the execution time should be less than 5 seconds. In addition to the above functional requirements, your program should also be object- oriented and follow the Java naming convention. That is, you need to design one or more classes to model the simulation program. Programming style will be considered in the marking. All your classes should be organised in the package hw1.sDDDDDDDD where the D- string is your 8-digit student ID. Your main method should be located in the Main class as shown below. package hw1. sDDDDDDDD; // DDDDDDDD should be replaced by your real SID public class Main { public static void main(String[] args) { // entry point of your program } } class Mouse { // define the behaviours of the mouse } class Maze { // define the behaviours of the maze } // more classes if needed A mouse is trying to escape from a maze where it starts moving from the top-left corner (0,0) to the exit in the bottom-right corner (6,6). It moves according to the following rules: o o o o o The mouse has 40% chance to go forward along the same direction. The mouse has 30% chance to turn left and 30% chance to turn right. The initial moving direction is indicated by the pointer. So, if the mouse chooses to go forward, it will reach (1,0) in the next step. The new position must be within the boundaries of the maze. The new position must not have been visited previously. If the new position does not fulfil the criteria above, the mouse will try another move again. Every decision is independent of the others. If the mouse reaches a dead-end - all directions are not enterable, it fails to leave the maze. The mouse continues to move until it reaches the exit. o o a (0,0) DEAD END Exit (6,6) Write a simulation program using the Monte Carlo method to estimate the probability (P) of the mouse successfully escaping from the maze. The simulation should run one million times. Your program should print out the simulation results clearly and round the success rate P to 3 digits after the decimal point as follow: The Monte Carlo simulation result of one million runs: No. of successful escape: 279451 Success Rate P: 0.279 The acceptable range of the success rate is 0.278 - 0.281 and the execution time should be less than 5 seconds. In addition to the above functional requirements, your program should also be object- oriented and follow the Java naming convention. That is, you need to design one or more classes to model the simulation program. Programming style will be considered in the marking. All your classes should be organised in the package hw1.sDDDDDDDD where the D- string is your 8-digit student ID. Your main method should be located in the Main class as shown below. package hw1. sDDDDDDDD; // DDDDDDDD should be replaced by your real SID public class Main { public static void main(String[] args) { // entry point of your program } } class Mouse { // define the behaviours of the mouse } class Maze { // define the behaviours of the maze } // more classes if needed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
