Skip to content

Commit 5e923ba

Browse files
committed
Mixed Python/Rust
1 parent 6148e1f commit 5e923ba

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

gomori-py/pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ classifiers = [
1414

1515
[tool.maturin]
1616
features = ["pyo3/extension-module"]
17+
python-source = "python"
18+
module-name = "gomori._gomori"

gomori-py/python/gomori/__init__.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from gomori._gomori import *
2+
from typing import List
3+
4+
class Bot():
5+
def new_game(self, color: Color):
6+
raise NotImplementedError()
7+
8+
def play_first_turn(cards: List[Card]) -> Card:
9+
raise NotImplementedError()
10+
11+
def play_turn(
12+
cards: List[Card],
13+
board: Board,
14+
cards_won_by_opponent: CardsSet
15+
) -> PlayTurnResponse:
16+
raise NotImplementedError()

gomori-py/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ use pyo3::prelude::*;
22

33
/// A Python module implemented in Rust.
44
#[pymodule]
5+
#[pyo3(name = "_gomori")]
56
fn gomori(py: Python, m: &PyModule) -> PyResult<()> {
67
m.add(
78
"IllegalCardPlayed",
89
py.get_type::<::gomori::IllegalCardPlayedException>(),
910
)?;
11+
m.add(
12+
"IllegalMove",
13+
py.get_type::<::gomori::IllegalMoveException>(),
14+
)?;
1015
m.add_class::<::gomori::BitBoard>()?;
1116
m.add_class::<::gomori::Board>()?;
1217
m.add_class::<::gomori::BoundingBox>()?;
@@ -16,6 +21,7 @@ fn gomori(py: Python, m: &PyModule) -> PyResult<()> {
1621
m.add_class::<::gomori::Color>()?;
1722
m.add_class::<::gomori::CompactField>()?;
1823
m.add_class::<::gomori::Field>()?;
24+
m.add_class::<::gomori::PlayTurnResponse>()?;
1925
m.add_class::<::gomori::PyCalculatedEffects>()?;
2026
m.add_class::<::gomori::Rank>()?;
2127
m.add_class::<::gomori::Suit>()?;

0 commit comments

Comments
 (0)