Merge branch 'recursive'

master
Ondřej Hruška 5 years ago
commit 6a0a233671
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 16
      README.md
  2. 4
      index.html
  3. 1022
      script.js
  4. 20
      style.css

@ -94,7 +94,6 @@ or changed without updating this reference. Search for `SettingsStorage`.
```
{
log: 'info', // default log level
allowTemplateAugmenting: false, // sloppy mode
retryTemplate: 30, // retry attempts within one template
attemptTemplates: 50, // number of templates to try on failure
svgEffects: false, // fancy mode
@ -125,19 +124,20 @@ Algorithm Quirks
Every board must be solvable, otherwise it wouldn't be much of a game. Generating a valid board
turned out quite a bit more challenging than I thought. My algorithm is based in some heuristics
and good deal of luck.
and luck.
To make things more fun, besides the marble matching rules, the board must be laid out in one of
several pre-defined shapes of exactly 55 tiles. The algorithm can sometimes get itself into a dead
end while placing marbles on the board. I experimented with backtracking, but the current version
simply retries the whole thing with a different random seed. There are configurable retry limits
as a failsafe. If the given template fails many consecutive times, the algorithm opts to switch to
end while placing marbles on the board. After some experimentation I settled on a recursive algorithm
with a heuristic and backtracking. There are configurable retry limits and max recursion / retry
counter as a failsafe. If the given template fails many consecutive times, the algorithm opts to switch to
a different template. Some templates are harder than others, and some random seeds just seem to
have a problem.
A workaround I added is called Sloppy Mode. When the algorithm can't place a marble, it may choose
to add a new tile to the template, trying to keep the overall shape as tidy as possible. This may
hurt game difficulty, but is generally much faster than retrying over and over.
I added a few extra rules to the generation algorithm to make the boards harder: Vitae and Mors should not
appear as the first few marbles to remove, since they tend to eliminate any choice; and metals start a few
levels deeper still. This gives the player a lot more room to make a mistake in the beginning.
At least you can enjoy the Undo and Try Again buttons!
If you're curious about the inner workings, open dev tools and enable debug logging with the `debug=1`
GET parameter.

@ -8,7 +8,7 @@
<meta name="apple-mobile-web-app-capable" content="yes">
<title>Sigmar's Garden Online</title>
<link rel="stylesheet" href="style.css?cache=2019-12-10b">
<link rel="stylesheet" href="style.css?cache=2019-12-15">
<meta name="author" content="Ondřej Hruška">
<meta name="description" content="Play Sigmar's Garden online. Opus Magnum minigame re-implemented in JavaScript and SVG.">
@ -90,6 +90,6 @@
</div>
</div>
</div>
<script src="script.js?cache=2019-12-10b"></script>
<script src="script.js?cache=2019-12-15"></script>
</body>
</html>

File diff suppressed because it is too large Load Diff

@ -122,6 +122,24 @@ text {
stroke-width: 2px;
cursor: pointer;
}
.button-text.working,
.button-text.working:hover {
fill: #8d7761;
font-size: 26px;
opacity: 0;
}
.button-text.working {
transition: opacity linear 0.2s;
}
.cfg-no-anim .button-text.working {
transition: none;
}
.button-text.working.show {
opacity: 1;
}
.you-win {
font-size: 80px;
@ -160,6 +178,8 @@ text {
transform: translateY(1px);
}
.button-text.disabled,
.button-text.disabled:hover,
.button-text.disabled:active {

Loading…
Cancel
Save