Determine the best/most efficient algorithm to program

Assignment Help Basic Computer Science
Reference no: EM13738017

You are the owner of a new business idea called the Roomba!!! You are trying to determine the best/most efficient algorithm to program for your Roomba operation. You want the Roomba to not only clean the entire floor, but in the fastest time possible. Your Roomba can
only go left, right, up, and down from its current location. It has a battery life that we will simulate as a maximum number of moves. In addition, the Roomba can be placed on any spot on the floor.
Your program will take the name of a file, battery life, and starting position as command line arguments with the -f (filename), -b (battery), -v (moves before viewing), -r (starting row) and -c (starting column) options. a.out -f floorplan.txt -b 100 -r 0 -c 0 -v 1
Catch Exceptions with File I/O:
You will try to open the file for input, but if it is not present, then you must catch the exception and let the user know that he/she must supply a floor plan file in order to run the simulation. The file with the floor plan doesn't contain dimensions. It only contains the cells of floor and potential objects, indicated by 'f' or 'd' for floor (or dirty floor) and 'o' for object. For example:
f f f o
f f f o
o o f f
f f f f
For this Assignment, your floor doesn't need to have objects, it can just be a dirty floor that needs to be cleaned!
Use classes with a Template, "Is a", "Has a", and "Uses" relationship:
Here are the classes you need to have:
template <typename T>
class Room {
private:
Floor f;
T *obj; //obj could be a Roomba, Person, etc.
public:
//The functionality of a room is to view it, put
//objects in it, take objects out of it, etc.
...
void clean_room() {
if(obj!=NULL)
obj->clean_floor(f);
}
};
class Floor {
private:
vector < vector <char> > v;
int obj_row; //Holds an object's current row position
int obj_col; //Holds an object's current col position
public:
//The functionality of a floor is to create the floor
//plan, as well as determining if an object's
//position is at the edge of the room
...
};
class Roomba {
private:
int battery; //how many moves it can make
int total_moves; //total moves needed to clean
public:
//The Roomba needs to be able to clean a floor, and
//move left, right, up, down
...
};
class RandomRoomba : public Roomba {
private:
...
public:
...
};
class ...Roomba : public Roomba { //for first AI Roomba
class ...Roomba : public Roomba { //for second AI Roomba
You can decide the function names for each class and whether you need to define the Big Three for the class. However, you MUST have the class relationship, members, and functionality specified above. Be creative!!!
Simulate the Roomba:
Now, you need to simulate the Roomba cleaning the room. You know you have a Room with a Roomba that cleans a specific floor. It is your job in your simulation to find which Roomba can clean the room the fastest (or in the least amount of moves). Here is the simulation you need:
#include <iostream>
#include "./Room.hpp"
#include "./RandomRoomba.h"
...
using namespace std;
void choose_roomba(Room <Roomba> &r) {
int choice;
cout << "Which Roomba (1 - Random, 2 - ?, 3 - ?)? ";
cin >> choice;

if(choice == 1)
r.set_roomba(new RandomRoomba);
else if(choice ==2)
...
}
void simulate_roomba() {
Room <Roomba> r;

choose_roomba(r);
//More setup is needed for the Room
...
r.clean_room(); //Now clean it after everything is setup
...
}
int main(int argc, char *argv[]) {
simulate_roomba();
return 0;
}
Example output:
After running a program with the file and command line arguments provided below, your program simulation might look something like the output below. (This is a very smart random!)
a.out -f floorplan.txt -b 100 -r 0 -c 0 -v 1
Which Roomba (1 - Random, 2 - ?, 3 - ?)? 1
Beginning:
r f f f
f f f f
f f f f
Move 1:
c r f f
f f f f
f f f f
Move 2:
c c r f
f f f f
f f f f
Move 3:
c c c r
f f f f
f f f f
Move 4:
c c c c
f f f r
f f f f
Move 5:
c c c c
f f f c
f f f r
Move 6:
c c c c
f f f c
f f r c
Move 7:
c c c c
f f r c
f f c c
Move 8:
c c c c
f r c c
f f c c
Move 9:
c c c c
r c c c
f f c c
Move 10:
c c c c
c r c c
f f c c
Move 11:
c c c c
c c c c
f r c c
Move 12:
c c c c
c c c c
r c c c
Entire floor visited and cleaned in 12 moves!!!
Things to consider:
? You must keep the classes, members, and functionality specified in the design above. ? Your member variables in all classes must be private or protected for encapsulation rules. ? You must have your class definitions in a .h file and your implemented classes in .cpp files.
Your template class can have interface and implementation in a .hpp file. ? You must also have your main function in a simulate_roomba.cpp file, separated from the class implementations.
? Create a Makefile for you project.
(10 pts) Extra Credit to avoid objects:
After running a program with the file and command line arguments provided above, your program simulation might look something like the output below. (This is the best random ever!)
Which Roomba (1 - Random, 2 - ?, 3 - ?)? 1
Beginning:
r f f o
f f f o
o o f f
f f f f
Move 1:
c r f o
f f f o
o o f f
f f f f
Move 2:
c c r o
f f f o
o o f f
f f f f
Move 3:
c c c o
f f r o
o o f f
f f f f 
Move 4:
c c c o
f r c o
o o f f
f f f f
Move 5:
c c c o
r c c o
o o f f
f f f f
Move 6:
c c c o
c r c o
o o f f
f f f f
Move 7:
c c c o
c c r o
o o f f
f f f f
Move 8:
c c c o
c c c o
o o r f
f f f f
Move 9:
c c c o
c c c o
o o c r
f f f f
Move 10:
c c c o
c c c o
o o c c
f f f r 
Move 11:
c c c o
c c c o
o o c c
f f r c
Move 12:
c c c o
c c c o
o o c c
f r c c
Move 13:
c c c o
c c c o
o o c c
r c c c
Entire floor visited and cleaned in 13 moves!!! 

Reference no: EM13738017

Questions Cloud

Understand employee relations in organizations : The purpose of this assignment is to understand Employee Relations in organizations in the UAE context. The features, role, and challenges related to employee relations are examined.
Preferred storage method for vsphere : For this discussion, select your preferred storage method for vSphere and explain why this is your preferred method.•Is one storage method easier to configure and support than another? If so, which one do you feel is easier? Explain what separates th..
What is the p-value : Conduct a hypothesis test. Be sure to state H0 and HA. What is the p-value. What is your conclusion using a typical value for a
Describe two devices used for mechanical observation : Briefly discuss mechanical observation - What is it and why is it used? Describe two devices used for mechanical observation that do not require the respondent's direct participation.
Determine the best/most efficient algorithm to program : You are the owner of a new business idea called the Roomba!!! You are trying to determine the best/most efficient algorithm to program for your Roomba operation. You want the Roomba to not only clean the entire floor, but in the fastest time possible..
Problems are being solved through government action : Identify three policy problems and determine an appropriate indicator or index that would help determine whether each of the identified problems are being solved through government action. Justify your position on each. (Note: The box includes Wor..
Develop a training manual : In this assignment, you will develop a training manual that will be utilized for training new employees (certified medical administrative assistants [CMAAs]) who join the clinic.
Find the composition of the simple harmonic motion : Find the composition of the simple harmonic motion of the same period in the perpendicular directions
How did womens reactions to the panic : How did women's reactions to the Panic of 1819 differ from their reactions to the American Revolution, the Quasi-War with France, and the War of 1812? Why?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Assume an open addressing hash table

Assume an open addressing hash table, with a load balance α given. What is the expected number of probs needed when searching a key x that is in the table. Note that the development shown in class was for the case that x is not in the table.

  What purposes do cpus, memory and i-o devices

What purposes do CPUs, memory and I-O devices individually serve in a computer system

  Regardless of the value of the input k

Suppose the DES F function mapped every 32-bit input R, regardless of the value of  the input K,

  Compare and contrast roles and responsibilities it positions

Compare and contrast the roles and responsibilities of IT position.

  Derive from g1 10b + (a * (a + b000)) {build a tree}

1.      Given grammar G1 uses variables S, and T where alphabet T={+, ?, (, ), a, b,0, 1} with rules

  Compare iso-iec outline with nist documents

Compare the ISO/IEC 27001 outline with the NIST documents outlined in 'Management of Information Security' (by Michael E. Whitman, Herbert J. Mattord).

  A sharper image

Iain works on the Web development team for a prominent community college system in the Southwest part of the United States. He was assigned to create several new Web pages, most of which would include detailed images. These images would aid nav..

  Discuss the training and any other important details for

imagine you are a paralegal writing to your boss the supervising partner of the law firm. write a memorandum of no more

  Assigning value to last array of array list

Write a statement that assigns the value 160000 to the last element of the ArrayList salaryStep.

  What change management initiatives should km group have

What change management initiatives should the KM group have initiated at Infosys before attempting to develop and implement knowledge management at the company?

  Calculate and display running total of yesterday receipts

calculate and display the running total of yesterday's receipts. The program should use the method calculate-Charges to determine the charge for each customer.

  Give a polynomial-time algorithm for the following problem

Give a polynomial-time algorithm for the following problem. We are given a binary tree T = (V, E) with an even number of nodes, and a nonnegative weight on each edge.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd