/Multi-Balance-Puzzle

Implementation of a solver for MultiBalance Puzzle in Prolog language, The Multi-Balance puzzle was created by Erich Friedman. It is a two-dimensional board game where the player must place sequential digits from 1 to N (determined at the beginning of the game) on the board, these digits must be placed in a way that all rules are satisfied. This project solves this constraint-driven problem using Constraint Logic Programming (CLP) class of programming languages.

Primary LanguageProlog

Multi-Balance Puzzle

How to use

Windows

  • Execute spwin.exe
  • File -> Consult... -> Select file multiBalance.pl
  • On SicStus' console insert the command: play.

Linux

  • Execute SicStus Prolog
  • File -> Consult... -> Select file multiBalance.pl
  • On SicStus' console insert the command: play.

Interface

             __  __       _ _   _
            |  \/  |     | | | (_)        
            | \  / |_   _| | |_ _      
            | |\/| | | | | | __| | 
            | |  | | |_| | | |_| |      
            |_|  |_|\__,_|_|\__|_|
     ____        _
    |  _ \      | | 
    | |_) | __ _| | __ _ _ __   ___ ___     
    |  _ < / _` | |/ _` | \_ \ / __/ _ \
    | |_) | (_| | | (_| | | | | (_|  __/
    |____/ \__,_|_|\__,_|_| |_|\___\___|


Insert the puzzle number to be solved (1-4).

The interface is for choosing between the 4 implemented puzzles, after choosing the program solves the puzzle and displays the solution, as there are only one possible solution per puzzle, the time for solving varies, some are fast and some take a long a time.

Here are the available puzzles:

                        Puzzle 1

            --------------------------------
            |   |   |   |   |   |   | ▇ |   |   
            --------------------------------
            |   |   |   | ▇ |   |   |   |   |           
            --------------------------------             Columns:  8
            | ▇ |   |   |   |   |   |   | ▇ |           
            --------------------------------             Rows:     6
            |   |   |   |   |   |   |   |   |           
            --------------------------------             Digits:   6
            |   |   |   |   |   |   |   |   |
            --------------------------------
            |   |   |   |   |   | ▇ |   |   |
            --------------------------------
                        Puzzle 2

            ----------------------------
            |   |   |   |   | ▇ |   |   |
            ----------------------------
            |   |   |   |   | ▇ |   |   |
            ----------------------------                 Columns:  7
            | ▇ |   |   |   |   |   | ▇ |
            ----------------------------                 Rows:     6
            |   |   |   |   |   |   |   |
            ----------------------------                 Digits:   8
            |   | ▇ |   |   |   |   |   |
            ----------------------------
            |   |   |   | ▇ |   |   |   |
            ----------------------------
                        Puzzle 3

        ----------------------------------------
        |   |   |   |   |   | ▇ |   |   |   |   |
        ----------------------------------------         Columns:  10
        |   |   |   |   |   | ▇ |   |   |   |   |
        ----------------------------------------         Rows:     4
        | ▇ |   |   |   |   |   |   | ▇ |   | ▇ |
        ----------------------------------------         Digits:   7
        |   |   |   |   |   | ▇ |   |   |   |   |
        ----------------------------------------
                        Puzzle 4

    ------------------------------------------------
    |   |   |   |   |   |   |   |   |   | ▇ |   |   |
    ------------------------------------------------
    |   |   |   |   |   |   |   |   |   |   |   |   |
    ------------------------------------------------
    |   |   |   | ▇ |   |   |   |   |   |   |   |   |
    ------------------------------------------------     Columns:  12
    |   | ▇ |   |   |   |   |   |   |   |   |   |   |
    ------------------------------------------------     Rows:     9
    |   |   |   |   |   |   |   |   |   |   |   |   |
    ------------------------------------------------     Digits:   6
    |   |   |   |   |   |   |   |   |   |   |   | ▇ |
    ------------------------------------------------
    | ▇ |   |   |   |   |   |   |   |   |   |   |   |
    ------------------------------------------------
    |   |   |   |   |   |   |   |   |   |   |   |   |
    ------------------------------------------------
    |   |   |   |   |   | ▇ |   |   |   |   |   |   |
    ------------------------------------------------