Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <getopt.h>
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <deque>
- #include <map>
- #include <string.h>
- #include <iterator> // for std::begin, std::end
- using namespace std;
- //To Do, for some reason adding duplicate right at the end. Talk about how it works but for some reason duplicates coming and dont
- //know how to handle removing them in terms of time efficiency.
- pair<string, string> getOptions(int argc, char * argv[]) {
- opterr = true; // Give us help with errors
- int choice;
- int option_index = 0;
- option long_options[] = {
- { "help", no_argument, nullptr, 'h'},
- { "queue", no_argument, nullptr, 'q'},
- { "stack", no_argument, nullptr, 's'},
- { "output", required_argument, nullptr, 'o'},
- { nullptr, 0, nullptr, '\0' }
- };
- pair<string, string> args_val;
- while ((choice = getopt_long(argc, argv, "hqso:", long_options, &option_index)) != -1) {
- switch (choice) {
- case 'h':
- cout << "Help Printout \n";
- exit(1);
- break;
- case 'q':
- //Error Handling
- if (args_val.first != "") {
- cerr << "Error";
- exit(1);
- }
- args_val.first = "queue";
- break;
- case 's':
- //Error Handling
- if (args_val.second != "") {
- cerr << "Error";
- exit(1);
- }
- args_val.first = "stack";
- break;
- case 'o':
- if (strcmp(optarg, "list") == 0)
- args_val.second = "list";
- if (strcmp(optarg, "map") == 0)
- args_val.second = "map";
- break;
- default:
- cerr << "Error";
- exit(1);
- } // switch
- } // while
- //Error Handling
- if (args_val.second == "")
- args_val.second = "list";
- return args_val;
- } // getOptions()
- struct objState {
- char color;
- int row;
- int col;
- objState()
- :color('^'), row(-1), col(-1) {}
- objState(char color_in, int row_in, int col_in)
- :color(color_in), row(row_in), col(col_in) {}
- };
- struct Tiles {
- char value;
- bool visited;
- //bool planned_visit = false; // Idea!
- Tiles()
- : value('0'), visited(false) {}
- Tiles(char val, bool visit)
- : value(val), visited(visit) {}
- };
- map<char, int> mapOfButtons = {
- {'^',0},{'A',1}, {'B',2},{'C',3},{'D',4},{'E',5},{'F',6},{'G',7},{'H',8},{'I',9},{'J',10},{'K',11},{'L',12},{'M',13},{'N',14},{'O',15},{'P',16},{'Q',17},{'R',18},{'S',19},{'T',20},{'U',21},{'V',22},{'W',23},{'X',24},{'Y',25},{'Z',26},{'@',27}
- };
- map<int, char> mapOfButtonsReverse = {
- {0,'^'},{1,'A'}, {2,'B'},{3,'C'},{4,'D'},{5,'E'},{6,'F'},{7,'G'},{8,'H'},{9,'I'},{10,'J'},{11,'K'},{12,'L'},{13,'M'},{14,'N'},{15,'O'},{16,'P'},{17,'Q'},{18,'R'},{19,'S'},{20,'T'},{21,'U'},{22,'V'},{23,'W'},{24,'X'},{25,'Y'},{26,'Z'},{27,'@'}
- };
- char validInputs[] = { '.','^','@','?','#','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','t','U','V','W','X','Y','Z' };
- /*
- struct trackingState {
- int row;
- int col;
- trackingState()
- :row(-1), col(-1) {}
- trackingState(int row_in, int col_in)
- : row(row_in), col(col_in){}
- };
- */
- //Gonna need to fix the ^ version of saving the direction_vec with numbers likely need to set that number to 0!
- deque<objState> backTracking(objState &end, vector<vector<vector<string>>> &tracking_vec) {
- deque<objState> backtracking_collection;//TREAT THIS AS A STACK!!!
- backtracking_collection.push_back(end);
- while (true) {
- if (tracking_vec[mapOfButtons.find(end.color)->second][end.row][end.col] == "N") {
- backtracking_collection.push_back(objState(end.color, end.row - 1, end.col));
- end.row = end.row - 1;
- }
- else if (tracking_vec[mapOfButtons.find(end.color)->second][end.row][end.col] == "E") {
- backtracking_collection.push_back(objState(end.color, end.row, end.col + 1));
- end.col = end.col + 1;
- }
- else if (tracking_vec[mapOfButtons.find(end.color)->second][end.row][end.col] == "W") {
- backtracking_collection.push_back(objState(end.color, end.row, end.col - 1));
- end.col = end.col - 1;
- }
- else if (tracking_vec[mapOfButtons.find(end.color)->second][end.row][end.col] == "S") {
- backtracking_collection.push_back(objState(end.color, end.row + 1, end.col));
- end.row = end.row + 1;
- }
- else if (tracking_vec[mapOfButtons.find(end.color)->second][end.row][end.col] == "-1") {
- return backtracking_collection;
- }
- else {
- end.color = mapOfButtonsReverse[stoi((tracking_vec[mapOfButtons.find(end.color)->second][end.row][end.col]))];
- backtracking_collection.push_back(objState(end.color, end.row, end.col));
- }
- }
- return backtracking_collection;
- }
- void listOutput(deque<objState> &backtracking_collection) {
- while (!backtracking_collection.empty()) {
- cout << "(" << (char)tolower(backtracking_collection.back().color) << ", " << "(" << backtracking_collection.back().row << ", " << backtracking_collection.back().col << "))\n";
- backtracking_collection.pop_back();
- }
- }
- void mapOutput(vector<vector<vector<Tiles>>> &puzzle, deque<objState> &backtracking_collection) {
- objState current_state;
- while (backtracking_collection.size() > 1) {
- current_state = backtracking_collection.back();
- backtracking_collection.pop_back();
- //if colors same use +
- if (current_state.color == backtracking_collection.back().color) {
- puzzle[mapOfButtons.find(current_state.color)->second][backtracking_collection.back().row][backtracking_collection.back().col].value = '+';
- }
- else if (current_state.color != backtracking_collection.back().color) {
- puzzle[mapOfButtons.find(current_state.color)->second][backtracking_collection.back().row][backtracking_collection.back().col].value = '%';
- puzzle[mapOfButtons.find(backtracking_collection.back().color)->second][backtracking_collection.back().row][backtracking_collection.back().col].value = '@';
- backtracking_collection.pop_back();
- }
- }
- for (unsigned z = 0; z < puzzle.size(); ++z) {
- for (unsigned i = 0; i < puzzle[z].size(); ++i) {
- for (unsigned j = 0; j < puzzle[z][i].size(); ++j) {
- if (mapOfButtonsReverse.find(z)->second == toupper(puzzle[z][i][j].value))
- puzzle[z][i][j].value = '.';
- }
- }
- }
- }
- bool checkNorth(vector<vector<vector<Tiles>>> &puzzle, deque<objState> &reachable_collection, objState ¤t_state, vector<vector<vector<string>>> &tracking_vec) {
- //Check for edge of map, wall, and been their before. NORTH
- if (current_state.row - 1 >= 0
- && (puzzle[mapOfButtons.find(current_state.color)->second][current_state.row - 1][current_state.col].value != '#')) {
- //Handling if not a free space (.)
- char northVal = puzzle[mapOfButtons.find(current_state.color)->second][current_state.row - 1][current_state.col].value;
- if (northVal != '.' && northVal != '^'&& northVal != '@') {
- if (northVal == '?') {
- reachable_collection.push_back(objState(current_state.color, current_state.row - 1, current_state.col));
- cout << "Found";
- return true;
- }
- //If current color != tile about to try to reach and not UpperCase letter, make new color
- if (current_state.color != northVal && mapOfButtons.find(northVal) == mapOfButtons.end()) {
- if (puzzle[mapOfButtons.find((char)toupper(northVal))->second][current_state.row - 1][current_state.col].visited == false && puzzle[mapOfButtons.find(current_state.color)->second][current_state.row - 1][current_state.col].visited == false) {
- reachable_collection.push_back(objState((char)toupper(northVal), current_state.row - 1, current_state.col));
- puzzle[mapOfButtons.find(current_state.color)->second][current_state.row - 1][current_state.col].visited = true;
- tracking_vec[mapOfButtons.find(current_state.color)->second][current_state.row - 1][current_state.col] = 'S';
- tracking_vec[mapOfButtons.find((char)toupper(northVal))->second][current_state.row - 1][current_state.col] = to_string((int)mapOfButtons.find(current_state.color)->second);
- }
- }
- //If not # and . but UpperCase and same as current color
- else if (northVal == current_state.color && northVal != '^') {
- if (puzzle[mapOfButtons.find((char)toupper(northVal))->second][current_state.row - 1][current_state.col].visited == false) {
- reachable_collection.push_back(objState((char)toupper(northVal), current_state.row - 1, current_state.col));
- puzzle[mapOfButtons.find((char)toupper(northVal))->second][current_state.row - 1][current_state.col].visited = true;
- tracking_vec[mapOfButtons.find(current_state.color)->second][current_state.row - 1][current_state.col] = 'S';
- }
- }
- }
- //Handling if free space (.)
- else {
- if (puzzle[mapOfButtons.find(current_state.color)->second][current_state.row - 1][current_state.col].visited == false) {
- if (northVal == '^') {
- reachable_collection.push_back(objState('^', current_state.row - 1, current_state.col));
- puzzle[0][current_state.row - 1][current_state.col].visited = true;
- if (tracking_vec[0][current_state.row - 1][current_state.col] == "-1") {
- tracking_vec[0][current_state.row - 1][current_state.col] = to_string((int)mapOfButtons.find(current_state.color)->second); // Ground floor set to where at currently
- tracking_vec[mapOfButtons.find(current_state.color)->second][current_state.row - 1][current_state.col] = 'S';
- }
- }
- else {
- reachable_collection.push_back(objState(current_state.color, current_state.row - 1, current_state.col));
- puzzle[mapOfButtons.find(current_state.color)->second][current_state.row - 1][current_state.col].visited = true;
- tracking_vec[mapOfButtons.find(current_state.color)->second][current_state.row - 1][current_state.col] = 'S';
- }
- }
- }
- }// //Check for edge of map, wall, and been their before. NORTH
- return false;
- }
- bool checkEast(vector<vector<vector<Tiles>>> &puzzle, deque<objState> &reachable_collection, objState ¤t_state, int cols, vector<vector<vector<string>>> &tracking_vec) {
- //Check for edge of map, wall, and been their before. EAST
- if (current_state.col + 1 < cols // DOUBLE CHECK THIS LINE
- && (puzzle[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col + 1].value != '#')) {
- //Handling if not a free space (.)
- char northVal = puzzle[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col + 1].value;
- if (northVal != '.' && northVal != '^' && northVal != '@') {
- if (northVal == '?') {
- reachable_collection.push_back(objState(current_state.color, current_state.row, current_state.col + 1));
- cout << "Found";
- return true;
- }
- //If current color != tile about to try to reach and not UpperCase letter, make new color
- if (current_state.color != northVal && mapOfButtons.find(northVal) == mapOfButtons.end()) {
- if (puzzle[mapOfButtons.find((char)toupper(northVal))->second][current_state.row][current_state.col + 1].visited == false && puzzle[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col + 1].visited == false) {
- reachable_collection.push_back(objState((char)toupper(northVal), current_state.row, current_state.col + 1));
- puzzle[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col + 1].visited = true;
- tracking_vec[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col + 1] = 'W';
- tracking_vec[mapOfButtons.find((char)toupper(northVal))->second][current_state.row][current_state.col + 1] = to_string((int)mapOfButtons.find(current_state.color)->second);
- }
- }
- //If not # and . but UpperCase and same as current color
- else if (northVal == current_state.color && northVal != '^') {
- if (puzzle[mapOfButtons.find((char)toupper(northVal))->second][current_state.row][current_state.col + 1].visited == false) {
- reachable_collection.push_back(objState((char)toupper(northVal), current_state.row, current_state.col + 1));
- puzzle[mapOfButtons.find((char)toupper(northVal))->second][current_state.row][current_state.col + 1].visited = true;
- tracking_vec[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col + 1] = 'W';
- }
- }
- }
- //Handling if free space (.)
- else {
- if (puzzle[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col + 1].visited == false) {
- if (northVal == '^') {
- reachable_collection.push_back(objState('^', current_state.row, current_state.col + 1));
- puzzle[0][current_state.row][current_state.col + 1].visited = true;
- if (tracking_vec[0][current_state.row][current_state.col + 1] == "-1") {
- tracking_vec[0][current_state.row][current_state.col + 1] = to_string((int)mapOfButtons.find(current_state.color)->second); // Ground floor set to where at currently
- tracking_vec[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col + 1] = 'W';
- }
- }
- else {
- reachable_collection.push_back(objState(current_state.color, current_state.row, current_state.col + 1));
- puzzle[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col + 1].visited = true;
- tracking_vec[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col + 1] = 'W';
- }
- }
- }
- }// //Check for edge of map, wall, and been their before. EAST
- return false;
- }
- bool checkSouth(vector<vector<vector<Tiles>>> &puzzle, deque<objState> &reachable_collection, objState ¤t_state, int rows, vector<vector<vector<string>>> &tracking_vec) {
- //Check for edge of map, wall, and been their before. South
- if (current_state.row + 1 < rows
- && (puzzle[mapOfButtons.find(current_state.color)->second][current_state.row + 1][current_state.col].value != '#')) {
- //Handling if not a free space (.)
- char northVal = puzzle[mapOfButtons.find(current_state.color)->second][current_state.row + 1][current_state.col].value;
- if (northVal != '.' && northVal != '^'&& northVal != '@') {
- if (northVal == '?') {
- reachable_collection.push_back(objState(current_state.color, current_state.row + 1, current_state.col));
- cout << "Found";
- return true;
- }
- //If current color != tile about to try to reach and not UpperCase letter, make new color
- if (current_state.color != northVal && mapOfButtons.find(northVal) == mapOfButtons.end()) {
- if (puzzle[mapOfButtons.find((char)toupper(northVal))->second][current_state.row + 1][current_state.col].visited == false && puzzle[mapOfButtons.find(current_state.color)->second][current_state.row + 1][current_state.col].visited == false) {
- reachable_collection.push_back(objState((char)toupper(northVal), current_state.row + 1, current_state.col));
- puzzle[mapOfButtons.find(current_state.color)->second][current_state.row + 1][current_state.col].visited = true;
- tracking_vec[mapOfButtons.find(current_state.color)->second][current_state.row + 1][current_state.col] = 'N';
- tracking_vec[mapOfButtons.find((char)toupper(northVal))->second][current_state.row + 1][current_state.col] = to_string((int)mapOfButtons.find(current_state.color)->second); // Handling level for output
- }
- }
- //If not # and . but UpperCase and same as current color
- else if (northVal == current_state.color && northVal != '^') {
- if (puzzle[mapOfButtons.find((char)toupper(northVal))->second][current_state.row + 1][current_state.col].visited == false) {
- reachable_collection.push_back(objState((char)toupper(northVal), current_state.row + 1, current_state.col));
- puzzle[mapOfButtons.find((char)toupper(northVal))->second][current_state.row + 1][current_state.col].visited = true;
- tracking_vec[mapOfButtons.find(current_state.color)->second][current_state.row + 1][current_state.col] = 'N';
- }
- }
- }
- //Handling if free space (.)
- else {
- if (puzzle[mapOfButtons.find(current_state.color)->second][current_state.row + 1][current_state.col].visited == false) {
- if (northVal == '^') {
- reachable_collection.push_back(objState('^', current_state.row + 1, current_state.col));
- puzzle[0][current_state.row + 1][current_state.col].visited = true;
- if (tracking_vec[0][current_state.row + 1][current_state.col] == "-1") {
- tracking_vec[0][current_state.row + 1][current_state.col] = to_string((int)mapOfButtons.find(current_state.color)->second); // Ground floor set to where at currently
- tracking_vec[mapOfButtons.find(current_state.color)->second][current_state.row + 1][current_state.col] = 'N';//Came from B will make jump to B floor
- }
- }
- else {
- reachable_collection.push_back(objState(current_state.color, current_state.row + 1, current_state.col));
- puzzle[mapOfButtons.find(current_state.color)->second][current_state.row + 1][current_state.col].visited = true;
- tracking_vec[mapOfButtons.find(current_state.color)->second][current_state.row + 1][current_state.col] = 'N';
- }
- }
- }
- }// //Check for edge of map, wall, and been their before. SOUTH
- return false;
- }
- bool checkWest(vector<vector<vector<Tiles>>> &puzzle, deque<objState> &reachable_collection, objState ¤t_state, vector<vector<vector<string>>> &tracking_vec) {
- //Check for edge of map, wall, and been their before. West
- if (current_state.col - 1 >= 0 // DOUBLE CHECK THIS LINE
- && (puzzle[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col - 1].value != '#')) {
- //Handling if not a free space (.)
- char northVal = puzzle[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col - 1].value;
- if (northVal != '.' && northVal != '^'&& northVal != '@') {
- if (northVal == '?') {
- reachable_collection.push_back(objState(current_state.color, current_state.row, current_state.col - 1));
- cout << "Found";
- return true;
- }
- //If current color != tile about to try to reach and not UpperCase letter, make new color
- if (current_state.color != northVal && mapOfButtons.find(northVal) == mapOfButtons.end()) {
- if (puzzle[mapOfButtons.find((char)toupper(northVal))->second][current_state.row][current_state.col - 1].visited == false && puzzle[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col - 1].visited == false) {
- reachable_collection.push_back(objState((char)toupper(northVal), current_state.row, current_state.col - 1));
- puzzle[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col - 1].visited = true;
- tracking_vec[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col - 1] = 'E';
- tracking_vec[mapOfButtons.find((char)toupper(northVal))->second][current_state.row][current_state.col - 1] = to_string((int)mapOfButtons.find(current_state.color)->second);
- }
- }
- //If not # and . but UpperCase and same as current color
- else if (northVal == current_state.color && northVal != '^') {
- if (puzzle[mapOfButtons.find((char)toupper(northVal))->second][current_state.row][current_state.col - 1].visited == false) {
- reachable_collection.push_back(objState((char)toupper(northVal), current_state.row, current_state.col - 1));
- puzzle[mapOfButtons.find((char)toupper(northVal))->second][current_state.row][current_state.col - 1].visited = true;
- tracking_vec[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col - 1] = 'E';
- }
- }
- }
- //Handling if free space (.)
- else {
- if (puzzle[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col - 1].visited == false) {
- if (northVal == '^') {
- reachable_collection.push_back(objState('^', current_state.row, current_state.col - 1));
- puzzle[0][current_state.row][current_state.col - 1].visited = true;
- if (tracking_vec[0][current_state.row][current_state.col - 1] == "-1") {
- tracking_vec[0][current_state.row][current_state.col - 1] = to_string((int)mapOfButtons.find(current_state.color)->second); // Ground floor set to where at currently
- tracking_vec[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col - 1] = 'E';
- }
- }
- else {
- reachable_collection.push_back(objState(current_state.color, current_state.row, current_state.col - 1));
- puzzle[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col - 1].visited = true;
- tracking_vec[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col - 1] = 'E';
- }
- }
- }
- }// //Check for edge of map, wall, and been their before. WEST
- return false;
- }
- int main(int argc, char *argv[]) {
- ios_base::sync_with_stdio(false);
- //Getting Command Line Stuff
- std::pair<string, string> optionQorS = getOptions(argc, argv);
- if (optionQorS.first == "" || optionQorS.second == "") {
- cerr << "Error";
- exit(1);
- }
- //Reading in first line
- int colors;
- cin >> colors;
- int rows;
- cin >> rows;
- int cols;
- cin >> cols;
- //Error checking
- if (colors < 0 || colors > 26) {
- cerr << "Error";
- exit(1);
- }
- if (rows < 1 || cols < 1) {
- cerr << "Error";
- exit(1);
- }
- //Reading in Rest lines
- string val;
- vector<vector<vector<Tiles>>> puzzle(colors + 1, vector<vector<Tiles>>(rows, vector<Tiles>(cols)));
- vector<vector<vector<string>>> direction_vec(colors + 1, vector<vector<string>>(rows, vector<string>(cols, "-1")));
- //cin.ignore();
- string ignore;
- getline(cin, ignore);
- int row_num = 0;
- while (getline(cin, val)) {
- if (val[0] != '/') {
- for (int i = 0; i < cols; ++i) {
- for (int abc = 0; abc < colors + 1; ++abc) {
- //Error checking No invalid characters appear in the map (for example, '+' can’t appear in the map, but it could appear in a comment)
- if (std::find(std::begin(validInputs), std::end(validInputs), val[i]) == std::end(validInputs)) {
- cerr << "Error";
- exit(1);
- }
- //● No invalid door or button appears in the map (for example, if num_colors is 3, then 'z' is invalid)
- if (mapOfButtons.find((val[i])) != mapOfButtons.end()) {
- if (mapOfButtons.find(val[i])->second > colors) {
- cerr << "Error";
- exit(1);
- }
- }
- puzzle[abc][row_num][i] = Tiles(val[i], false);
- }
- }
- row_num++;
- }
- if (row_num == rows)
- break;
- }
- deque<objState> reachable_collection;
- objState startLocation;
- objState endLocation;
- //Find starting position and put that into dequ as current state
- for (int i = 0; i < rows; ++i) {
- for (int j = 0; j < cols; ++j) {
- if (puzzle[0][i][j].value == '@') {
- reachable_collection.push_back(objState('^', i, j));
- startLocation = objState('^', i, j);
- break;
- }
- }
- }
- //Find more reachable states now from this original starting position.
- while (true) {
- if (reachable_collection.empty()) {
- cout << "No solution";
- return 0;
- }
- objState current_state;
- //Stack Mode
- if (optionQorS.first == "stack") {
- current_state = reachable_collection.back();
- reachable_collection.pop_back();
- }
- //Queue Mode
- if (optionQorS.first == "queue")
- current_state = reachable_collection.front();
- puzzle[mapOfButtons.find(current_state.color)->second][current_state.row][current_state.col].visited = true;
- if (checkNorth(puzzle, reachable_collection, current_state, direction_vec)) {
- endLocation = reachable_collection.back();
- direction_vec[mapOfButtons.find(endLocation.color)->second][endLocation.row][endLocation.col] = "S";
- break;
- }
- if (checkEast(puzzle, reachable_collection, current_state, cols, direction_vec)) {
- endLocation = reachable_collection.back();
- direction_vec[mapOfButtons.find(endLocation.color)->second][endLocation.row][endLocation.col] = "W";
- break;
- }
- if (checkSouth(puzzle, reachable_collection, current_state, rows, direction_vec)) {
- endLocation = reachable_collection.back();
- direction_vec[mapOfButtons.find(endLocation.color)->second][endLocation.row][endLocation.col] = "N";
- break;
- }
- if (checkWest(puzzle, reachable_collection, current_state, direction_vec)) {
- endLocation = reachable_collection.back();
- direction_vec[mapOfButtons.find(endLocation.color)->second][endLocation.row][endLocation.col] = "E";
- break;
- }
- //Queue mode
- if (optionQorS.first == "q" || "queue")
- reachable_collection.pop_front();
- }//While loop
- cout << "\n";
- /*
- for (int z = 0; z < colors + 1; ++z) {
- for (int i = 0; i < rows; ++i) {
- for (int j = 0; j < cols; ++j) {
- cout << direction_vec[z][i][j] << " ";
- if (direction_vec[z][i][j] != "-1")
- cout << " ";
- }
- cout << " " << i << " \n";
- }
- cout << "\n\n";
- }
- */
- deque<objState> tracking_collection = backTracking(endLocation, direction_vec);
- listOutput(tracking_collection);
- /*mapOutput(puzzle, tracking_collection);
- for (int z = 0; z < colors + 1; ++z) {
- for (int i = 0; i < rows; ++i) {
- for (int j = 0; j < cols; ++j) {
- cout << puzzle[z][i][j].value;
- }
- cout << " \n";
- }
- cout << "\n\n";
- }
- */
- return 0;
- }
- /*
- //Direction we got it from,
- sofor back tracking, i came from S N W E
- I came here from carrot color
- could make predisesor const to make sure all good
- USE STACK FOR LIST OUTPUT!!! OR VECTOR STACK PREF NO QUEUQ
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement