hexo 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hexo-0.1.0/.github/workflows/python-publish.yml +108 -0
- hexo-0.1.0/.gitignore +164 -0
- hexo-0.1.0/.idea/.gitignore +10 -0
- hexo-0.1.0/.idea/inspectionProfiles/profiles_settings.xml +6 -0
- hexo-0.1.0/.idea/misc.xml +7 -0
- hexo-0.1.0/.idea/modules.xml +8 -0
- hexo-0.1.0/.idea/python_template.iml +11 -0
- hexo-0.1.0/.idea/runConfigurations/app.xml +18 -0
- hexo-0.1.0/.idea/vcs.xml +6 -0
- hexo-0.1.0/.pre-commit-config.yaml +24 -0
- hexo-0.1.0/CONTRIBUTING.md +60 -0
- hexo-0.1.0/LICENSE +21 -0
- hexo-0.1.0/PKG-INFO +176 -0
- hexo-0.1.0/README.md +144 -0
- hexo-0.1.0/RULES.md +66 -0
- hexo-0.1.0/benchmarks/test_engine_benchmarks.py +51 -0
- hexo-0.1.0/examples/random_match.py +56 -0
- hexo-0.1.0/pyproject.toml +41 -0
- hexo-0.1.0/src/hexo/__init__.py +30 -0
- hexo-0.1.0/src/hexo/engine.py +428 -0
- hexo-0.1.0/src/hexo/errors.py +21 -0
- hexo-0.1.0/src/hexo/geometry.py +21 -0
- hexo-0.1.0/src/hexo/py.typed +1 -0
- hexo-0.1.0/src/hexo/types.py +109 -0
- hexo-0.1.0/tests/test_hexo/__init__.py +0 -0
- hexo-0.1.0/tests/test_hexo/test_hexo_api.py +107 -0
- hexo-0.1.0/uv.lock +604 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
name: CI & Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
# Run tests on every PR to master
|
|
5
|
+
pull_request:
|
|
6
|
+
branches: [ master ]
|
|
7
|
+
|
|
8
|
+
# Run full pipeline (incl. publish) when something is pushed to master
|
|
9
|
+
# – this includes merges of PRs into master
|
|
10
|
+
push:
|
|
11
|
+
branches: [ master ]
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
include:
|
|
20
|
+
- python-version: "3.10"
|
|
21
|
+
experimental: false
|
|
22
|
+
- python-version: "3.11"
|
|
23
|
+
experimental: false
|
|
24
|
+
- python-version: "3.12"
|
|
25
|
+
experimental: false
|
|
26
|
+
- python-version: "3.13"
|
|
27
|
+
experimental: false
|
|
28
|
+
- python-version: "3.14"
|
|
29
|
+
experimental: true
|
|
30
|
+
- python-version: "3.15-dev"
|
|
31
|
+
experimental: true
|
|
32
|
+
continue-on-error: ${{ matrix.experimental }}
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v4
|
|
35
|
+
|
|
36
|
+
- name: Set up Python
|
|
37
|
+
uses: actions/setup-python@v5
|
|
38
|
+
with:
|
|
39
|
+
python-version: ${{ matrix.python-version }}
|
|
40
|
+
|
|
41
|
+
- name: Install dependencies
|
|
42
|
+
run: |
|
|
43
|
+
python -m pip install --upgrade pip
|
|
44
|
+
pip install uv && uv sync
|
|
45
|
+
|
|
46
|
+
- name: Run tests
|
|
47
|
+
run: uv run pytest
|
|
48
|
+
|
|
49
|
+
build:
|
|
50
|
+
needs: test
|
|
51
|
+
runs-on: ubuntu-latest
|
|
52
|
+
|
|
53
|
+
outputs:
|
|
54
|
+
version: ${{ steps.get_version.outputs.version }}
|
|
55
|
+
|
|
56
|
+
steps:
|
|
57
|
+
- uses: actions/checkout@v4
|
|
58
|
+
|
|
59
|
+
- uses: actions/setup-python@v5
|
|
60
|
+
with:
|
|
61
|
+
python-version: "3.13"
|
|
62
|
+
|
|
63
|
+
- name: Get version from pyproject.toml
|
|
64
|
+
id: get_version
|
|
65
|
+
run: |
|
|
66
|
+
version=$(grep '^version =' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
|
|
67
|
+
echo "Detected version: $version"
|
|
68
|
+
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
69
|
+
|
|
70
|
+
- name: Build distributions
|
|
71
|
+
run: |
|
|
72
|
+
python -m pip install --upgrade pip
|
|
73
|
+
pip install build
|
|
74
|
+
python -m build
|
|
75
|
+
|
|
76
|
+
- name: Upload artifacts
|
|
77
|
+
uses: actions/upload-artifact@v4
|
|
78
|
+
with:
|
|
79
|
+
name: dist
|
|
80
|
+
path: dist/
|
|
81
|
+
|
|
82
|
+
publish:
|
|
83
|
+
needs: build
|
|
84
|
+
runs-on: ubuntu-latest
|
|
85
|
+
|
|
86
|
+
# Only publish on *push* to master (i.e. after a PR is merged)
|
|
87
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
88
|
+
|
|
89
|
+
environment:
|
|
90
|
+
name: pypi
|
|
91
|
+
# Use the version detected from pyproject.toml in the environment URL
|
|
92
|
+
url: https://pypi.org/project/hexo/${{ needs.build.outputs.version }}
|
|
93
|
+
|
|
94
|
+
permissions:
|
|
95
|
+
contents: read
|
|
96
|
+
id-token: write
|
|
97
|
+
|
|
98
|
+
steps:
|
|
99
|
+
- name: Download build artifacts
|
|
100
|
+
uses: actions/download-artifact@v4
|
|
101
|
+
with:
|
|
102
|
+
name: dist
|
|
103
|
+
path: dist/
|
|
104
|
+
|
|
105
|
+
- name: Publish to PyPI
|
|
106
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
107
|
+
with:
|
|
108
|
+
packages-dir: dist/
|
hexo-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
### Python template
|
|
2
|
+
# Byte-compiled / optimized / DLL files
|
|
3
|
+
__pycache__/
|
|
4
|
+
*.py[cod]
|
|
5
|
+
*$py.class
|
|
6
|
+
|
|
7
|
+
# C extensions
|
|
8
|
+
*.so
|
|
9
|
+
|
|
10
|
+
# Distribution / packaging
|
|
11
|
+
.Python
|
|
12
|
+
build/
|
|
13
|
+
develop-eggs/
|
|
14
|
+
dist/
|
|
15
|
+
downloads/
|
|
16
|
+
eggs/
|
|
17
|
+
.eggs/
|
|
18
|
+
lib/
|
|
19
|
+
lib64/
|
|
20
|
+
parts/
|
|
21
|
+
sdist/
|
|
22
|
+
var/
|
|
23
|
+
wheels/
|
|
24
|
+
share/python-wheels/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
.installed.cfg
|
|
27
|
+
*.egg
|
|
28
|
+
MANIFEST
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
# Usually these files are written by a python script from a template
|
|
32
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
33
|
+
*.manifest
|
|
34
|
+
*.spec
|
|
35
|
+
|
|
36
|
+
# Installer logs
|
|
37
|
+
pip-log.txt
|
|
38
|
+
pip-delete-this-directory.txt
|
|
39
|
+
|
|
40
|
+
# Unit test / coverage reports
|
|
41
|
+
htmlcov/
|
|
42
|
+
.tox/
|
|
43
|
+
.nox/
|
|
44
|
+
.coverage
|
|
45
|
+
.coverage.*
|
|
46
|
+
.cache
|
|
47
|
+
nosetests.xml
|
|
48
|
+
coverage.xml
|
|
49
|
+
*.cover
|
|
50
|
+
*.py,cover
|
|
51
|
+
.hypothesis/
|
|
52
|
+
.pytest_cache/
|
|
53
|
+
cover/
|
|
54
|
+
|
|
55
|
+
# Translations
|
|
56
|
+
*.mo
|
|
57
|
+
*.pot
|
|
58
|
+
|
|
59
|
+
# Django stuff:
|
|
60
|
+
*.log
|
|
61
|
+
local_settings.py
|
|
62
|
+
db.sqlite3
|
|
63
|
+
db.sqlite3-journal
|
|
64
|
+
|
|
65
|
+
# Flask stuff:
|
|
66
|
+
instance/
|
|
67
|
+
.webassets-cache
|
|
68
|
+
|
|
69
|
+
# Scrapy stuff:
|
|
70
|
+
.scrapy
|
|
71
|
+
|
|
72
|
+
# Sphinx documentation
|
|
73
|
+
docs/_build/
|
|
74
|
+
|
|
75
|
+
# PyBuilder
|
|
76
|
+
.pybuilder/
|
|
77
|
+
target/
|
|
78
|
+
|
|
79
|
+
# Jupyter Notebook
|
|
80
|
+
.ipynb_checkpoints
|
|
81
|
+
|
|
82
|
+
# IPython
|
|
83
|
+
profile_default/
|
|
84
|
+
ipython_config.py
|
|
85
|
+
|
|
86
|
+
# pyenv
|
|
87
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
88
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
89
|
+
# .python-version
|
|
90
|
+
|
|
91
|
+
# pipenv
|
|
92
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
93
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
94
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
95
|
+
# install all needed dependencies.
|
|
96
|
+
#Pipfile.lock
|
|
97
|
+
|
|
98
|
+
# poetry
|
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
100
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
101
|
+
# commonly ignored for libraries.
|
|
102
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
103
|
+
#poetry.lock
|
|
104
|
+
|
|
105
|
+
# pdm
|
|
106
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
107
|
+
#pdm.lock
|
|
108
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
109
|
+
# in version control.
|
|
110
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
111
|
+
.pdm.toml
|
|
112
|
+
.pdm-python
|
|
113
|
+
.pdm-build/
|
|
114
|
+
|
|
115
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
116
|
+
__pypackages__/
|
|
117
|
+
|
|
118
|
+
# Celery stuff
|
|
119
|
+
celerybeat-schedule
|
|
120
|
+
celerybeat.pid
|
|
121
|
+
|
|
122
|
+
# SageMath parsed files
|
|
123
|
+
*.sage.py
|
|
124
|
+
|
|
125
|
+
# Environments
|
|
126
|
+
.env
|
|
127
|
+
.venv
|
|
128
|
+
env/
|
|
129
|
+
venv/
|
|
130
|
+
ENV/
|
|
131
|
+
env.bak/
|
|
132
|
+
venv.bak/
|
|
133
|
+
|
|
134
|
+
# Spyder project settings
|
|
135
|
+
.spyderproject
|
|
136
|
+
.spyproject
|
|
137
|
+
|
|
138
|
+
# Rope project settings
|
|
139
|
+
.ropeproject
|
|
140
|
+
|
|
141
|
+
# mkdocs documentation
|
|
142
|
+
/site
|
|
143
|
+
|
|
144
|
+
# mypy
|
|
145
|
+
.mypy_cache/
|
|
146
|
+
.dmypy.json
|
|
147
|
+
dmypy.json
|
|
148
|
+
|
|
149
|
+
# Pyre type checker
|
|
150
|
+
.pyre/
|
|
151
|
+
|
|
152
|
+
# pytype static type analyzer
|
|
153
|
+
.pytype/
|
|
154
|
+
|
|
155
|
+
# Cython debug symbols
|
|
156
|
+
cython_debug/
|
|
157
|
+
|
|
158
|
+
# PyCharm
|
|
159
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
160
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
161
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
162
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
163
|
+
#.idea/
|
|
164
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="Black">
|
|
4
|
+
<option name="sdkName" value="uv (python_template)" />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="uv (hexo)" project-jdk-type="Python SDK" />
|
|
7
|
+
</project>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/python_template.iml" filepath="$PROJECT_DIR$/.idea/python_template.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="PYTHON_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
|
7
|
+
</content>
|
|
8
|
+
<orderEntry type="jdk" jdkName="uv (hexo)" jdkType="Python SDK" />
|
|
9
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
10
|
+
</component>
|
|
11
|
+
</module>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<component name="ProjectRunConfigurationManager">
|
|
2
|
+
<configuration default="false" name="app" type="UvRunConfigurationType" factoryName="UvRunConfigurationType">
|
|
3
|
+
<option name="args">
|
|
4
|
+
<list />
|
|
5
|
+
</option>
|
|
6
|
+
<option name="checkSync" value="true" />
|
|
7
|
+
<option name="env">
|
|
8
|
+
<map />
|
|
9
|
+
</option>
|
|
10
|
+
<option name="runType" value="MODULE" />
|
|
11
|
+
<option name="scriptOrModule" value="app" />
|
|
12
|
+
<option name="uvArgs">
|
|
13
|
+
<list />
|
|
14
|
+
</option>
|
|
15
|
+
<option name="uvSdkKey" value="uv (python_template)" />
|
|
16
|
+
<method v="2" />
|
|
17
|
+
</configuration>
|
|
18
|
+
</component>
|
hexo-0.1.0/.idea/vcs.xml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
# uv.lock update and requirement.txt generation (uncomment to enable)
|
|
3
|
+
- repo: https://github.com/astral-sh/uv-pre-commit
|
|
4
|
+
rev: 0.10.0
|
|
5
|
+
hooks:
|
|
6
|
+
- id: uv-lock
|
|
7
|
+
# - id: uv-export
|
|
8
|
+
|
|
9
|
+
# Lint and format
|
|
10
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
11
|
+
rev: v0.14.14
|
|
12
|
+
hooks:
|
|
13
|
+
- id: ruff-check
|
|
14
|
+
args: [ --fix ]
|
|
15
|
+
- id: ruff-format
|
|
16
|
+
|
|
17
|
+
# Tests
|
|
18
|
+
- repo: local
|
|
19
|
+
hooks:
|
|
20
|
+
- id: pytest
|
|
21
|
+
name: pytest
|
|
22
|
+
entry: uv run pytest -q
|
|
23
|
+
language: system
|
|
24
|
+
pass_filenames: false
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Contributing to Hexo
|
|
2
|
+
|
|
3
|
+
Thanks for contributing.
|
|
4
|
+
|
|
5
|
+
## Before You Start
|
|
6
|
+
|
|
7
|
+
- Read [RULES.md](RULES.md) to align with game behavior expectations.
|
|
8
|
+
- Check existing issues and pull requests before opening new ones.
|
|
9
|
+
|
|
10
|
+
## Reporting Issues
|
|
11
|
+
|
|
12
|
+
When opening an issue, include:
|
|
13
|
+
|
|
14
|
+
- clear title and concise summary
|
|
15
|
+
- expected behavior vs actual behavior
|
|
16
|
+
- minimal reproduction steps
|
|
17
|
+
- environment details (OS, Python version, command used)
|
|
18
|
+
- logs or traceback when relevant
|
|
19
|
+
|
|
20
|
+
Use one issue per distinct bug or feature request.
|
|
21
|
+
|
|
22
|
+
## Proposing Features
|
|
23
|
+
|
|
24
|
+
- Describe the use case first, then the proposed API.
|
|
25
|
+
- Call out rule or compatibility impacts.
|
|
26
|
+
- Prefer incremental changes over large all-in-one proposals.
|
|
27
|
+
|
|
28
|
+
## Pull Request Guidelines
|
|
29
|
+
|
|
30
|
+
- Keep PRs focused and scoped to one change area.
|
|
31
|
+
- Link the related issue (for example: `Closes #12`).
|
|
32
|
+
- Add or update tests for behavior changes.
|
|
33
|
+
- Update documentation when public API or behavior changes.
|
|
34
|
+
- Ensure linting and tests pass locally before requesting review.
|
|
35
|
+
|
|
36
|
+
## Development Setup
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
uv sync
|
|
40
|
+
uv run pre-commit install
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Local Quality Checks
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
uv run pytest
|
|
47
|
+
uvx ruff check . --fix
|
|
48
|
+
uvx ruff format .
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Commit Guidance
|
|
52
|
+
|
|
53
|
+
- Use clear commit messages in imperative form.
|
|
54
|
+
- Explain why a change was made when not obvious from the diff.
|
|
55
|
+
|
|
56
|
+
## Code Review Expectations
|
|
57
|
+
|
|
58
|
+
- Be respectful and technical in review discussions.
|
|
59
|
+
- Address feedback with follow-up commits.
|
|
60
|
+
- If you disagree with feedback, document tradeoffs and rationale clearly.
|
hexo-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [2025] [Pierre LAPOLLA]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
hexo-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hexo
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A fast, reusable Python engine for Hexo on an infinite hex grid.
|
|
5
|
+
Author: Pierre LAPOLLA
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) [2025] [Pierre LAPOLLA]
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Keywords: ai,board-game,connect-six,game-engine,hex-grid,hexo
|
|
29
|
+
Requires-Python: >=3.10
|
|
30
|
+
Requires-Dist: pedros>=0.12.3
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+

