Rules of Movement Our robot can only move in one of the following directions: right(r), left(1), up(u) or down(d). It cannot move diagonally. Meaning that at the beginning of each iteration after the printing of the coordinates is done, the user will be asked to input the direction. Then, you need to run the doesExceed function to check if by applying the change the user requested to the x or y coordinate, the new changed coordinate will exceed 4 or if it will fall under 0. If the robot would exceed the grid limits (the doesExceed function returns true), the user will automatically take -2,000 points of damage; the location will remain the same as the previous iteration; the iteration count increases and the user will also have to pay for the movement (-50 or -10 depending on the direction). Otherwise, the location and count will be updated, and the user only has to pay the moving penalty (-50 or -10 depending on the direction). At the beginning of each iteration the void displaylnfo function(int x, int y, int itrCount, int totalScore) will be called. It will print a message on the screen reporting the current x and y coordinate of the robot, the total score and the number of iterations made so far. After the void displaylnfo function(int x, int y, int itrCount, int totalScore) is launched, the user will be asked to input a character ('r': right, T: left, 'u': up and 'd': down) to tell the robot where to go next. E.g.: If the robot is at cell (4, 2) and the user enters 'ť they will face a 2,000 point damage (-2,000 added to its total score), the iteration count will be updated; the x coordinate will remain unchanged (4) for the next iteration and the user will also face a -50 damage due to having moved to the right. But if the user inputs 'u', there will be no -2,000 damage and only -10 will be taken out of its total score. 1. If the robot moves one cell to the right, its x coordinate is incremented by one and its y coordinate remains unchanged. 2. If the robot moves one cell to the left, its x coordinate is decremented by one and its y coordinate remains unchanged. 3. If the robot moves one cell up, its y coordinate is incremented by one and its x coordinate remains unchanged. 4. If the robot moves one cell down, its y coordinate will be decremented by one and its x coordinate remains unchanged. Functions: void displaylnfo function(int x, int y, int itrCount, int totalScore) This function will be called at the beginning of each iteration and it will print a message in the console reporting the current x and y coordinate of the robot, the total score, and the number of iterations made so far and moves to the next line(\n). List of Variables For the first iteration you will have to print this. You must respect the following format for the rest of There are some variables that you need to define in your main function before entering the control statement. You might want to use more variables, but the following should be present in your code. the iterations as well: | For point (X-0, Y-0) at iterations: 0 the total score is: 300 List of mandatory variables 1. int totalScore: keeps track of the total number of points obtained, initialized as 300 2. int itrCount: keeps track of the number of iterations. 3. int reward: stores the output of the reward function or the punishOrMercy function in each iteration. 4. char direction: stores the direction the user inputs 5. int x: stores the x coordinate of the robot, initialized as 0 boolean doesExceed(int x, int y, char direction) This function will receive the coordinates of the robot together with the direction the user entered that the robot should move towards. It will return true if the robot would exceed the grid limits after taking a step towards that direction and false otherwise.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

e Please read the whole document. Show the output screenshots with the code when done. You have to write it in Java Try and use methods and functions in the code.

