Skip to main content

Chess position Evaluation via hand-crafted features

Project description

Simple framework turning fen into set of hand-crafted chess position features

Installation

To install please run

pip install chevy

Basic usage

King safety features

import chess
from chevy.features import KingSafety

# https://lichess.org/analysis/2r3k1/7R/6PK/6P1/2Q5/8/8/8_b_-_-_6_73
fen = "2r3k1/7R/6PK/6P1/2Q5/8/8/8 b - - 6 73"
board = chess.Board(fen)

king_safety = KingSafety(board, color=chess.WHITE)
print(f"{king_safety.king_mobility=}")
print(f"{king_safety.castling_rights=}")
print(f"{king_safety.king_centrality=}")
print(f"{king_safety.checked=}")
print(f"{king_safety.king_attackers_looking_at_ring_1=}")
print(f"{king_safety.king_defenders_at_ring_1=}")
# + more

Pawn structure features

import chess
from chevy.features import PawnStructure

# https://lichess.org/editor/5kr1/4pp1p/1Q2q3/1PBP2p1/2P3P1/p7/4P3/1R2K1B1_w_-_-_0_19
fen = "5kr1/4pp1p/1Q2q3/1PBP2p1/2P3P1/p7/4P3/1R2K1B1 w - - 0 19"
board = chess.Board(fen)
pawn_structure = PawnStructure(board, color=chess.WHITE)
print(f"{pawn_structure.passed_pawns=}")
print(f"{pawn_structure.isolated_pawns=}")
print(f"{pawn_structure.blocked_pawns=}")
print(f"{pawn_structure.central_pawns=}")

Other common features

import chess
from chevy.features import BoardFeatures

# https://lichess.org/editor/5kr1/4pp1p/1Q2q3/1PBP2p1/2P3P1/p7/4P3/1R2K1B1_w_-_-_0_19
fen = "5kr1/4pp1p/1Q2q3/1PBP2p1/2P3P1/p7/4P3/1R2K1B1 w - - 0 19"
board = chess.Board(fen)
board_features = BoardFeatures(board, color=chess.WHITE)
print(f"{board_features.bishop_pair=}")
print(f"{board_features.fianchetto_queen=}")
print(f"{board_features.fianchetto_king=}")
print(f"{board_features.queens_mobility=}")
print(f"{board_features.open_files_rooks_count=}")
print(f"{board_features.connected_rooks=}")
print(f"{board_features.connectivity=}")
# + more 

To run tests:

pytest chevy/tests 

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chevy-0.2.2.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

chevy-0.2.2-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file chevy-0.2.2.tar.gz.

File metadata

  • Download URL: chevy-0.2.2.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.8.10 Linux/5.14.0-1042-oem

File hashes

Hashes for chevy-0.2.2.tar.gz
Algorithm Hash digest
SHA256 cb1db3154c5627296037343d0c3f7199f4beed0e659bcbaeacd7b299eb1b2362
MD5 b25617c526d9b7c13dbe32024924f6d7
BLAKE2b-256 cf3b29cfd89e1acf6a808904639cabefd96ba07030f73959900afe3f023790e6

See more details on using hashes here.

File details

Details for the file chevy-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: chevy-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.8.10 Linux/5.14.0-1042-oem

File hashes

Hashes for chevy-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2358e893416308034f187d477561997d643f490f9cb9f79e9a99417a99283d40
MD5 9ae467e683af59eae855c3b4b90d8462
BLAKE2b-256 19d146f24c24d1d6bbd533a15fc888f4473ef7194cdabffc8d88d45dfb9eaa2e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page