// ========================================================================== int main(int argc, char *argv[]) { std::string filename; int rows = -1; int columns = -1; bool all_solutions = false; bool allow_rotations = false; HandleCommandLineArguments(argc, argv, filename, rows, columns, all_solutions, allow_rotations); // load in the tiles std::vector<Tile*> tiles; ParseInputFile(argc,argv,filename,tiles); //if no board dimension entered, set the columns to 1/2 the number of tiles //this assumes the solutions won't be a straight line, but saves a lot of work if (rows<1 && columns<1) { rows=tiles.size()/2; columns=tiles.size()/2; if (tiles.size()%2==1) rows++;columns++; } // confirm the specified board is large enough if (rows < 1 || columns < 1 || rows * columns < tiles.size()) { std::cerr << "ERROR: specified board is not large enough" << rows << "X" << columns << "=" << rows*columns << " " << tiles.size() << std::endl; usage(argc,argv); } Board board(rows,columns); std::vector<Location> locations;//creates the base vector and board,then runs the function FindSolutionDriver(board,tiles,locations,all_solutions,allow_rotations); // delete the tiles for (int t = 0; t < tiles.size(); t++) { delete tiles[t]; } }
// ========================================================================== int main(int argc, char *argv[]) { std::string filename; int rows = -1; int columns = -1; bool all_solutions = false; bool allow_rotations = false; HandleCommandLineArguments(argc, argv, filename, rows, columns, all_solutions, allow_rotations); // load in the tiles std::vector<Tile*> tiles; ParseInputFile(argc,argv,filename,tiles); // confirm the specified board is large enough if (rows < 1 || columns < 1 || rows * columns < tiles.size()) { std::cerr << "ERROR: specified board is not large enough" << rows << "X" << columns << "=" << rows*columns << " " << tiles.size() << std::endl; usage(argc,argv); } //for (int i = 0; i < 5; i++) { // generate a random tile layouts Board board(rows,columns); std::vector<Location> locations; //RandomlyPlaceTiles(board, tiles, locations); PrintPieces(board, tiles, locations, all_solutions, allow_rotations); // print the solution //std::cout << "probably-not-a-Solution: "; // for (int i = 0; i < locations.size(); i++) { // std::cout << locations[i]; // } // std::cout << std::endl; // print the ASCII art board representation //board.Print(); //std::cout << std::endl; //} // delete the tiles for (int t = 0; t < tiles.size(); t++) { delete tiles[t]; } }