Question
Please help me write the following to complete unlucky robot game. Rules of Movement Our robot can only move in one of the following directions:
Please help me write the following to complete unlucky robot game.
Rules of Movement
Our robot can only move in one of the following directions: right(r), left(l), up(u) or down(d). It cannot move diagonally.
At the beginning of each iteration the void displayInfo 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 displayInfo function(int x, int y, int itrCount, int totalScore) is launched, the user will be asked to input a character ('r': right, 'l': left, 'u': up and 'd': down) to tell the robot where to go next.
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.
List of Variables
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.
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
6. int y: stores the y coordinate of the robot, initialized as 0
Rules of Payment
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. 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.
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