DarshanScripts commited on
Commit
cb36650
·
verified ·
1 Parent(s): d938aed

Upload stratego/prompts/presets.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. stratego/prompts/presets.py +88 -0
stratego/prompts/presets.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from __future__ import annotations
3
+ from dataclasses import dataclass
4
+ from typing import Dict
5
+
6
+ @dataclass(frozen=True)
7
+ class PromptPack:
8
+ name: str
9
+ system: str
10
+ guidance_template: str
11
+
12
+ def guidance(self, board_slice: str) -> str:
13
+ return self.guidance_template.format(board_slice=board_slice)
14
+
15
+ BASE = PromptPack(
16
+ name="base",
17
+ system=(
18
+ "You are a Stratego-playing agent.\n"
19
+ "You MUST output exactly ONE move and NOTHING ELSE.\n"
20
+ "The move MUST be in the format [A0 B0].\n"
21
+ # "The move MUST be one of the legal moves listed under 'Available Moves:'.\n"
22
+ "The move MUST be legal'.\n"
23
+ ),
24
+ guidance_template=(
25
+ "{board_slice}\n\n"
26
+ "RULES:\n"
27
+ "- You cannot control opponent's pieces yourself'.\n"
28
+ "- You cannot move your Flag and Bombs.\n"
29
+ "- You cannot move your pieces upon your other pieces.\n"
30
+ "- You cannot move your pieces diagonally.\n"
31
+ "- Output exactly one move in the format [A0 B0].\n"
32
+ "- No commentary. No extra spaces or lines.\n"
33
+ "- If multiple moves seem good, choose any ONE of them.\n"
34
+ "\n"
35
+ "ANSWER:\n"
36
+ ),
37
+ )
38
+
39
+ # TODO: write down proper concise and adaptive prompt which could be implemented to the game.
40
+ # You can refer my original base prompt from original code which I set here as BASE prompt.
41
+ # Your prompts would be exported to all codes by using __init__.py.
42
+
43
+ CONCISE = PromptPack(
44
+ name="concise",
45
+ system="Stratego agent. Output exactly one legal move like [SRC DST].",
46
+ guidance_template=(
47
+ "{board_slice}\n\n"
48
+ "INSTRUCTIONS:\n"
49
+ "- Choose exactly ONE move from the 'Available Moves:' section above.\n"
50
+ "- Do NOT choose any move listed under 'FORBIDDEN' (if present).\n"
51
+ "- Prefer captures that are likely to win, or otherwise prefer safe advancement.\n"
52
+ "- Avoid exposing high-value pieces to obvious captures.\n"
53
+ "- Output ONLY the move in format [A0 B0] and nothing else.\n"
54
+ ),
55
+ )
56
+
57
+
58
+ ADAPTIVE = PromptPack(
59
+ name="adaptive",
60
+ system=(
61
+ "You are an expert Stratego agent. Consider captures, threats, and safe advancement.\n"
62
+ "Output exactly one legal move [SRC DST]."
63
+ ),
64
+ guidance_template=(
65
+ "{board_slice}\n\n"
66
+ "GUIDANCE (ADAPTIVE):\n"
67
+ "- Consider immediate captures first: prefer trades that win material or remove high-value opponents.\n"
68
+ "- Assess risk: avoid moves that expose your high-rank pieces to probable capture.\n"
69
+ "- Prioritize safe advancement and creating or denying threats when captures are unclear.\n"
70
+ "- Respect 'FORBIDDEN' moves (do not choose them) and choose only from 'Available Moves:'.\n"
71
+ "- If multiple moves are comparable, prefer those that increase mobility or secure key squares.\n"
72
+ "- Output ONLY the chosen move in format [A0 B0] and nothing else.\n"
73
+ ),
74
+ )
75
+
76
+ _REGISTRY: Dict[str, PromptPack] = {
77
+ BASE.name: BASE,
78
+ CONCISE.name: CONCISE,
79
+ ADAPTIVE.name: ADAPTIVE,
80
+ }
81
+
82
+ def get_prompt_pack(name: str | None) -> PromptPack:
83
+ if not name:
84
+ return BASE
85
+ key = name.lower()
86
+ if key not in _REGISTRY:
87
+ return BASE
88
+ return _REGISTRY[key]