|
| 1 | +# Actions Reference |
| 2 | + |
| 3 | +Complete reference for all available actions in Balatrobot. |
| 4 | + |
| 5 | +## 📋 Table of Contents |
| 6 | + |
| 7 | +- [Overview](#overview) |
| 8 | +- [Action Format](#action-format) |
| 9 | +- [Blind Actions](#blind-actions) |
| 10 | +- [Hand Actions](#hand-actions) |
| 11 | +- [Shop Actions](#shop-actions) |
| 12 | +- [Joker Actions](#joker-actions) |
| 13 | +- [Consumable Actions](#consumable-actions) |
| 14 | +- [Booster Actions](#booster-actions) |
| 15 | +- [Arrangement Actions](#arrangement-actions) |
| 16 | +- [Examples](#examples) |
| 17 | + |
| 18 | +## Overview |
| 19 | + |
| 20 | +Actions in Balatrobot are represented as lists that tell the game what to do. Each action follows a specific format and is returned from bot methods to control game behavior. |
| 21 | + |
| 22 | +All actions are defined in the `Actions` enum and should be imported: |
| 23 | + |
| 24 | +```python |
| 25 | +from bot import Bot, Actions |
| 26 | +``` |
| 27 | + |
| 28 | +## Action Format |
| 29 | + |
| 30 | +Actions follow this general format: |
| 31 | + |
| 32 | +```python |
| 33 | +[Actions.ACTION_TYPE, [parameters], [additional_parameters]] |
| 34 | +``` |
| 35 | + |
| 36 | +- First element: Action type from `Actions` enum |
| 37 | +- Second element: List of parameters (often indices) |
| 38 | +- Third element: Additional parameters when needed |
| 39 | + |
| 40 | +## Blind Actions |
| 41 | + |
| 42 | +### SELECT_BLIND |
| 43 | +Select the current blind to play. |
| 44 | + |
| 45 | +```python |
| 46 | +def skip_or_select_blind(self, G): |
| 47 | + return [Actions.SELECT_BLIND] |
| 48 | +``` |
| 49 | + |
| 50 | +### SKIP_BLIND |
| 51 | +Skip the current blind (forfeit ante). |
| 52 | + |
| 53 | +```python |
| 54 | +def skip_or_select_blind(self, G): |
| 55 | + return [Actions.SKIP_BLIND] |
| 56 | +``` |
| 57 | + |
| 58 | +## Hand Actions |
| 59 | + |
| 60 | +### PLAY_HAND |
| 61 | +Play selected cards from hand. |
| 62 | + |
| 63 | +```python |
| 64 | +def select_cards_from_hand(self, G): |
| 65 | + # Play cards at indices 1 and 3 (1-based indexing) |
| 66 | + return [Actions.PLAY_HAND, [1, 3]] |
| 67 | +``` |
| 68 | + |
| 69 | +### DISCARD_HAND |
| 70 | +Discard selected cards from hand. |
| 71 | + |
| 72 | +```python |
| 73 | +def select_cards_from_hand(self, G): |
| 74 | + # Discard cards at indices 2, 4, 5 |
| 75 | + return [Actions.DISCARD_HAND, [2, 4, 5]] |
| 76 | +``` |
| 77 | + |
| 78 | +## Shop Actions |
| 79 | + |
| 80 | +### BUY_CARD |
| 81 | +Purchase a card from the shop. |
| 82 | + |
| 83 | +```python |
| 84 | +def select_shop_action(self, G): |
| 85 | + # Buy the first card in shop |
| 86 | + return [Actions.BUY_CARD, [1]] |
| 87 | +``` |
| 88 | + |
| 89 | +### BUY_VOUCHER |
| 90 | +Purchase a voucher from the shop. |
| 91 | + |
| 92 | +```python |
| 93 | +def select_shop_action(self, G): |
| 94 | + # Buy the first voucher |
| 95 | + return [Actions.BUY_VOUCHER, [1]] |
| 96 | +``` |
| 97 | + |
| 98 | +### BUY_BOOSTER |
| 99 | +Purchase a booster pack from the shop. |
| 100 | + |
| 101 | +```python |
| 102 | +def select_shop_action(self, G): |
| 103 | + # Buy the first booster pack |
| 104 | + return [Actions.BUY_BOOSTER, [1]] |
| 105 | +``` |
| 106 | + |
| 107 | +### REROLL_SHOP |
| 108 | +Reroll the shop contents (costs money). |
| 109 | + |
| 110 | +```python |
| 111 | +def select_shop_action(self, G): |
| 112 | + return [Actions.REROLL_SHOP] |
| 113 | +``` |
| 114 | + |
| 115 | +### END_SHOP |
| 116 | +Exit the shop phase. |
| 117 | + |
| 118 | +```python |
| 119 | +def select_shop_action(self, G): |
| 120 | + return [Actions.END_SHOP] |
| 121 | +``` |
| 122 | + |
| 123 | +## Joker Actions |
| 124 | + |
| 125 | +### SELL_JOKER |
| 126 | +Sell jokers for money. |
| 127 | + |
| 128 | +```python |
| 129 | +def sell_jokers(self, G): |
| 130 | + # Sell jokers at positions 1 and 3 |
| 131 | + return [Actions.SELL_JOKER, [1, 3]] |
| 132 | + |
| 133 | + # Sell no jokers |
| 134 | + return [Actions.SELL_JOKER, []] |
| 135 | +``` |
| 136 | + |
| 137 | +### REARRANGE_JOKERS |
| 138 | +Reorder jokers (usually no parameters needed). |
| 139 | + |
| 140 | +```python |
| 141 | +def rearrange_jokers(self, G): |
| 142 | + return [Actions.REARRANGE_JOKERS, []] |
| 143 | +``` |
| 144 | + |
| 145 | +## Consumable Actions |
| 146 | + |
| 147 | +### USE_CONSUMABLE |
| 148 | +Use a consumable card (tarot, planet, spectral). |
| 149 | + |
| 150 | +```python |
| 151 | +def use_or_sell_consumables(self, G): |
| 152 | + # Use consumable at index 1, targeting cards at indices 2 and 4 |
| 153 | + return [Actions.USE_CONSUMABLE, [1], [2, 4]] |
| 154 | + |
| 155 | + # Use consumable without targets |
| 156 | + return [Actions.USE_CONSUMABLE, [1], []] |
| 157 | + |
| 158 | + # Do nothing |
| 159 | + return [Actions.USE_CONSUMABLE, []] |
| 160 | +``` |
| 161 | + |
| 162 | +### SELL_CONSUMABLE |
| 163 | +Sell a consumable card for money. |
| 164 | + |
| 165 | +```python |
| 166 | +def use_or_sell_consumables(self, G): |
| 167 | + # Sell consumable at index 1 |
| 168 | + return [Actions.SELL_CONSUMABLE, [1]] |
| 169 | +``` |
| 170 | + |
| 171 | +### REARRANGE_CONSUMABLES |
| 172 | +Reorder consumable cards. |
| 173 | + |
| 174 | +```python |
| 175 | +def rearrange_consumables(self, G): |
| 176 | + return [Actions.REARRANGE_CONSUMABLES, []] |
| 177 | +``` |
| 178 | + |
| 179 | +## Booster Actions |
| 180 | + |
| 181 | +### SELECT_BOOSTER_CARD |
| 182 | +Select a card from an opened booster pack. |
| 183 | + |
| 184 | +```python |
| 185 | +def select_booster_action(self, G): |
| 186 | + # Select card 1 from booster, place at position 2 |
| 187 | + return [Actions.SELECT_BOOSTER_CARD, [1], [2]] |
| 188 | +``` |
| 189 | + |
| 190 | +### SKIP_BOOSTER_PACK |
| 191 | +Skip the current booster pack without selecting. |
| 192 | + |
| 193 | +```python |
| 194 | +def select_booster_action(self, G): |
| 195 | + return [Actions.SKIP_BOOSTER_PACK] |
| 196 | +``` |
| 197 | + |
| 198 | +## Arrangement Actions |
| 199 | + |
| 200 | +### REARRANGE_HAND |
| 201 | +Reorder cards in hand. |
| 202 | + |
| 203 | +```python |
| 204 | +def rearrange_hand(self, G): |
| 205 | + return [Actions.REARRANGE_HAND, []] |
| 206 | +``` |
| 207 | + |
| 208 | +## Examples |
| 209 | + |
| 210 | +### Conditional Actions Based on Game State |
| 211 | + |
| 212 | +```python |
| 213 | +def select_cards_from_hand(self, G): |
| 214 | + hand = G["hand"] |
| 215 | + money = G["player"]["money"] |
| 216 | + |
| 217 | + # Play high-value cards if we need money |
| 218 | + if money < 5: |
| 219 | + high_cards = [i+1 for i, card in enumerate(hand) |
| 220 | + if card["rank"] in ["King", "Queen", "Jack"]] |
| 221 | + if high_cards: |
| 222 | + return [Actions.PLAY_HAND, high_cards[:2]] |
| 223 | + |
| 224 | + # Otherwise discard low cards |
| 225 | + low_cards = [i+1 for i, card in enumerate(hand) |
| 226 | + if card["rank"] in ["2", "3", "4"]] |
| 227 | + return [Actions.DISCARD_HAND, low_cards[:3]] |
| 228 | +``` |
| 229 | + |
| 230 | +### Smart Shop Decisions |
| 231 | + |
| 232 | +```python |
| 233 | +def select_shop_action(self, G): |
| 234 | + money = G["player"]["money"] |
| 235 | + shop_cards = G["shop"]["cards"] |
| 236 | + |
| 237 | + # Buy affordable jokers first |
| 238 | + for i, card in enumerate(shop_cards): |
| 239 | + if card["type"] == "joker" and card["price"] <= money: |
| 240 | + return [Actions.BUY_CARD, [i+1]] |
| 241 | + |
| 242 | + # Reroll if we have extra money |
| 243 | + if money > 10: |
| 244 | + return [Actions.REROLL_SHOP] |
| 245 | + |
| 246 | + return [Actions.END_SHOP] |
| 247 | +``` |
| 248 | + |
| 249 | +--- |
| 250 | + |
| 251 | +*For more examples and patterns, see [Bot Development Guide](bot-development.md) and [Examples](examples.md).* |
0 commit comments