tic-tac-toe-engine


Nametic-tac-toe-engine JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryAn implementation of the Tic Tac Toe game rules
upload_time2024-09-22 12:36:45
maintainerNone
docs_urlNone
authorSebastian Mendoza
requires_pythonNone
licenseNone
keywords python tic-tac-toe tictactoe game engine
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Tic Tac Toe Engine


Implementation of the rules of the game "Tic tac toe".

This project can be use as:
- An engine for a game (Both CLI and paired with a game library like Pygame).
- A tool for AI training.

This project implements all the logic needed to play the tic tac toe game.

Example usage (a CLI implementation):

```python
from tic_tac_toe_engine import Engine
from typing import Union



def print_board(board: list[Union[str, None]]) -> None:
	""" Print the board """	

	print("") # Some space

	for i in range(0, 9, 3):
		row = " | ".join(board[j] if board[j] is not None else str(j) for j in range(i, i + 3))
		print(row)
		if i < 6:  # Add a line between rows, but not after the last row
			print("-" * 9)


engine = Engine()

while True:
	print_board(engine.board)
	print(f"\n{engine.current_player} moves.")
	move = int(input("Enter your move (0 - 8): "))

	engine.play_move(move)

	if engine.is_over():
		print_board(engine.board) # Print again to reflect the ending
		
		if engine.is_tie():
			print("It's a tie")

		else:
			print(f"{engine.winner} wins!")

		break
```


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tic-tac-toe-engine",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "python, tic-tac-toe, tictactoe, game, engine",
    "author": "Sebastian Mendoza",
    "author_email": "<sebastian.mendoza.clases@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/e8/00/25c7915a5c3e9cee4b4969d3e14ee04b773b30d73f997b7e572faee00cc0/tic-tac-toe-engine-0.1.0.tar.gz",
    "platform": null,
    "description": "\n# Tic Tac Toe Engine\n\n\nImplementation of the rules of the game \"Tic tac toe\".\n\nThis project can be use as:\n- An engine for a game (Both CLI and paired with a game library like Pygame).\n- A tool for AI training.\n\nThis project implements all the logic needed to play the tic tac toe game.\n\nExample usage (a CLI implementation):\n\n```python\nfrom tic_tac_toe_engine import Engine\nfrom typing import Union\n\n\n\ndef print_board(board: list[Union[str, None]]) -> None:\n\t\"\"\" Print the board \"\"\"\t\n\n\tprint(\"\") # Some space\n\n\tfor i in range(0, 9, 3):\n\t\trow = \" | \".join(board[j] if board[j] is not None else str(j) for j in range(i, i + 3))\n\t\tprint(row)\n\t\tif i < 6:  # Add a line between rows, but not after the last row\n\t\t\tprint(\"-\" * 9)\n\n\nengine = Engine()\n\nwhile True:\n\tprint_board(engine.board)\n\tprint(f\"\\n{engine.current_player} moves.\")\n\tmove = int(input(\"Enter your move (0 - 8): \"))\n\n\tengine.play_move(move)\n\n\tif engine.is_over():\n\t\tprint_board(engine.board) # Print again to reflect the ending\n\t\t\n\t\tif engine.is_tie():\n\t\t\tprint(\"It's a tie\")\n\n\t\telse:\n\t\t\tprint(f\"{engine.winner} wins!\")\n\n\t\tbreak\n```\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "An implementation of the Tic Tac Toe game rules",
    "version": "0.1.0",
    "project_urls": {
        "Source": "https://github.com/Sebastian-0110/Tic-Tac-Toe-Engine/"
    },
    "split_keywords": [
        "python",
        " tic-tac-toe",
        " tictactoe",
        " game",
        " engine"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "57ca9684b39d47d99f764adeb202a99ab50cdc0f9175955cf8a8c9d0d1efaf06",
                "md5": "1613622e529eeb755c7c15a253e82174",
                "sha256": "5d9069442e9d779aad855287510aadb8a28e639a2807a60d540c1f6c5f2a626a"
            },
            "downloads": -1,
            "filename": "tic_tac_toe_engine-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1613622e529eeb755c7c15a253e82174",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5894,
            "upload_time": "2024-09-22T12:36:44",
            "upload_time_iso_8601": "2024-09-22T12:36:44.090230Z",
            "url": "https://files.pythonhosted.org/packages/57/ca/9684b39d47d99f764adeb202a99ab50cdc0f9175955cf8a8c9d0d1efaf06/tic_tac_toe_engine-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e80025c7915a5c3e9cee4b4969d3e14ee04b773b30d73f997b7e572faee00cc0",
                "md5": "6532f7a799a4f5a418ef375849ef7854",
                "sha256": "cc7619212ec8125d447611d0ad5cbec13ae111e04155cd6f1011a7c3f060cd4f"
            },
            "downloads": -1,
            "filename": "tic-tac-toe-engine-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6532f7a799a4f5a418ef375849ef7854",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4541,
            "upload_time": "2024-09-22T12:36:45",
            "upload_time_iso_8601": "2024-09-22T12:36:45.181530Z",
            "url": "https://files.pythonhosted.org/packages/e8/00/25c7915a5c3e9cee4b4969d3e14ee04b773b30d73f997b7e572faee00cc0/tic-tac-toe-engine-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-22 12:36:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Sebastian-0110",
    "github_project": "Tic-Tac-Toe-Engine",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tic-tac-toe-engine"
}
        
Elapsed time: 0.36471s