Giter Club home page Giter Club logo

ripred / javachess Goto Github PK

View Code? Open in Web Editor NEW
17.0 0.0 3.0 1.01 MB

24-bit ANSI colored, console-based chess engine using Java. Optional multi-threaded AI using Minimax with alpha-beta pruning. Fully configurable properties including: ply depth, thread pool size, optional AI time limit, all colors, and more.

Java 100.00%
chess java minimax-algorithm alpha-beta-pruning multithread console-color configurable console-game javachess chess-engine

javachess's Introduction

JavaChess

  • 24-bit ANSI colored, console-based chess using Java.
  • Either side can be human or a multi-threaded AI instance using the Minimax algorithm with alpha-beta pruning.
  • Uses map/reduce and streaming techniques to speed up the parallelism using multiple cores during board valuations since those happen after every move millions of times on every thread.
  • Includes high-speed mapping and caching of all moves seen by all threads in order to gain short-circuit efficiency on parallel threads evaluating the same board state for which the best move to be made has already been determined earlier by the popularity winner of previous evaluation threads that all ran to ply (or quiescent search) depth and were repeatedly determined to be the best moves. The required percentage of repeated wins as "best move" is configurable to control the required reliability of the cached best moves answers.
  • Includes end game recognition and several map/reduce specialization approaches including walking the King into a corner if possible and intentionally advancing and sacrificing pawns if necessary in order to allow other pieces to make higher value moves or unblock pieces when it is recognized that they cannot advance.
  • configurable choice of how many of the available physical processor cores to use
  • Includes quiescent search support.
  • Full support for reading and writing FEN chess notation strings and full game replay.
  • Fully configurable properties text file including: ply depth, thread pool size, optional AI time limit, all colors, and more.

Running the program:

$ java -jar chess.jar

To end the program simply hit ctrl-c at any time.
To play against the computer change the humanPlayer value to true in the editable chess.properties file and re-run the jar file. Or change any of the other options and re-run the jar file. Play around! Many interesting combinations are available there:
#
# Usage:
#
# General Game Settings:
# numDrawReps         number of repeated moves to call game a draw
#
# AI Settings:
# humanPlayer:        set to true to play as player 1 (white)
# maxThreads:         maximum number of threads for AI to run simultaneously
# aiPlyDepth:         maximum number of moves for AI to look ahead
# maxAISeconds:       maximum number of seconds to allow AI to think (0 for no time limit)
#
# UI Settings:
# showVictims:        color the board to show current players possible moves if true
# showTargets:        color the board to show opponents possible moves if true
# showCapturesOnly:   limit board coloring to only show possible captures if true
#
# player1             label to use for player 1
# player2             label to use for player 2
#
# ANSI Colors (24-bit):
# blkBack             background color for dark squares
# whtBack             background color for light squares
#
# blkForeB            foreground color for black piece on dark square
# blkForeW            foreground color for black piece on light square
#
# whtForeB            foreground color for white piece on dark square
# whtForeW            foreground color for white piece on light square
#
# blkMoved            foreground color for last moved black piece
# whtMoved            foreground color for last moved white piece
#
# blkCheck            foreground color for black king in check
# whtCheck            foreground color for white king in check
#
# targetsShade        color influence for target path positions
# victimsShade        color influence for victim path positions
#
#
#Wed Jul 03 01:13:30 CDT 2019
numDrawReps=3

humanPlayer=false
maxThreads=100
aiPlyDepth=6
maxAISeconds=75

showVictims=true
showTargets=true
showCapturesOnly=true

player1=Player 1
player2=Player 2

blkBack=142, 142, 142
whtBack=204, 204, 204

blkForeB=64, 64, 64
blkForeW=0, 0, 0

whtForeB=255, 255, 255
whtForeW=255, 255, 255

blkMoved=192, 0, 0
whtMoved=0, 0, 255

blkCheck=192, 128, 0
whtCheck=192, 128, 0

targetsShade=0, 0, 128
victimsShade=160, 0, 0

javachess's People

Contributors

ripred avatar

Stargazers

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

javachess's Issues

This code is a mess

I took this code as a reference for my "Advanced Software Development" class on my MSc degree and the classes are tightly-coupled so hard... ๐Ÿ˜ž I don't want to hate but in this project even the basic OOP principles are invalidated...

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.