A robot walks into a 5*5 grid to collect some points from some of the cells. The objective of the game is
to reach one of the end cells or to collect above 2,000 points. Of course, like every other game, you will
lose if your points fall under a certain range.
Termination Criterion
Starting at the start cell (x=0, y=0), the goal is to keep moving in the grid and collecting points until one
of the following conditions is satisfied:
1. The number of the steps/iterations exceeds 20
2. Your total score falls under -1,000
3. Your total score exceeds 2,000
4. The robot reaches one of the end locations (x=4, y=4) OR (x=4, y=0).
Transcribed Image Text:A robot walks into a 5*5 grid to collect some points from some of the cells. The objective of the game is to reach one of the end cells or to collect above 2,000 points. Of course, like every other game, you will lose if your points fall under a certain range. Termination Criterion Starting at the start cell (x=0, y=0), the goal is to keep moving in the grid and collecting points until one of the following conditions is satisfied: 1. The number of the steps/iterations exceeds 20 2. Your total score falls under -1,000 3. Your total score exceeds 2,000 4. The robot reaches one of the end locations (x=4, y=4) OR (x=4, y=0).
Meaning that at the beginning of each iteration after the printing of the coordinates is done, the user
will be asked to input the direction. Then, you need to run the doesExceed function to check if by
Rules of Movement
Our robot can only move in one of the following directions: right(r), left(1), up(u) or down(d). It cannot
applying the change the user requested to the x or y coordinate, the new changed coordinate will
exceed 4 or if it will fall under 0. If the robot would exceed the grid limits (the doesExceed function
returns true), the user will automatically take -2,000 points of damage; the location will remain the
move diagonally.
At the beginning of each iteration the void displaylnfo function(int x, int y, int itrCount, int totalScore)
will be called. It will print a message on the screen reporting the current x and y coordinate of the robot,
same as the previous iteration; the iteration count increases and the user will also have to pay for the
movement (-50 or -10 depending on the direction). Otherwise, the location and count will be updated,
and the user only has to pay the moving penalty (-50 or -10 depending on the direction).
the total score and the number of iterations made so far.
After the void displaylnfo function(int x, int y, int itrCount, int totalScore) is launched, the user will be
asked to input a character ('r': right, T': left, 'u': up and 'd': down) to tell the robot where to go next.
E.g.: If the robot is at cell (4, 2) and the user enters 'r' they will face a 2,000 point damage (-2,000 added
to its total score), the iteration count will be updated; the x coordinate will remain unchanged (4) for the
1. If the robot moves one cell to the right, its x coordinate is incremented by one and its y
coordinate remains unchanged.
next iteration and the user will also face a -50 damage due to having moved to the right. But if the user
inputs 'u', there will be no -2,000 damage and only -10 will be taken out of its total score.
2.
moves one cell to the left, its x coordinate is decremented by one and its y
coordinate remains unchanged.
3. If the robot moves one cell up, its y coordinate is incremented by one and its x coordinate
remains unchanged.
Functions:
4. If the robot moves one cell down, its y coordinate will be decremented by one and its x
coordinate remains unchanged.
void displaylnfo function(int x, int y, int itrCount, int totalScore)
This function will be called at the beginning of each iteration and it will print a message in the console
reporting the current x and y coordinate of the robot, the total score, and the number of iterations
made so far and moves to the next line(\n).
List of Variables
For the first iteration you will have to print this. You must respect the following format for the rest of
There are some variables that you need to define in your main function before entering the control
the iterations as well:
statement. You might want to use more variables, but the following should be present in your code.
For point (X=0, Y=0) at iterations: 0 the total
score is: 300
List of mandatory variables
1. int totalScore: keeps track of the total number of points obtained, initialized as 300
boolean doesExceed(int x, int y, char dire
2. int itrCount: keeps track of the number of iterations.
This function will receive the coordinates of the robot together with the direction the user entered that
3. int reward: stores the output of the reward function or the punishOrMercy function in each
the robot should move towards. It will return true if the robot would exceed the grid limits after taking a
iteration.
step towards that direction and false otherwise.
4. char direction: stores the direction the user inputs
5. int x: stores the x coordinate of the robot, initialized as 0
6. int y: stores the y coordinate of the robot, initialized as 0
int reward()
This function will be called when the robot makes a move and ends up in a cell. It returns a number as
the reward or the punishment of entering that cell. Once called, the function will roll a dice and return a
Rules of Payment
number based on the following rules:
We don't want the game to go on forever. When the robot moves, (in each iteration), it will lose some
points according to the following rules:
1. If 1 is displayed it will return -100.
2. If 2 is displayed it will return -200.
3. If 3 is displayed it will return -300.
4. If 4 is displayed it will return 300.
5. If 5 is displayed it will return 400.
6. If 6 is displayed it will return 600.
1. For every cell, the robot moves right, left, or down it will lose 50 points.
2. However, if it decides to go up, it will only lose 10 points.
The robot should not exit the grid. So, neither the robot's x coordinate nor its y coordinate should be
under 0 or above 4 or you will be penalized -2,000 points.
Transcribed Image Text:Meaning that at the beginning of each iteration after the printing of the coordinates is done, the user will be asked to input the direction. Then, you need to run the doesExceed function to check if by Rules of Movement Our robot can only move in one of the following directions: right(r), left(1), up(u) or down(d). It cannot applying the change the user requested to the x or y coordinate, the new changed coordinate will exceed 4 or if it will fall under 0. If the robot would exceed the grid limits (the doesExceed function returns true), the user will automatically take -2,000 points of damage; the location will remain the move diagonally. At the beginning of each iteration the void displaylnfo function(int x, int y, int itrCount, int totalScore) will be called. It will print a message on the screen reporting the current x and y coordinate of the robot, same as the previous iteration; the iteration count increases and the user will also have to pay for the movement (-50 or -10 depending on the direction). Otherwise, the location and count will be updated, and the user only has to pay the moving penalty (-50 or -10 depending on the direction). the total score and the number of iterations made so far. After the void displaylnfo function(int x, int y, int itrCount, int totalScore) is launched, the user will be asked to input a character ('r': right, T': left, 'u': up and 'd': down) to tell the robot where to go next. E.g.: If the robot is at cell (4, 2) and the user enters 'r' they will face a 2,000 point damage (-2,000 added to its total score), the iteration count will be updated; the x coordinate will remain unchanged (4) for the 1. If the robot moves one cell to the right, its x coordinate is incremented by one and its y coordinate remains unchanged. next iteration and the user will also face a -50 damage due to having moved to the right. But if the user inputs 'u', there will be no -2,000 damage and only -10 will be taken out of its total score. 2. moves one cell to the left, its x coordinate is decremented by one and its y coordinate remains unchanged. 3. If the robot moves one cell up, its y coordinate is incremented by one and its x coordinate remains unchanged. Functions: 4. If the robot moves one cell down, its y coordinate will be decremented by one and its x coordinate remains unchanged. void displaylnfo function(int x, int y, int itrCount, int totalScore) This function will be called at the beginning of each iteration and it will print a message in the console reporting the current x and y coordinate of the robot, the total score, and the number of iterations made so far and moves to the next line(\n). List of Variables For the first iteration you will have to print this. You must respect the following format for the rest of There are some variables that you need to define in your main function before entering the control the iterations as well: statement. You might want to use more variables, but the following should be present in your code. For point (X=0, Y=0) at iterations: 0 the total score is: 300 List of mandatory variables 1. int totalScore: keeps track of the total number of points obtained, initialized as 300 boolean doesExceed(int x, int y, char dire 2. int itrCount: keeps track of the number of iterations. This function will receive the coordinates of the robot together with the direction the user entered that 3. int reward: stores the output of the reward function or the punishOrMercy function in each the robot should move towards. It will return true if the robot would exceed the grid limits after taking a iteration. step towards that direction and false otherwise. 4. char direction: stores the direction the user inputs 5. int x: stores the x coordinate of the robot, initialized as 0 6. int y: stores the y coordinate of the robot, initialized as 0 int reward() This function will be called when the robot makes a move and ends up in a cell. It returns a number as the reward or the punishment of entering that cell. Once called, the function will roll a dice and return a Rules of Payment number based on the following rules: We don't want the game to go on forever. When the robot moves, (in each iteration), it will lose some points according to the following rules: 1. If 1 is displayed it will return -100. 2. If 2 is displayed it will return -200. 3. If 3 is displayed it will return -300. 4. If 4 is displayed it will return 300. 5. If 5 is displayed it will return 400. 6. If 6 is displayed it will return 600. 1. For every cell, the robot moves right, left, or down it will lose 50 points. 2. However, if it decides to go up, it will only lose 10 points. The robot should not exit the grid. So, neither the robot's x coordinate nor its y coordinate should be under 0 or above 4 or you will be penalized -2,000 points.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Block Comments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education