Coder Social home page Coder Social logo

pawnchesbot's Introduction

Pawnchesbot

School project: An ai playing chess with ony pawn.

Hot to play

Start the game with python3 game.py

Select a mode:
1: human    vs. computer
2: computer vs. human
3: computer vs. computer
4: human    vs. human
Enter your choice (1-4): 1
    A   B   C   D   E 
   --------------------
5 | b | b | b | b | b |
   --------------------
4 |   |   |   |   |   |
   --------------------
3 |   |   |   |   |   |
   --------------------
2 |   |   |   |   |   |
   --------------------
1 | w | w | w | w | w |
   --------------------
heuristics for this board: 0
Select your move white
Possible Moves
1: 1A->2A
2: 1B->2B
3: 1C->2C
4: 1D->2D
5: 1E->2E
Enter the number of your move:

Then enter the number of the move want to play: (1,2,3,...) Just enter for example 3 and press enter.

How it works

Alpha-Beta-Pruning

We have implemented a Alpha-Beta-Pruning algorithm. The searched depth is 5 and can be adjusted in to code. The implementation of the search algorithm can be found in the alphabeta.py file.

Heuristic

We played a bit with different heuristics and found our that the following works best. We start with a value of 0. For each white piece we check on which rank it is (1 to 5) and add the square of the rank to the value. For the black pieces we do the same but just subtract the the rank for the value. Let's make an example with the following board.

    A   B   C   D   E 
   --------------------
5 |   | b | b |   | b |
   --------------------
4 | b |   |   | b |   |
   --------------------
3 |   |   | w |   |   |
   --------------------
2 | w |   |   |   |   |
   --------------------
1 |   | w |   | w | w |
   --------------------

Because the white A pawn is on the second rank it adds 4 point to the heuristic value. The C pawn adds 9 points to the heuristic output. The B, D, and E pawn each add 1 point to the value. The total points for white are 2+1+9+1+1=14 The black pawns A,B,C,D,E count as 4 1, 1, 4, 1 and therefore subtracts 11 points in total for the heuristic output. The final output of the heuristic is therefore 14-11=3.

pawnchesbot's People

Contributors

gianlucafrei avatar freerider689 avatar

Watchers

James Cloos 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.