|
|
34
|
+

|
|
35
|
+
|
|
36
|
+
# Hexo Engine
|
|
37
|
+
|
|
38
|
+
Hexo is a Python engine for the Hexo game played on an infinite hex grid.
|
|
39
|
+
|
|
40
|
+
The goal of this repository is to provide a clean, reusable engine API (similar in spirit to `python-chess`) so others can build bots, analysis tools, and frontends without re-implementing game logic.
|
|
41
|
+
|
|
42
|
+
Game rules are documented in [RULES.md](RULES.md).
|
|
43
|
+
Agent handoff context is documented in [AGENT_CONTEXT.md](AGENT_CONTEXT.md).
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- Deterministic game engine with strict rule validation
|
|
48
|
+
- Infinite hex-grid coordinate model
|
|
49
|
+
- Opening and turn rules enforced by the engine
|
|
50
|
+
- Win detection (connect 6 on any hex axis)
|
|
51
|
+
- Undo support for search algorithms
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
### Requirements
|
|
56
|
+
|
|
57
|
+
- [UV](https://docs.astral.sh/uv/) package manager
|
|
58
|
+
|
|
59
|
+
### Clone the repository
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
git clone https://github.com/<your-org>/hexo.git
|
|
63
|
+
cd hexo
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Initialize your environment
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
uv sync
|
|
70
|
+
uv run pre-commit install
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## API
|
|
74
|
+
|
|
75
|
+
Public entry point is the `Hexo` class.
|
|
76
|
+
|
|
77
|
+
- `Hexo.new(config=None) -> Hexo`: create a new game with `P1` already placed at `(0, 0)`.
|
|
78
|
+
- `Hexo.from_state(state, config=None) -> Hexo`: restore a game from serialized state.
|
|
79
|
+
- `game.to_state() -> dict`: serialize committed turns and any in-progress partial turn.
|
|
80
|
+
- `game.turn() -> Player`: return the player currently placing stones.
|
|
81
|
+
- `game.status() -> GameStatus`: return `ONGOING`, `P1_WON`, or `P2_WON`.
|
|
82
|
+
- `game.moves_left_in_turn() -> int`: return remaining moves in current turn (`2` or `1`).
|
|
83
|
+
- `game.pending_moves() -> tuple[Coord, ...]`: return moves already made in the current turn.
|
|
84
|
+
- `game.is_legal_move(coord) -> tuple[bool, str | None]`: validate one submove.
|
|
85
|
+
- `game.legal_moves() -> tuple[Coord, ...]`: return legal single-move candidates.
|
|
86
|
+
- `game.push(coord) -> TurnRecord | None`: play one move; returns `None` if turn is still partial, or `TurnRecord` when the turn completes (or wins early).
|
|
87
|
+
- `game.is_legal(move) -> tuple[bool, str | None]`: validate a full 2-stone move (only when no partial turn is active).
|
|
88
|
+
- `game.play(move) -> TurnRecord`: convenience wrapper that places two stones in sequence.
|
|
89
|
+
- `game.undo() -> TurnRecord`: undo the last placement (works for both partial and completed turns).
|
|
90
|
+
- `game.at(coord) -> Player | None`: inspect occupancy at a coordinate.
|
|
91
|
+
- `game.board() -> dict[Coord, Player]`: get a snapshot of all occupied coordinates.
|
|
92
|
+
|
|
93
|
+
Notes:
|
|
94
|
+
|
|
95
|
+
- `Hexo.new()` starts with `P1` already placed at `(0, 0)`.
|
|
96
|
+
- Every played turn is a 2-stone move.
|
|
97
|
+
|
|
98
|
+
## Quickstart
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from hexo import Hexo
|
|
102
|
+
|
|
103
|
+
game = Hexo.new()
|
|
104
|
+
print(game.turn()) # Player.P2
|
|
105
|
+
|
|
106
|
+
legal, reason = game.is_legal_move((1, 0))
|
|
107
|
+
if not legal:
|
|
108
|
+
raise ValueError(reason)
|
|
109
|
+
game.push((1, 0))
|
|
110
|
+
|
|
111
|
+
# Hook point for engines: run a search after first placement.
|
|
112
|
+
# ... search code here ...
|
|
113
|
+
|
|
114
|
+
record = game.push((0, 1)) # turn completes here
|
|
115
|
+
print(record) # TurnRecord
|
|
116
|
+
print(game.moves_left_in_turn()) # 2
|
|
117
|
+
|
|
118
|
+
state = game.to_state()
|
|
119
|
+
restored = Hexo.from_state(state)
|
|
120
|
+
print(restored.turn())
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Tests, linting and formatting
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
uv run pytest
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
uvx ruff check . --fix
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
uvx ruff format .
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Run all hooks manually:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
uv run pre-commit run --all-files
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Benchmarks
|
|
144
|
+
|
|
145
|
+
Benchmarking uses `pytest-benchmark` and is kept separate from normal tests.
|
|
146
|
+
|
|
147
|
+
Run benchmarks:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
uv run pytest benchmarks --benchmark-only
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Save a baseline:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
uv run pytest benchmarks --benchmark-only --benchmark-save=baseline
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Compare with a saved baseline:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
uv run pytest benchmarks --benchmark-only --benchmark-compare=baseline
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Contributing
|
|
166
|
+
|
|
167
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for:
|
|
168
|
+
|
|
169
|
+
- issue reporting guidelines
|
|
170
|
+
- feature proposal flow
|
|
171
|
+
- pull request requirements
|
|
172
|
+
- code style and testing expectations
|
|
173
|
+
|
|
174
|
+
## License
|
|
175
|
+
|
|
176
|
+
This project is licensed under the MIT [LICENSE](LICENSE)
|