Giter Site home page Giter Site logo

flip-side's Introduction

Flip-Side Puzzle

Flip-Side is a recent puzzle by Thinkfun. It consists of a frame containing 10 numbered blocks in two rows of five. In the centre of the frame is a turntable that holds 3 blocks from each row. When turned, the three blocks in the top row swap with the three blocks directly beneath them. Each row can slide left or right, so you can choose which three adjacent blocks in a row are flipped to the other row. The blocks are numbered, and the aim is of course to arrange them in numerical order after they have been mixed, i.e. 01234 on the top row, 56789 on the bottom row.

Image game

Flip-Side was invented by Ferdinand Lammertink, who also invented Topspin, Backspin, and Triple Cross. The puzzle's patent, US 2006/279041, was published 14 December 2006.

Game representation

We will represent the game-state as a bidimensional matrix where the empty spaces will be represented with the value -1. To implement this we use a numpy array.

For example, the winning state will be represented as:

np.array([[-1, 0, 1, 2, 3, 4, -1], 
          [-1, 5, 6, 7, 8, 9, -1]])

To make a game move we will use advanced numpy indexing. In the example shown below the movement of the top row to the right is shown.

i = np.array([[0, 0, 0, 0, 0, 0, 0],
                [1, 1, 1, 1, 1, 1, 1]])
j = np.array([[6, 0, 1, 2, 3, 4, 5],
                [0, 1, 2, 3, 4, 5, 6]])
new_game_state = game_state[(i, j)]

To see the other movement options you can see here

Usage

python3 brute_force.py -D 5

where D is the nested recursive level

The output will be a image with recusrsive tree (using D 7).

drawing

flip-side's People

Contributors

gtamayo avatar

Watchers

James Cloos avatar  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.