plazma-chess


Nameplazma-chess JSON
Version 1.2.1 PyPI version JSON
download
home_pageNone
SummaryA fully function chess engine written in python
upload_time2024-06-07 14:21:07
maintainerNone
docs_urlNone
authorNone
requires_python>3
licenseNone
keywords chess engine game
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Plazma Chess Engine

## In development!

### This is a basic chess engine based off of the [python-chess](https://github.com/niklasf/python-chess) library

#### The engine has a [client](https://github.com/niklasf/python-chess-client) which supports multiplayer, singleplayer and bot chess matches!

## Documentation
### Setting up the board
```python
import engine # Import the plazma-chess module

chessEngine = engine.Engine() # Create instance of the Engine class
```

This will initialize the engine class which contains all of the information of the board.
All pieces will be set to normal chess starting positions.

### Acessing the board
```python
import engine # Import the plazma-chess module

chessEngine = engine.Engine() # Create instance of the Engine class
print(chessEngine.board.board) # Access the board class stored in the engine class and get the board list

# Example output of starting positions
"""[[10, 8, 9, 11, 12, 9, 8, 10],
    [7, 7, 7, 7, 7, 7, 7, 7],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [1, 1, 1, 1, 1, 1, 1, 1],
    [4, 2, 3, 5, 6, 3, 2, 4]]"""
```
To Access the board class, and the board list within that you need to use the engine class.
This is because when the engine class is initialized it also initializes the board.

### Generating moves
```python
import engine # Import the plazma-chess module

chessEngine = engine.Engine() # Create instance of the Engine class

legalMoves = chessEngine.generateMoves((4, 6)) # Get the legal moves for the kings pawn
```
To get the legal moves for a piece you just need to specify the coordinates of the piece and call the `generateMoves` function in the engine class, passing in those coordinates.

### Finding pieces
```python
import engine # Import the plazma-chess module

chessEngine = engine.Engine() # Create instance of the Engine class

pos = any_pieces_position

print(chessEngine.board.pieceAt(pos)) # Call the 'pieceAt' function in the board
# Prints:
#   bool -> Found a piece
#   int -> Piece value (0 if no piece)
```
To check if a piece is on a specific part of the board you can either access the board list manually or use the `pieceAt` function in the board class.

### Moving pieces
```python
import engine # Import the plazma-chess module

chessEngine = engine.Engine() # Create instance of the Engine class

pos = current_piece_position
newPos = new_piece_position

status = chessEngine.move(pos, newPos) # Call the move function in the engine

# If status = 0 the move was successfull.
# If status = 1 the move ended in checkmate.
# If an Illegal Move error surfaces the move was unsuccessfull.
```
To move pieces simply call the move function in the engine class. It will not allow illegal moves to be played and it uses the same `generateMoves` function to validate moves.

Neither the `generateMoves` function or the `move` function will return moves that may result in a check.

### Bots
Bot support is not fully implemented yet so creating bots requires a little more work than expected.

Generating moves is a little easier thanks to the individual move generation functions.

These include:
* `generatePawnMoves`
* `generateKnightMoves`
* `generateSlidingMoves`
* `generateDiagonalMoves`
* `generateKingMoves`

This allows you to generate moves with more speciallity and presicion.

These functions all take the same argument, `pos` which defines the piece position.

These functions do not take checks into account so illegal move errors are a risk.

You can remedy this by using the `inCheck` function which takes a `turn` argument and and optional `square` argument which is used to check for a specific piece. It returns `True` or `False` if the king is in check.

