Skip to main content

Python SDK for 三國志略 (Histrategy) — AI-powered Three Kingdoms strategy game engine

Project description

histrategy-sdk

Python SDK for 三國志略 (Histrategy) — AI-powered Three Kingdoms strategy game.

pip install histrategy-sdk

Quick Start

Server Client (HTTP)

from histrategy_sdk import ServerClient

client = ServerClient()

# Create a new game as Shu Han (刘备)
game = client.create_game(faction="shu")
print(game["narrative"])
# → "建安十二年冬,刘备屯兵新野,寄居刘表麾下..."

# Get strategic suggestions
plan = client.get_plan(game["game_id"])
for s in plan["suggestions"]:
    print(f"  • {s}")

# Execute a command
result = client.execute_command(game["game_id"], "联吴抗曹,攻打襄阳")
print(result["narrative"])
print(f"Token usage: {result['token_usage']}")

Direct Engine (In-Process)

pip install histrategy-sdk[engine]
from histrategy_sdk import DirectEngine

engine = DirectEngine(faction="cao")  # Play as 曹操
intro = engine.get_intro()
result = engine.execute("南征刘备,先取新野")

# Save game state
save = engine.to_dict()

# Restore later
engine2 = DirectEngine.from_dict(save)

API Reference

ServerClient

Method Description
create_game(faction, scenario) Create new game → GameIntro
get_plan(game_id) Get advisor suggestions → PlanData
execute_command(game_id, decision) Process turn → TurnResult
get_status(game_id) Get faction resources → FactionStatus
restore_game(world_state) Restore from save → RestoreResult
health() Check server status

DirectEngine

Method Description
DirectEngine(faction, llm_api_key) Create new in-process engine
get_intro() Get intro scene → GameIntro
get_plan() Get suggestions → PlanData
execute(decision) Process turn → TurnResult
get_status() Get faction status → FactionStatus
to_dict() Serialize game state
DirectEngine.from_dict(data) Restore from saved state

TurnResult

Field Type Description
narrative str AI-generated historical chronicle
aftermath str Resource changes summary
state_changes dict Numerical state deltas
new_suggestions list[str] Next-turn strategy suggestions
token_usage TokenUsage LLM token consumption
game_over dict | None Victory/defeat message
faction_status FactionStatus Current resources and territories

License

MIT — Emergence Science

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

histrategy_sdk-0.1.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

histrategy_sdk-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file histrategy_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: histrategy_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for histrategy_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 af340b7ae18b77ed5a8d1e75bcf3439dc41a566d8a3a4c97427dba039d673405
MD5 4c982ae50a4a502664b860e2f3a5f191
BLAKE2b-256 a897474f059349540d5bff74320ae66d994535803d1d0ff05e7d7e682a956234

See more details on using hashes here.

File details

Details for the file histrategy_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: histrategy_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for histrategy_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da2db82808d8ad8cf19dad61bdf033c8fd1fdf7e0860a1025c8dafb23065eadb
MD5 e2016c3eb14b7e9a363c67d65366f744
BLAKE2b-256 c37c0a0f14309fac35dc65176305287270c684c843363a1941c54b2c2baa4b57

See more details on using hashes here.

Supported by

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