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.
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
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.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps
Knowledge Booster
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.Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education