Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objective: Write a program that simulates a robot running a queue of commands to move around a board with obstacles. The board is composed of

Objective:

Write a program that simulates a robot running a queue of commands to move around a board with obstacles. The board is composed of spaces that are either empty (_) or have an obstacle (X). Also the board is assumed to be 10x10 spaces. The robot (O) has an x and y position corresponding to its location on the board, and four commands: move up, move down, move left, and move right. Both the board and the robots commands are assumed to be read in via a file (you can make your own format). Assume the robot starts in the top left corner of the board. The robot and an obstacle cannot exist in the same space, and if that happens the robot will crash, or in other words the simulation will stop. Also if the robot goes outside of the bounds of the board, then the robot will crash as well. The robots commands must be enqueued and dequeued from a Generic Queue of your own making. You may not use the built in Java Queue.

board.txt

_____X____

_______X__

_______X__

X____X____

_X________

__X___X___

_________X

___X__X___

___X______

__XX______

robotCommands.txt

Move Right
Move Down
Move Down
Move Down
Move Right
Move Right
Move Right
Move Down
Move Right
Move Right
Move Right
Move Right
Move Down
Move Down
Move Down
Move Down
Move Down
Move Right

Example Dialog:

Welcome to the Robot Simulator

Enter file for the Board

board.txt

Enter file for the Robot Commands

robotCommands.txt

O____X____

_______X__

_______X__

X____X____

_X________

__X___X___

_________X

___X__X___

___X______

__XX______

Simulation begin

Command 0

_O___X____

_______X__

_______X__

X____X____

_X________

__X___X___

_________X

___X__X___

___X______

__XX______

Command 1

_____X____

_O_____X__

_______X__

X____X____

_X________

__X___X___

_________X

___X__X___

___X______

__XX______

Command 2

_____X____

_______X__

_O_____X__

X____X____

_X________

__X___X___

_________X

___X__X___

___X______

__XX______

Command 3

_____X____

_______X__

_______X__

XO___X____

_X________

__X___X___

_________X

___X__X___

___X______

__XX______

Command 4

_____X____

_______X__

_______X__

X_O__X____

_X________

__X___X___

_________X

___X__X___

___X______

__XX______

Command 5

_____X____

_______X__

_______X__

X__O_X____

_X________

__X___X___

_________X

___X__X___

___X______

__XX______

Command 6

_____X____

_______X__

_______X__

X___OX____

_X________

__X___X___

_________X

___X__X___

___X______

__XX______

Command 7

_____X____

_______X__

_______X__

X____X____

_X__O_____

__X___X___

_________X

___X__X___

___X______

__XX______

Command 8

_____X____

_______X__

_______X__

X____X____

_X___O____

__X___X___

_________X

___X__X___

___X______

__XX______

Command 9

_____X____

_______X__

_______X__

X____X____

_X____O___

__X___X___

_________X

___X__X___

___X______

__XX______

Command 10

_____X____

_______X__

_______X__

X____X____

_X_____O__

__X___X___

_________X

___X__X___

___X______

__XX______

Command 11

_____X____

_______X__

_______X__

X____X____

_X______O_

__X___X___

_________X

___X__X___

___X______

__XX______

Command 12

_____X____

_______X__

_______X__

X____X____

_X________

__X___X_O_

_________X

___X__X___

___X______

__XX______

Command 13

_____X____

_______X__

_______X__

X____X____

_X________

__X___X___

________OX

___X__X___

___X______

__XX______

Command 14

_____X____

_______X__

_______X__

X____X____

_X________

__X___X___

_________X

___X__X_O_

___X______

__XX______

Command 15

_____X____

_______X__

_______X__

X____X____

_X________

__X___X___

_________X

___X__X___

___X____O_

__XX______

Command 16

_____X____

_______X__

_______X__

X____X____

_X________

__X___X___

_________X

___X__X___

___X______

__XX____O_

Command 17

_____X____

_______X__

_______X__

X____X____

_X________

__X___X___

_________X

___X__X___

___X______

__XX_____O

Simulation end

Quit? Enter "true" to quit or hit enter to run another simulation

True

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions