diff --git a/AI_PROMPT.md b/AI_PROMPT.md new file mode 100644 index 0000000..88fcfaa --- /dev/null +++ b/AI_PROMPT.md @@ -0,0 +1,56 @@ +# Backgammon AI Move Prompt + +Use this prompt template to ask an AI model for a valid backgammon move suggestion given a board state and dice roll. + +--- + +## Prompt Template + +``` +We are playing backgammon. You are playing as {{color}} ({{color}} moves in the {{direction}} direction, from point {{start}} toward point {{end}} and then bearing off). + +### Board Configuration + +The board has 24 points numbered 1–24. Positive values represent {{positiveColor}} pieces; negative values represent {{negativeColor}} pieces. Zero means the point is empty. + +Board (point 1 to 24): +{{board}} + +Pieces in prison (hit and waiting to re-enter): +- White: {{prison.white}} +- Black: {{prison.black}} + +Pieces already borne off (home): +- White: {{home.white}} +- Black: {{home.black}} + +### Dice + +You rolled: {{dice[0]}} and {{dice[1]}} +{{#doubles}}(Doubles! You have four moves of {{dice[0]}} to use.){{/doubles}} + +### Your Task + +Choose the best legal play for this turn and respond **only** in standard backgammon notation. If no legal moves are available, respond with: `no move` +``` + +--- + +## Field Reference + +| Placeholder | Source in `Game` type | Description | +|---|---|---| +| `{{color}}` | `game.color` | Current player's color (`white` or `black`) | +| `{{board}}` | `game.board` (24-element array) | Piece counts per point; positive = white, negative = black | +| `{{prison.white}}` | `game.prison.white` | White pieces on the bar | +| `{{prison.black}}` | `game.prison.black` | Black pieces on the bar | +| `{{home.white}}` | `game.home.white` | White pieces borne off | +| `{{home.black}}` | `game.home.black` | Black pieces borne off | +| `{{dice[0]}}`, `{{dice[1]}}` | `game.dice` | The two dice values rolled | + +### Direction by Color + +| Color | Moves toward | Entry range | Home board | +|---|---|---|---| +| White | Point 24 → 1, then off | Points 19–24 | Points 1–6 | +| Black | Point 1 → 24, then off | Points 1–6 | Points 19–24 | diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 7fa61f5..2f681a2 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -27,5 +27,7 @@ "notificationsDisabled": "Notifications Disabled", "notificationsEnabled": "Notifications Enabled", "enableNotifications": "Enable Notifications", - "privacyPolicy": "Privacy Policy" + "privacyPolicy": "Privacy Policy", + "aiOpponent": "AI Opponent", + "aiComingSoon": "Coming soon — pick your model" } diff --git a/src/Dialogues/Friends.css b/src/Dialogues/Friends.css index 5f0164d..05cf606 100644 --- a/src/Dialogues/Friends.css +++ b/src/Dialogues/Friends.css @@ -71,6 +71,11 @@ overflow: hidden; text-overflow: ellipsis; } + &.ai-opponent { + opacity: 0.5; + cursor: not-allowed; + pointer-events: none; + } > svg, > img { width: 4em; height: 4em; diff --git a/src/Dialogues/Friends.tsx b/src/Dialogues/Friends.tsx index 7174aee..425ff9d 100644 --- a/src/Dialogues/Friends.tsx +++ b/src/Dialogues/Friends.tsx @@ -22,6 +22,8 @@ import NotificationsOffIcon from '@material-design-icons/svg/filled/notification import NotificationsActiveIcon from '@material-design-icons/svg/filled/notifications_active.svg?react'; import CircleNotificationsIcon from '@material-design-icons/svg/filled/circle_notifications.svg?react'; import LocalIcon from '@material-design-icons/svg/filled/location_on.svg?react'; +import SmartToyIcon from '@material-design-icons/svg/filled/smart_toy.svg?react'; +import AutoAwesomeIcon from '@material-design-icons/svg/filled/auto_awesome.svg?react'; import RestartAltIcon from '@material-design-icons/svg/filled/restart_alt.svg?react'; import BugReportIcon from '@material-design-icons/svg/filled/bug_report.svg?react'; import InfoIcon from '@material-design-icons/svg/filled/info.svg?react'; @@ -327,6 +329,16 @@ export default function Friends({ user, load, reset, friend }: FriendsProps) { {t('local')} : null} +
  • + + + + +
    +

    {t('aiOpponent')}

    + +
    +
  • {[...myTurnFriends, ...renderFriends]} diff --git a/src/index.css b/src/index.css index aa1b37f..c190b4e 100644 --- a/src/index.css +++ b/src/index.css @@ -91,6 +91,31 @@ body, } } +.ai-icon { + position: relative; + display: inline-flex; + flex-shrink: 0; + width: 4em; + height: 4em; + + > .material-icons-svg { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + fill: var(--primary); + } + + > .material-icons-svg:last-child { + top: 30%; + left: 30%; + width: 55%; + height: 55%; + fill: white; + filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); + } +} + .offline-icon { position: relative; display: inline-flex;