Coder Social home page Coder Social logo

npuzzle's Introduction

NPuzzle

In the 16-puzzle version of the game, a 4x4 board consists of 15 tiles numbered 1 through 15 and an empty tile (marked as 0). One may move any tile into an orthogonally adjacent empty square, but maynot move outside the board or diagonally.The problem is to find a sequence of moves that transforms an initial board configuration into a specified goal configuration. The following are examples of an initial and goal configurations.

Initial configuration

initial

Goal configuration

goal

Algorithm

The mouse click is mapped to UP, DOWN, LEFT and RIGHT accordingly. Such as: 0 is in the tile of(2,3),if I click 11, 11 moves to the right.

goal

The method to move RIGHT like this:

def move( direction):
  ... ...
  if(direction == Direction.RIGHT): 
    if column_0 != 0:
      blocks[row_0][column_0] = blocks[row_0][column_0 - 1]
      blocks[row_0][column_0 - 1] = 0
      column_0 -= 1 

Make sure the final configuration can be reached

In initial state, make all the data according to the final configuration first. And then move the tiles in random direction with different rounds. The round decides the different Level :easy, medium or high.

Tool chain

  1. Python3
  2. tkinter

npuzzle's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

miloparigi

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.