App¶
patiencepilot.app ¶
Application orchestration between UI adapters and core game modules.
AdviceProvider ¶
Bases: Protocol
Protocol for components that produce advice from player-known state.
Source code in src/patiencepilot/solvers/base.py
128 129 130 131 132 133 | |
suggest ¶
suggest(
view: PlayerView, *, limit: SearchLimit | None = None
) -> Advice
Return move advice using only the supplied player-known view.
Source code in src/patiencepilot/solvers/base.py
131 132 133 | |
SerializedSession ¶
Bases: TypedDict
JSON-compatible game-session payload.
Source code in src/patiencepilot/app.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
ValidationReport
dataclass
¶
Validation result suitable for UI display.
Source code in src/patiencepilot/app.py
53 54 55 56 57 58 59 60 | |
PatiencePilotApp
dataclass
¶
Small application service for UI and adapter workflows.
Source code in src/patiencepilot/app.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
select_variant ¶
select_variant(
name: str, options: VariantOptions | None = None
) -> Variant
Select the variant used for newly created sessions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Registered variant name. |
required |
options
|
VariantOptions | None
|
Variant-specific option values. |
None
|
Source code in src/patiencepilot/app.py
72 73 74 75 76 77 78 79 80 81 82 | |
select_solver ¶
select_solver(name: str = 'dummy') -> AdviceProvider
Select the advice provider used for future advice requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Registered solver name or alias. |
'dummy'
|
Source code in src/patiencepilot/app.py
84 85 86 87 88 89 90 91 | |
new_session ¶
new_session(
*,
seed: Seed = None,
metadata: Mapping[str, object] | None = None,
ui_state: Mapping[str, object] | None = None,
) -> GameSession
Create, store, and return a new session for the selected variant.
Source code in src/patiencepilot/app.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
use_session ¶
use_session(session: GameSession) -> GameSession
Store an existing session and sync selected variant metadata.
Source code in src/patiencepilot/app.py
110 111 112 113 114 115 116 | |
validate ¶
validate(
state: GameState | None = None,
) -> ValidationReport
Validate a state or the active session state without raising.
Source code in src/patiencepilot/app.py
118 119 120 121 122 123 124 125 126 127 | |
apply_move ¶
apply_move(move: Move) -> MoveResult
Apply move to the active session.
Source code in src/patiencepilot/app.py
129 130 131 | |
undo ¶
undo() -> GameSession
Undo the active session's most recent move and return the session.
Source code in src/patiencepilot/app.py
133 134 135 136 137 | |
redo ¶
redo() -> MoveResult
Redo the active session's most recently undone move.
Source code in src/patiencepilot/app.py
139 140 141 | |
export_session ¶
export_session(
session: GameSession | None = None,
*,
seen_cards: Iterable[Card] | None = None,
) -> SerializedSession
Return a serialized payload for session or the active session.
Source code in src/patiencepilot/app.py
143 144 145 146 147 148 149 150 | |
import_session ¶
import_session(data: Mapping[str, object]) -> GameSession
Import, store, and return a session payload.
Source code in src/patiencepilot/app.py
152 153 154 155 156 | |
request_advice ¶
request_advice(
*,
provider: AdviceProvider | None = None,
limit: SearchLimit | None = None,
seen_cards: Iterable[Card] | None = None,
) -> Advice
Request advice for the active session from an advice provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
AdviceProvider | None
|
Optional provider to use for this request. When omitted,
the configured |
None
|
limit
|
SearchLimit | None
|
Optional solver search limits. |
None
|
seen_cards
|
Iterable[Card] | None
|
Optional cards known from earlier observation history. |
None
|
Source code in src/patiencepilot/app.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
export_session ¶
export_session(
session: GameSession,
*,
seen_cards: Iterable[Card] | None = None,
) -> SerializedSession
Return a JSON-compatible session payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
GameSession
|
Session to export. |
required |
seen_cards
|
Iterable[Card] | None
|
Cards known to the player from earlier observation history.
When omitted, |
None
|
Source code in src/patiencepilot/app.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
import_session ¶
import_session(data: Mapping[str, object]) -> GameSession
Return a session from a serialized payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Mapping[str, object]
|
Session payload created by :func: |
required |
Raises:
| Type | Description |
|---|---|
NotationError
|
If the payload cannot be imported. |
Source code in src/patiencepilot/app.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
migrate_session_payload ¶
migrate_session_payload(
data: Mapping[str, object],
) -> dict[str, object]
Return a best-effort alpha migration to session schema version 1.
Source code in src/patiencepilot/app.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
validate_session_payload ¶
validate_session_payload(
data: Mapping[str, object],
) -> ValidationReport
Validate a serialized session payload without raising.
Source code in src/patiencepilot/app.py
298 299 300 301 302 303 304 | |
validate_state_payload ¶
validate_state_payload(
data: Mapping[str, object],
) -> ValidationReport
Validate a serialized state payload without raising.
Source code in src/patiencepilot/app.py
307 308 309 310 311 312 313 314 315 316 317 318 | |