aboutsummaryrefslogtreecommitdiff
path: root/metasol.cpp
AgeCommit message (Collapse)AuthorLines
2019-04-03Add indefinite runningtrh/multirunTom Harley-23/+40
centre can now be run indefinitely, attempting to solve games incrementally, by passing it the -f flag.
2019-04-02Prepare for solvability calculationsTom Harley-32/+66
New fucntions have been implemented to allow for the integration into centre of the calculation of solvability percentages, through mass-solving games.
2019-02-25Skip to 'solved' when there are no hidden cardsTom Harley-2/+38
If a game-state can be solved by a voter from a position where there are no hidden cards, the game can be solved by metasol also. The rest of the game can be skipped, which saves time. If the sequence of moves taken is required, the remaining moves can be taken from a successful voter.
2019-02-25Check for majority moves after regular moveTom Harley-14/+10
Previously, majority moves were checked for before regular moves. This would usually result in time wasted after a reveal-reset.
2019-02-22Add documentation for metasol.hppTom Harley-19/+61
Adding doxygen documentation should help people understand the use for metasol.
2019-02-21Clean up rule description filesTom Harley-2/+27
The files for describing rules have changed a bit: they are no longer `.json` files (although they are still parsed by a JSON parser). The description files are now their own format, with a little less boilerplate required than for JSON files. As a result, rule description files can be given shebangs and be made executable, allowing a user to run the rule file instead of `centre` directly. The rules files in the repository are set up to run `centre` if it is on the user's path.
2019-02-19Add support for GolfTom Harley-2/+19
A few changes were needed to support Golf: `hole_build_loop` had to be implemented, as well as the `STOCK_TO_HOLE` stock deal method. The solver doesn't seem very good at Golf, although there may be a bug or missing rule causing this.
2019-02-18Add Will-o-the-wisp rules, reorganise main loopTom Harley-135/+153
Also, the solvability (and the solved-ness) of a game-state is not checked between majority-vote moves.
2019-02-17Reveal stock cards if stock redeals allowedTom Harley-0/+7
If stock redeals are allowed, then the player can go through the stock once at the start of the game and reset it, bringing the game back to the original game state. This allows the player to see all cards in the stock, even if the stock isn't explicitly face-up. This can be used to reduce the number of voters run, since the stock will not be hidden and fewer reveals means fewer full resets. As such, this optimisation seems to reduce solving time by roughly half. This optimisation also theoretically increases solvability percentages in affected games, since the system has fewer face-down cards to generate misleading permutations with.
2019-02-17Skip voting if majority already establishedTom Harley-39/+80
If there is a number of voters that agree on the next move that is a majority, then it is unnecessary to run more voters as they cannot affect the outcome.
2019-02-17Split Solvitaire k+ moves into stock movesTom Harley-63/+58
In Solvitaire, going through the stock in stock-waste games is bundled with the move out of the waste, in what's called a k-plus move. This makes sense in Solvitaire, but in this system having each stock move be explicit helps because it itemises all moves similarly, making shaving off single moves easy. The `calculate_stock_moves` function uses a simulation rather than a simple calculation, which has a couple of downsides: 1. it's slower than a calculation; 2. it loops infinitely when given an index that's impossible to reach.
2019-02-11Solve a Klondike dealTom Harley-49/+320
The solver can now solve a Klondike deal! Use seed 5 to generate a deal that seems to always be solvable.
2019-02-02Add support for non-diagonal dealsTom Harley-20/+25
Previously, if a game had a tableau but was not diagonal-deal, it would only place one card in each tableau. Now, all left over cards are dealt to each each tableau pile, evenly split.
2019-02-01Add support for reading rules from .json filesTom Harley-1/+144
Game rules can now be read from .json files passed as argument with `-r`/`--rules` on the command-line. The rules descriptions are built on top of sane default rules, so some rules can be omitted. Without a rules file specified, `centre` plays canfield.
2019-01-31Update submodulesTom Harley-23/+17
I promise it works this time
2019-01-29Add support for reading gamestates from json filesTom Harley-23/+22
Piles of cards can now be read from `.json` files using the `--game`/`-g` flag, although the solver doesn't seem to like them. Currently, cards mentioned in these files are all face-up, which means that they aren't particularly useful for building whole games and more just test cases. Also added command-line options parsing, including accepting randomisation seeds from the `--seed`/`-s` option.
2019-01-27Reorganise repoTom Harley-56/+163
All solvitaire content has been shoved into a subdirectory to tidy up the root of the project. This also means solvitaire is treated similarly to other dependencies of the project, and allows other dependencies to be added easily. There's also a lot of other work done here, such as usign a thread pool library to manage the running of the voters.
2019-01-24Split code into 3 filesTom Harley-796/+181
The code that used to reside in `metasol.cpp` has been split between `metasol.h`, `centre.cpp`, and the original file.
2019-01-24It works with fortune's favorTom Harley-0/+1119
It seems to be consistently running to completion successfully! It's been renamed to `metasol` for now, since that's a better name than `test`. Next step will probably be eliminating the namespace pollution in `metasol.cpp`.