The simplest example of inference use is connecting 2 points with a path. In other words, inference connects 2 given states (or partially observed states) with a chain of rewrite rules. Probabilistic inference in MarkovJunior allows to impose constraints on the future state, and generate only those runs that lead to the constrained future. Like in REFAL, Markov nodes can be nested: once we go into a child node, we ignore outer nodes until the child branch completes. Dungeons without cycles are pretty boring, since the player has to return through already explored zones. Make some additional connections (GBG=*W* #5), so the resulting dungeon has cycles.For example, inference in Sokoban rules (GBW=*WG)). Interpreter stops when there are no matches for any rule. Then it can apply the first rule again, and so on. At this point the first rule has no matches, so interpreter applies the second rule RGG=WWR until the walk gets unstuck. But eventually the green self-avoiding walk gets stuck. In the maze backtracker example, interpreter first applies a bunch of RBB=GGR rules.
![magicavoxel dead grass magicavoxel dead grass](https://www.masterlawninc.com/hs-fs/hubfs/Images/Stock%20Images/lawn-care-memphis-tn-lamp-dead-grass.jpg)
On each execution step MJ interpreter finds the first rule in the list that has a match on the grid, finds all matches for that rule and applies that rule for a random match.
![magicavoxel dead grass magicavoxel dead grass](https://empire-s3-production.bobvila.com/articles/wp-content/uploads/2021/03/Dead-Grass-650x433.jpg)
RGG=WWR or "replace red-green-green with white-white-red".
![magicavoxel dead grass magicavoxel dead grass](https://www.goodtextures.com/cache/31b380e7/ave9e86ac86ec200872bb.jpg)