Giter VIP home page Giter VIP logo

dots-and-boxes's Introduction

Dots And Boxes

Build Status License: GPL

🎲 Online preview: HERE

Pencil-and-paper game for two players.

Description

The game starts with an empty grid of dots. Usually two players take turns adding a single horizontal or vertical line between two unjoined adjacent dots. A player who completes the fourth side of a 1×1 box earns one point and takes another turn. (A point is typically recorded by placing a mark that identifies the player in the box, such as an initial.) The game ends when no more lines can be placed. The winner is the player with the most points. The board may be of any size grid. When short on time, or to learn the game, a 2×2 board (3×3 dots) is suitable. A 5×5 board, on the other hand, is good for experts.

Screenshot

Sources

In this project, artificial intelligence was supported by DLV.
DLV is an Answer Set Programming system, based on disjunctive logic programming, which offers front-ends to several advanced KR formalisms. The system supports a language based on a logical formalisms with a very high expressive power so that programs are able to represent relevant practical problems in presence of incomplete or contradictory knowledge.

Notable sources are:

  • Player Agent, asp/player.asp AI for calculate next move to get best score.
  • Phase Detector, asp/phase.asp detect and store status about current phase game.
  • Chains/Cycles Detector, asp/chain.asp detect all chains and cycle inside the current board state.

Build

To run Dots And Boxes, execute the following command:

$ make init
$ make run-server & 
$ make run

NOTE: Building and running require Python 3.x.x or greater.

Run

Open your web browser on http://localhost:8080 after successful build.

Third-Party Software

Dots And Boxes uses and depends on third-party open-source tools and libraries which are outside of this repository.

License

Copyright (c) Mantik. All rights reserved.

Licensed under the GPL-3.0 license.

dots-and-boxes's People

Contributors

kwrx avatar nottyche avatar

Watchers

 avatar

dots-and-boxes's Issues

[IA] Fase 2: Chiudi partendo dalle short chain più piccole

Short Chain Rule

This helps you how to count who gets the most short chains duing the short chain phase of the game. It says:

Short Chain Rule: The player who has lost the chain fight (the first player forced to move into a chain) will get at least as many short chains as his opponent during the short chain phase of the game.

In other words, if you have been forced to first move into a long chain, then you will either tie or get more boxes during the short chain phase.

  • The short chain rule also says that you should count points in short chains backwards from the largest to the smallest.
  • The short chain rule also implies the zero rule dealing with the case when there are no chains or cycles.
  • The short chain rule is a simple consequence of the chain rule

[IA] Fase 1: Valutare come spezzare una catena

The chain rule tells you how many chains you should make to force your opponent to open the first long chain or cycle:

  • If there is an odd total number of dots, then the first player (Yellow) should make an odd number of chains and the second player (Green) an even number of chains.

  • If there is an even number of total dots, then the first player should make an even number of chains and the second player an odd number of chains.

For the usual board sizes, this gives:

  • 3x3 dots (2x2 boxes): First player odd number of chains, second player even number of chains.
  • 5x5 dots (4x4 boxes): First player odd number of chains, second player even number of chains.
  • 6x6 dots (5x5 boxes): First player even number of chains, second player odd number of chains.
  • 10x10 dots (9x9 boxes): First player even number of chains, second player odd number of chains.

Using the chain rule to make the correct number of chains will usually win the game for you.

https://www.oocities.org/cf/ilanpi/glossary.html?202110#chainrule
https://www.oocities.org/cf/ilanpi/math.html#proof

@notTyche

[IA] Fase 1: Individuare quando entrare in fase 2.

This is the part of the game in which there are only chains and cycles left.

Short Chain Phase

This is the part of the game in which all that is left is short chains, long chains, and cycles, and in which players alternate giving away short chains.

Without exception, players should always give away the shortest short chains first.
The short chain phase happens right after the neutral phase and right before final phase of the game.
The scoring can be done more efficiently using the short chain rule.

@notTyche

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.