Giter VIP home page Giter VIP logo

prolog-checkers's Introduction

What is This?

Checkers (Draughts) game written in Prolog language.

This checkers follow russian draights rules. The russian draughts was chosen among other draughts variants because the rules (especially rules for kings) offer more freedom and thus increased search space. In other words, it was just slightly more complicated and fun to implement.

This whole project was done as a fun experiment and bears zero practical value.

Rules

Rules are standard for russian checkers:

  • Board is an 8x8 grid
  • There are two kinds of pieces (figures): men and kings
  • Long-range kings
  • Men can capture backwards

How to Play?

Install Prolog

For now only SWI-Prolog is supported. You can download it from here.

Start the Game

To play you only need file checkers.pl. Download it and open in SWI Prolog (in Windows usually you can just double click the file, alternatively type consult('your_path/checkers.pl'). in Prolog terminal, where your_path is a full path to checkers.pl file).

To start game type play.. You will be prompted for the side selection (black or white).

Board

Game board appears like this:

    0   1   2   3   4   5   6   7
  ---------------------------------
7 |   | o |   | o |   | o |   | o | 7
  ---------------------------------
6 | o |   | o |   | o |   | o |   | 6
  ---------------------------------
5 |   | o |   | o |   | o |   | o | 5
  ---------------------------------
4 | . |   | . |   | . |   | . |   | 4
  ---------------------------------
3 |   | . |   | . |   | . |   | . | 3
  ---------------------------------
2 | x |   | x |   | x |   | x |   | 2
  ---------------------------------
1 |   | x |   | x |   | x |   | x | 1
  ---------------------------------
0 | x |   | x |   | x |   | x |   | 0
  ---------------------------------
    0   1   2   3   4   5   6   7

Cells are numbered from 0 to 7. Figures are marked as: X - white king, x - white man, O - black king, o - black man.

Making Moves

When prompted for move (Your move:) you need to enter start and destination positions for your move. Each position is entered as X-Y.. For example, to move white man from cell (2, 2) to cell (3, 3) enter: 2-2. 3-3.. You will see board updated after your move, and a board updated after computer responded to your move.

Capturing

In russian checkers when you have possibility to make capture, then you have to do it. If you have possibility to capture, you will be prompted to enter capture path: Please input your capture path (type 'end.' to finish):.

Capture path is a list of positions, ending with a term end.. The first position in a list is a position of your man or king which is making a capture. The other positions are positions of intermediate cells on which your figure jumps during the capturing.

For example, for the board below you can enter two possible capture paths (for white):

    0   1   2   3   4   5   6   7
  ---------------------------------
7 |   | . |   | . |   | . |   | . | 7
  ---------------------------------
6 | . |   | . |   | . |   | . |   | 6
  ---------------------------------
5 |   | . |   | . |   | . |   | . | 5
  ---------------------------------
4 | . |   | . |   | o |   | o |   | 4
  ---------------------------------
3 |   | o |   | . |   | . |   | . | 3
  ---------------------------------
2 | x |   | . |   | . |   | . |   | 2
  ---------------------------------
1 |   | X |   | . |   | . |   | . | 1
  ---------------------------------
0 | . |   | . |   | . |   | . |   | 0
  ---------------------------------
    0   1   2   3   4   5   6   7
Please input your capture path (type 'end.' to finish):

The first is 0-2. 2-4. end., to capture one enemy men using our men. And a second one is 1-1. 5-5. 7-3. end., to capture two enemy men using our king.

End of The Game

When one of the sides can't make any move - other side is considered a winner. There is no check for the draw.

Tweaking

In the beginning of the checkers.pl file there are some predicates you can change, like depth of decision tree for minimax algorithm, initial positions of men and kings on the board, and board evaluation function.

License

This program is licensed under BSD 2-clause license (or Simplified BSD License, or FreeBSD License).

prolog-checkers's People

Watchers

 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.