Adds a replayed for the solutions
This commit is contained in:
parent
79f49893e4
commit
9e2c8f0c5c
1 changed files with 54 additions and 0 deletions
54
src/Replayer.cpp
Normal file
54
src/Replayer.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
#include "dynamic_grid.hpp"
|
||||
#include "analyzed_grid.hpp"
|
||||
#include "clusters.hpp"
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char** argv){
|
||||
namespace po = boost::program_options;
|
||||
|
||||
// Describe program options
|
||||
po::options_description opts;
|
||||
opts.add_options()
|
||||
("file", "level file to replay")
|
||||
("help", po::bool_switch(), "show this help");
|
||||
|
||||
po::positional_options_description file_opts;
|
||||
file_opts.add("file", 1);
|
||||
|
||||
// Parse and store them in a vm
|
||||
po::variables_map vm;
|
||||
po::store(po::command_line_parser(argc, argv).options(opts).positional(file_opts).run(), vm);
|
||||
po::notify(vm);
|
||||
|
||||
if(vm["help"].as<bool>()){
|
||||
std::cout << "Puzzle Wuzzle Replayer, version " << __DATE__ << std::endl;
|
||||
std::cout << opts << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::cout << "= The puzzle =\n";
|
||||
auto level = grid_from_file(vm["file"].as<std::string>());
|
||||
level.grid.print(std::cout);
|
||||
if(level.analysis.solution_traces.empty()){
|
||||
std::cout << "has no solutions\n";
|
||||
} else {
|
||||
std::cout << "has " << level.analysis.solution_traces.size() << " solutions\n\n";
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for(auto && solution : level.analysis.solution_traces){
|
||||
std::cout << "= Solution " << count++ << " =\n";
|
||||
|
||||
auto grid = level.grid;
|
||||
grid.print(std::cout);
|
||||
|
||||
for(auto && tap : solution){
|
||||
std::cout << "Tapping on " << tap.first << ", " << tap.second << " => \n";
|
||||
grid = make_empty(grid, cluster_at(grid, level.rules, tap));
|
||||
grid.print(std::cout);
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue