<commit_before># python-chess

[![Build Status](https://travis-ci.org/jrialland/python-chess.svg)](https://travis-ci.org/jrialland/python-chess)

chess3 is a really simple chess engine, written in python, mainly for fun..

It also features an openings book.

Representation
--------------

chess3 is a board-centric engine, (contrary to my former chess2 engine which was part-centric).
The board state is viewed as a 64 chars string. Part names follow the standard letter convention, except that
it uses a different letter to distinguish between parts on their initial positions and part that have moved, when necessary.
 (castling only applies if involved parts have stayed on their initial positions)

Then the representation is :

|character| signification
|-------|-----------------------------------------------------------------|
| .   | an empty cell                                                   |
| *   | an empty cell that is a target for en 'en-passant' pawn attack. |
| H or h | rook at initial position                                        |
| R or r | rook that have moved                                            |
| N or n | knight                                                          |
| B or b | bishop                                                          |
| Q or q | queen                                                           |
| P or p | pawn                                                            |
| A or a | king at initial position                                        |
| Z or z | king after it has moved                                         |
---------------------------------------------------------------------------

The initial board state representation is :
```
HNBQABNHPPPPPPPP................................pppppppphnbqabnh
```

Which corresponds to the following chess board :
```
#########
#hnbqabnh  <-- black side
#pppppppp
#........
#........
#........
#........
#PPPPPPPP
#HNBQABNH  <-- white side
```


IA
--

The IA is a basic "negamax", with alpha/beta simplification
By default it searches 4 moves beyond, which takes some time, especially in python :(

it is more compact an understandable that my old 'chess2' engine, that I had written in java some years ago

It plays well enough to beat me ('less-than-average' player), but always looses against fairymax, for example.


How to play
-----------

It aims at supporting the XBoard protocol version 2. Run XBoard (or any XBoard/WinBoard -compatible UI, pychess works well too), and choose chess3.py as opponent engine.

You can run :

```sh
xboard -debugMode true -cp -fcp "python chess3.py" -scp "python chess3.py"
```

In a terminal, you can enter :

```sh
yes go | python chess3.py
```

And see the engine play against itself ! (or type ctrl+T in XBoard)<commit_msg>some infos about win32 build<commit_after># python-chess

[![Build Status](https://travis-ci.org/jrialland/python-chess.svg)](https://travis-ci.org/jrialland/python-chess)

chess3 is a really simple chess engine, written in python, mainly for fun..

It also features an openings book.

Representation
--------------

chess3 is a board-centric engine, (contrary to my former chess2 engine which was part-centric).
The board state is viewed as a 64 chars string. Part names follow the standard letter convention, except that
it uses a different letter to distinguish between parts on their initial positions and part that have moved, when necessary.
 (castling only applies if involved parts have stayed on their initial positions)

Then the representation is :

|character| signification
|-------|-----------------------------------------------------------------|
| .   | an empty cell                                                   |
| *   | an empty cell that is a target for en 'en-passant' pawn attack. |
| H or h | rook at initial position                                        |
| R or r | rook that have moved                                            |
| N or n | knight                                                          |
| B or b | bishop                                                          |
| Q or q | queen                                                           |
| P or p | pawn                                                            |
| A or a | king at initial position                                        |
| Z or z | king after it has moved                                         |
---------------------------------------------------------------------------

The initial board state representation is :
```
HNBQABNHPPPPPPPP................................pppppppphnbqabnh
```

Which corresponds to the following chess board :
```
#########
#hnbqabnh  <-- black side
#pppppppp
#........
#........
#........
#........
#PPPPPPPP
#HNBQABNH  <-- white side
```


IA
--

The IA is a basic "negamax", with alpha/beta simplification
By default it searches 4 moves beyond, which takes some time, especially in python :(

it is more compact an understandable that my old 'chess2' engine, that I had written in java some years ago

It plays well enough to beat me ('less-than-average' player), but always looses against fairymax, for example.


How to play
-----------

It aims at supporting the XBoard protocol version 2. Run XBoard (or any XBoard/WinBoard -compatible UI, pychess works well too), and choose chess3.py as opponent engine.

You can run :

```sh
xboard -debugMode true -cp -fcp "python chess3.py" -scp "python chess3.py"
```

In a terminal, you can enter :

```sh
yes go | python chess3.py
```

And see the engine play against itself ! (or type ctrl+T in XBoard)

Cross "compilation" from linux to win32
---------------------------------------

Maybe the most interesting thing is that the script can be packed into a plain win32 exe without owning windows. (see build_win32.sh)
{'fraction_non_alphanumeric': 0.1536480686695279, 'fraction_numerical': 0.005493562231759657, 'mean_word_length': 1.5231702035513208, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 8, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3967972', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1351, 'n_words': 637}