Giter Site home page Giter Site logo

grundy's Introduction

SOLVER FOR IMPARTIAL GAMES

The aim of this module is to implement a generic solver for impartial games like NIM.

Please refer to the links at the bottom of this page for some good lecture notes on the beautiful theory of impartial games.

For the purpose of this module, we need two results:

  1. Every game is equivalent to some NIM game. This relationship is given by the Grundy number (also called nimber) of the game. If G_1 to G_k are the games reachable from G, g(G) = mex({g(G_1),...,g(G_k)}) mex of a set of integers is defined to be the smallest non-negative integer not in that set.
  2. If G and H are two games, their sum G+H is defined as the game where the two games are to be played simultaneously, i.e., in her turn, the player will have to choose one of the games G or H and make one move in that game.

REMARKS

The code is very far from the goal of being a generic solver. I will get around to writing it when I have the time.

Right now, I have made a solver for a specific impartial game suggested by a friend.

N points are chosen around a circle. Now Bob and Alice play the following game: Alice draws a line connecting two of the points with a line segment. Bob and Alice move in turn, but the line segment cannot cross any of the previously drawn lines (the end points cannot even be reused). A player who cannot draw a suitable line loses.

USAGE

To play the game as Bob (computer plays first), do python player.py N where N is the number of points on the circle.

To see the first N grundy values of the game, do python circlegame.py

I have included windows 32 bit exectubles for player and circlegame in the dist directory.

P.S. I have no rights to distribute msvcm90.dll, msvcp90.dll, msvcr90.dll

REFERENCES

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.