To bypass the check detection there is a function called `__moveWithoutCheck`. This function is dangerous as it defies the rules of chess. It should only be used for move generation in bots which will garrentee faster move generation. chess. It should only be used for move generation in bots which will garrentee faster move generation.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "plazma-chess",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">3",
    "maintainer_email": null,
    "keywords": "chess, engine, game",
    "author": null,
    "author_email": "CaptainDeathead <unstableplazma@gmail.com>",
    "download_url": null,
    "platform": null,
    "description": "# Plazma Chess Engine\n\n## In development!\n\n### This is a basic chess engine based off of the [python-chess](https://github.com/niklasf/python-chess) library\n\n#### The engine has a [client](https://github.com/niklasf/python-chess-client) which supports multiplayer, singleplayer and bot chess matches!\n\n## Documentation\n### Setting up the board\n```python\nimport engine # Import the plazma-chess module\n\nchessEngine = engine.Engine() # Create instance of the Engine class\n```\n\nThis will initialize the engine class which contains all of the information of the board.\nAll pieces will be set to normal chess starting positions.\n\n### Acessing the board\n```python\nimport engine # Import the plazma-chess module\n\nchessEngine = engine.Engine() # Create instance of the Engine class\nprint(chessEngine.board.board) # Access the board class stored in the engine class and get the board list\n\n# Example output of starting positions\n\"\"\"[[10, 8, 9, 11, 12, 9, 8, 10],\n    [7, 7, 7, 7, 7, 7, 7, 7],\n    [0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0, 0, 0, 0],\n    [1, 1, 1, 1, 1, 1, 1, 1],\n    [4, 2, 3, 5, 6, 3, 2, 4]]\"\"\"\n```\nTo Access the board class, and the board list within that you need to use the engine class.\nThis is because when the engine class is initialized it also initializes the board.\n\n### Generating moves\n```python\nimport engine # Import the plazma-chess module\n\nchessEngine = engine.Engine() # Create instance of the Engine class\n\nlegalMoves = chessEngine.generateMoves((4, 6)) # Get the legal moves for the kings pawn\n```\nTo get the legal moves for a piece you just need to specify the coordinates of the piece and call the `generateMoves` function in the engine class, passing in those coordinates.\n\n### Finding pieces\n```python\nimport engine # Import the plazma-chess module\n\nchessEngine = engine.Engine() # Create instance of the Engine class\n\npos = any_pieces_position\n\nprint(chessEngine.board.pieceAt(pos)) # Call the 'pieceAt' function in the board\n# Prints:\n#   bool -> Found a piece\n#   int -> Piece value (0 if no piece)\n```\nTo check if a piece is on a specific part of the board you can either access the board list manually or use the `pieceAt` function in the board class.\n\n### Moving pieces\n```python\nimport engine # Import the plazma-chess module\n\nchessEngine = engine.Engine() # Create instance of the Engine class\n\npos = current_piece_position\nnewPos = new_piece_position\n\nstatus = chessEngine.move(pos, newPos) # Call the move function in the engine\n\n# If status = 0 the move was successfull.\n# If status = 1 the move ended in checkmate.\n# If an Illegal Move error surfaces the move was unsuccessfull.\n```\nTo move pieces simply call the move function in the engine class. It will not allow illegal moves to be played and it uses the same `generateMoves` function to validate moves.\n\nNeither the `generateMoves` function or the `move` function will return moves that may result in a check.\n\n### Bots\nBot support is not fully implemented yet so creating bots requires a little more work than expected.\n\nGenerating moves is a little easier thanks to the individual move generation functions.\n\nThese include:\n* `generatePawnMoves`\n* `generateKnightMoves`\n* `generateSlidingMoves`\n* `generateDiagonalMoves`\n* `generateKingMoves`\n\nThis allows you to generate moves with more speciallity and presicion.\n\nThese functions all take the same argument, `pos` which defines the piece position.\n\nThese functions do not take checks into account so illegal move errors are a risk.\n\nYou can remedy this by using the `inCheck` function which takes a `turn` argument and and optional `square` argument which is used to check for a specific piece. It returns `True` or `False` if the king is in check.\n\nTo bypass the check detection there is a function called `__moveWithoutCheck`. This function is dangerous as it defies the rules of chess. It should only be used for move generation in bots which will garrentee faster move generation. chess. It should only be used for move generation in bots which will garrentee faster move generation.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A fully function chess engine written in python",
    "version": "1.2.1",
    "project_urls": {
        "Homepage": "https://github.com/CaptainDeathead/plazma-chess-engine"
    },
    "split_keywords": [
        "chess",
        " engine",
        " game"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e4ef0ded81992ee7e1297b6de3f489077360f2eb46e0e70b9da8a4fbc4a8c3e8",
                "md5": "bc7ecc4ccf7a1dc8dd1365bc673caa03",
                "sha256": "b00f6da4bcd550ce1501fb4821eb0d50233c655d7ac51a6d7096eae25e764df4"
            },
            "downloads": -1,
            "filename": "plazma_chess-1.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bc7ecc4ccf7a1dc8dd1365bc673caa03",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">3",
            "size": 6499,
            "upload_time": "2024-06-07T14:21:07",
            "upload_time_iso_8601": "2024-06-07T14:21:07.151807Z",
            "url": "https://files.pythonhosted.org/packages/e4/ef/0ded81992ee7e1297b6de3f489077360f2eb46e0e70b9da8a4fbc4a8c3e8/plazma_chess-1.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-07 14:21:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "CaptainDeathead",
    "github_project": "plazma-chess-engine",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "plazma-chess"
}
        
Elapsed time: 0.34990s