Question
Answer in Java please thank you There is an artificial environment that a robot can freely walk on that. The user controls the robot's movement.
Answer in Java please thank you
There is an artificial environment that a robot can freely walk on that. The user controls the robot's movement. The environment automatically will be loaded from the given file. The environment is a 2D character set. Your program should read a 2D array of characters. Your program should store the entire map inside an array. To move the robot, you give the commands like u for up and d for down and... If the location is blocked you can produce a new command. After each move, the energy of the robot reduces by one. If you receive to the goal point within the number of allowed steps then you are a winner. If you run out of steps, you are a loser. If you enter a blank line the program exits.
Your program should store the states of the robot on private static member variables.
Your program should only have one class "GoalSeekingRobotGame". The others must be static methods.
There are different types of characters:
Goal: '*'
Robot: 'o'
Empty space: ' '
Obstacle: '#'
Battery: '+'
Trap: '-'
Boundary: %
Direction: A character number: 'u', 'l', 'd', 'r'
The user can move to any direction by inserting any of the following characters: u, l, d, r
The robot has a certain initial energy. After each move, its energy reduces by one.
The robot's energy increases by 10 when moving over a battery and the battery disappears.
The robot's energy decreases by 10 when moving over a trap and the trap disappears.
The direction will never disappear and they show the goal is located in which direction.
The robot can only see a square space around itself with a radius of two blocks. It saves its memory and it marks its path with '.' characters.
The user is the winner if it reaches the goal point without running out of energy.
No Methods body (i.e. between { and }) is allowed to be larger than 12 lines.
Here is a sample of running the program:
Input:
25
%%%%%%%%%%%%%%%%%
%###############%
%## r ######*#%
%##### ####### #%
%##### ## #%
%##### -### ##%
%o # #### ##%
%## #### ##%
%## ############%
%## ############%
%## u+ #####%
%##### ### #####%
%##### ### ####%
%##### #########%
%###############%
%###############%
%%%%%%%%%%%%%%%%%
>READY:
25
?????
%###?
%###?
%o ?
%## ?
%## ?
?????
>r
24
??????
%####?
%####?
%.o ?
%## #?
%## #?
??????
u
4
?%%%%%
??####%
????????###o#%
????## #######.#%
%##### ## ..#%
%#####...-###.##%
%......#.####.##%
%## ####......##?
%## ############?
??????##########?
????????????
Congratulations! You won the game!
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