Code Monkey home page Code Monkey logo

bloxorz_sat's Introduction

SAT Solver to Solve Bloxorz Game

alt text

Description

Convert a "single-used tile" Bloxorz game, which is a NP-Complete problem [1] into a CNF formula, then use MiniSAT to check whether there exist a path from start node to the goal hole

Usage

   make 
   ./bloxorz <input map file>

Map generator

reference: Cellular Automata Method for Generating Random Cave-Like Levels

It adopt cellular automata to generate cave-like structures. First fille the map randomly. The basic rule is, a tile becomes a wall if it was a wall and 4 or more of its eight neighbors were walls, or if it was not a wall and 5 or more neighbors were. Put more succinctly, a tile is a wall if the 3x3 region centered on it contained at least 5 walls

generate map
To randomly generate a MxN map, with p% area being occupied, r1_cutoff, r2_cutoff, r iterations (the more iterations, the less noise), type

cd input
./mapGen M N r1_cutoff r2_cutoff r

1 represents tile, 0 represent boundary, for strat node (2) and end node 3, you need to add them in manual. For example, m1.in.

011110
110311
110111
010111
110111
000211

Result

Test cases
Maps are stores in ./input directory, 1 represents tiles, 2 represents start node, 3 represents goal hole, 0 represents boundaries.

Output results
Results are stored in ./output directory

Example
If it is SAT, it will also print out a possible paths and actions you should adapt

Result of m1.in

map boundary (_m, _n) = (6, 6), size = 26
starting index = (5, 3)
ending index   = (1, 3)

nodes size     = 78
moves size     = 312
unary var size = 2028

=====  Begin to solve  =====
==============================[MINISAT]===============================
| Conflicts |     ORIGINAL     |          LEARNT          | Progress |
|           | Clauses Literals | Clauses Literals  Lit/Cl |          |
======================================================================
|         6 |   21270    45150 |       3        8     2.7 |  0.000 % |
======================================================================
SAT

state U_5_3_S_0
                        step 0 : UP
state U_5_4_Ly_1
                        step 1 : LEFT
state U_4_4_Ly_2
                        step 2 : LEFT
state U_3_4_Ly_3
                        step 3 : LEFT
state U_2_4_Ly_4
                        step 4 : LEFT
state U_1_4_Ly_5
                        step 5 : DOWN
state  U_1_3_S_6

Total memory usage: 5980
Total time usage: 0.036443 s

Reference

[1] Van Der Zanden, Tom C., and Hans L. Bodlaender. "PSPACE-completeness of Bloxorz and of games with 2-buttons." arXiv preprint arXiv:1411.5951 (2014).
[2] Costa, Diogo M. "Computational complexity of games and puzzles." arXiv preprint arXiv:1807.04724 (2018).
[3] Zhou, Neng-Fa. "In pursuit of an efficient SAT encoding for the Hamiltonian cycle problem." International Conference on Principles and Practice of Constraint Programming. Springer, Cham, 2020

bloxorz_sat's People

Contributors

eddie6382 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.