Giter VIP home page Giter VIP logo

chess's Introduction

Goal

Leokom Chess is a Java-based chess engine. The engine is using Chess Engine Communication Protocol for communication with any existing GUI that supports the protocol.

Not a goal

Leokom Chess doesn't include any GUI. If you are a bot you can play with it using command line :) If you are a human being you should deploy it to your favourite Chess GUI software.

Motivation

The chess software is developed for fun. It should proof that OOP and TDD principles can lead to quality game software.

Creator

Initial creator is Leonid Rozenblyum (the last name could also be spelled as Rozenblium according to Ukrainian transliteration rules)

Milestone

Main goals for version1 are:

  • support Chess Engine Communication Protocol (http://home.hccnet.nl/h.g.muller/engine-intf.html) This protocol is one of de facto standards in communicating between a chess GUI and an engine. The well-known GUI implementations are XBoard/Winboard.
  • know about all chess rules (including ambiguities with the 3'd position repetition and insufficient material)
  • be able to choose at least random 'correct according to rules' move.

How to run

  • Git clone
  • Set up Winboard
  • Modify variables.bat:
  • Set up correct WINBOARD_INSTALLATION_PATH
  • Set up correct JAVA_PATH
  1. Default (recommended) way
    1. mvn clean package -Dproject.deployDirectory="path to set up" (-DskipTests=true if you feel brave; avoid clean phase if your IDE has already compiled the code).
    2. runEngine.bat
  2. New way (requires M3_HOME variable set up)
    1. runEngineDev.bat

How to develop

Branch naming convention

Due to SonarCloud analyzing of pull requests, the branch names should follow the pattern: they can only contain 'A-Z', 'a-z', '0-9', '-', '_', '.', and '/'.

How to release

Preparation

  1. settings.xml must contain valid credentials for release uploading to GitHub
<servers>
    <server>
        <id>github</id>
        <username>...</username>
        <password>...</password>
    </server>
</servers>
  1. pom.xml: github-release-plugin configuration contains meaningful description for the current release

  2. current release tag name is the same as Maven version (so in release 0.3 the tag name must be 0.3)

Execution

mvn clean deploy

Release artifacts

The release consists of:

  • source code in *.zip
  • source code in *.tar.gz
  • binaries in *.zip

Continuous Integration

GitHub Actions

CI

SonarCloud

Full overview: https://sonarcloud.io/dashboard?id=leokom-chess

Technical debt

Maintainability rating

License

See the LICENSE and NOTICE files.

chess's People

Contributors

dependabot[bot] avatar fluxroot avatar lrozenblyum avatar lrozenblyum-yukon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

chess's Issues

Migrate to Java7

No sense to keep Java6 which is not supported by Oracle so far (no further updates are planned)

Continuous integration

Set up CI (to run unit-tests and Sonar analyzing on daily basis).
Hudson/Jenkins/...?

Winboard - promotion

When I move my pawn to promotion rank only queen is created, is it a bug in Winboard or need somehow control the possibility to select?

Mockito

Use mockito. Creating mocks manually is rather expensive when often needed

Statics and dynamics

All the changes I see now in PawnMovement are related to 'so-called' statics - which moves are available.
However we need also dynamics:
which position will we reach after the one of the available moves being executed.
It's VERY important especially for en passant (and for promotion)

King's movement

Finally it's time to introduce the King into the action!
However it could be a long-term task so it may be developed in parts...

Need to implement chess rules 3.8, 3.9.
They must be decomposed into sub-tasks

Rook movement

Implement rules for rook:
3.3 The rook may move to any square along the file or the rank on which it stands.
3.5 When making these moves the bishop, rook or queen may not move over any intervening pieces.

Castling is NOT covered by these changes.

Stable vs random tests

Currently all tests are stable so far (however there were some tests that had utility methods 'for future' to cover something bigger).
Need to think if we need random/multi-parameterized tests at all

Bishop movement

Implement Bishop movement according to rules:
3.2 The bishop may move to any square along a diagonal on which it stands.
3.5 When making these moves the bishop, rook or queen may not move over any intervening pieces.

Check integrationally with pawns and knights

King's movement - castling

The castling is rather a complex topic, therefore I introduce a separate sub-issue of #65

(0) This is a move of the king and either rook of the same colour along the player’s first rank, counting as a single move of the king and executed as follows: the king is transferred from its original square two squares towards the rook on its original square, then that rook is transferred to the square the king has just crossed.

(1) The right to castle has been lost:
if the king has already moved, or
with a rook that has already moved.

(2) Castling is prevented temporarily:
if the square on which the king stands, or the square which it must cross, or the square which it is to occupy, is attacked by one or more of the opponent's pieces, or
if there is any piece between the king and the rook with which castling is to be effected.

Self-learning engine

Think about a player who can self-learn from game to game.

Suppose we import 1-10-100- million of games and make some sophisticating learning possibility? E.g. neuron network etc

Support PGN notation

It's a world standard and will simplify import/export of games

http://portablegamenotation.com/Specification.html - down at the moment of checking on 2020-12-20
https://www.thechessdrum.net/PGN_Reference.txt
http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm

  • Acceptance criteria

    • Normal moves
      • Prevent ambiguous moves like in 1. d4 d5 2. Nf3 Nf6 3. Nd2 the 3'd
      • promotion
      • castling
      • captures
    • special moves
    • output ('export') mode only? (is 'import' to be split?)
      • reduced export format?
      • seven tag roster
      • For PGN export format, a single blank line appears after the last of the tag
        pairs to conclude the tag pair section. This helps simple scanning programs to
        quickly determine the end of the tag pair section and the beginning of the
        movetext section.
    • service fields
    • non-standard fields
    • game outcome
    • tool for validation might be useful: https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/help.html#flag-summary
  • Issue with PGN itself https://zuttobenkyou.wordpress.com/2012/01/27/problems-with-the-portable-game-notation-pgn-standard/

    • Pay attention to encoding...
    • Line separators
    • 4.2. Tab character prohibition
    • Event (the name of the tournament or match event)
      • Simple case
      • Customization
      • colons processing (?)
      • special characers (?)
    • Site (the location of the event)
      • simple case
      • customization
    • Date (the starting date of the game)
      • known date
      • missing parts (?)
      • missing full day
    • Round (the playing round ordinal of the game)
      • number of game played
      • question if unknown
      • hyphen if not appropriate
    • White (the player of the white pieces)
      • human
        • Last name
        • first name/first initial
        • 1/more middle initials
        • More than 1 person playing white pieces
      • computer program
        • name
        • version information
      • Question mark if unknown
    • Black (the player of the black pieces)
    • Result (the result of the game)
      • white wins
      • black wins
      • drawn game
      • game still in progress
      • game abandoned
      • result otherwise unknown
      • same as termination marker in movetext
    • movetext section
      • export format (?): justification + 80
      • export format: space at start/end prohibition
      • The movetext section is composed of chess moves, move number indications,
        optional annotations, and a single concluding game termination marker.
      • move number indication
      • SAN
      • illegal moves not permitted
        • illegal moves permitted in commentary section
      • 8.2: Movetext section
  • Architectural challenge

    • Where to implement: custom player? Game level?
  • Testing ways

    • Engine vs Engine
    • Engine vs Winboard
      • Compare with Winboard-generated?
    • Engine vs UCI (?)
    • Import the output to some chess software, check if it's reasonable
    • extract a new project with PGN support (?)
    • PGNGameRealPlayersTest is running too long

Develop black-moving player

Currently only first white move is Ok. Need to develop black-moving player as well (at least for usual 2 moves). This will allow adding more processing, .e..g. of resignment of its opponent.

King's movement - castling - part0

(0) This is a move of the king and either rook of the same colour along the player’s first rank, counting as a single move of the king and executed as follows: the king is transferred from its original square two squares towards the rook on its original square, then that rook is transferred to the square the king has just crossed.

This is sub-task of #76

Pawn movement - implement unoccupied conditions

Rule 3.7a:
The pawn may move forward to the UNOCCUPIED square immediately in front of it on the same file, or

Rule 3.7b
on its first move the pawn may move as in 3.7.a or alternatively it may advance two squares along the same file provided both squares are UNOCCUPIED, or

Knight movement

Implement rule 3.6.
The knight may move to one of the squares nearest to that on which it stands but not on the same rank, file or diagonal.

  • move possibilities
  • move execution
  • validate some integration with pawn movement.

Sonar - update to 3.6.2

But keep an eye on the mailing list, it looked like some guys had problems with this minor update.

Queen movement

Implement Queen movement.
3.4. The queen may move to any square along the file, the rank or a diagonal on which it stands.
3.5 When making these moves the bishop, rook or queen may not move over any intervening pieces.

Think about generalizing rook/bishop/queen movement. Look well at Direction/HorizontalDirection/VerticalDirection enums...

Backup Github

Think about whole GitHub repository backuping policy - internal/external/CI-controlled?..

FIDE rules

Analyze; create user stories

Extend backlog below.
Create separate issues per item TODO

Winboard moves validation

Winboard UI is as I see non-validating, it allows me doing illegal moves.
Need adding validation to our engine.

3.9 King in check

"The king is said to be 'in check' if it is attacked by one or more of the opponent's pieces, even if such pieces are constrained from moving to that square because they would then leave or place their own king in check. No piece can be moved that will either expose the king of the same colour to check or leave that king in check."

Practically need to limit amount of moves to only those ones which don't leave the king in check (not exposing the king to check looks like already implemented )

Refactor pieces storage

Now pawns and queens are stored separately - it's really hard-to-support.
Need to define a data model which will make the piece management easy

Player abstraction

Now the MainRunner definitely shows mix of Player's responsibilities - both thinking engine that plays AGAINST WinBoard player, and WinBoard player work himself.
It definitely must be split into 2 separate players (it would be very good to share common interface):

  1. Winboard 'thin client' player - who will delegate the real play to Winboard's player (e.g. human or another engine), and encapsulate all low-level communication issues
  2. Chess 'thick client' player - internal engine, real brains, it's opponent of 1)

Implementing them via common interface will help greatly for the next engines implementations, portability and flexibility

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.