44a predefined sequence of actions.
55"""
66
7+ import argparse
78import itertools
89from typing import Any , Iterator
910
10- from balatrobot import Actions , ActionSchema , Bot , Decks , Stakes
11+ from balatrobot import Actions , ActionSchema , Bot , Decks , Stakes , configure_bot_logging
1112
12- # Predefined sequence of actions using the ActionSchema format
13+ # Predefined sequence of actions using the ActionCall format
1314plays : Iterator [ActionSchema ] = itertools .cycle (
1415 [
1516 # This sequence of plays is winning for the first round
2223)
2324
2425
25- class MyFirstBot (Bot ):
26- """Example bot implementation using the ActionSchema API.
26+ class ExampleBot (Bot ):
27+ """Example bot implementation using the ActionCall API.
2728
2829 This bot demonstrates a simple strategy using predefined actions.
2930 It always selects blinds, uses a fixed sequence of plays, and
@@ -42,9 +43,9 @@ def __init__(
4243 """Initialize the bot with default settings.
4344
4445 Args:
45- deck (Decks) : The deck type to use.
46- stake (Stakes) : The stake level to play at.
47- seed (str) : The random seed for the game.
46+ deck: The deck type to use.
47+ stake: The stake level to play at.
48+ seed: The random seed for the game.
4849 """
4950 super ().__init__ (deck = deck , stake = stake , seed = seed )
5051 self .round_count : int = 0
@@ -56,7 +57,7 @@ def skip_or_select_blind(self, env: dict[str, Any]) -> ActionSchema:
5657 env (dict[str, Any]): The current game environment state.
5758
5859 Returns:
59- ActionSchema : Action to select blind.
60+ ActionCall : Action to select blind.
6061 """
6162 return {"action" : Actions .SELECT_BLIND , "args" : None }
6263
@@ -67,7 +68,7 @@ def select_cards_from_hand(self, env: dict[str, Any]) -> ActionSchema:
6768 env (dict[str, Any]): The current game environment state.
6869
6970 Returns:
70- ActionSchema : Action with card selection from predefined sequence.
71+ ActionCall : Action with card selection from predefined sequence.
7172 """
7273 return next (plays )
7374
@@ -78,7 +79,7 @@ def select_shop_action(self, env: dict[str, Any]) -> ActionSchema:
7879 env (dict[str, Any]): The current game environment state.
7980
8081 Returns:
81- ActionSchema : Action to end shop.
82+ ActionCall : Action to end shop.
8283 """
8384 return {"action" : Actions .END_SHOP , "args" : None }
8485
@@ -89,7 +90,7 @@ def select_booster_action(self, env: dict[str, Any]) -> ActionSchema:
8990 env (dict[str, Any]): The current game environment state.
9091
9192 Returns:
92- ActionSchema : Action to skip booster pack.
93+ ActionCall : Action to skip booster pack.
9394 """
9495 return {"action" : Actions .SKIP_BOOSTER_PACK , "args" : None }
9596
@@ -100,7 +101,7 @@ def sell_jokers(self, env: dict[str, Any]) -> ActionSchema:
100101 env (dict[str, Any]): The current game environment state.
101102
102103 Returns:
103- ActionSchema : Action to sell jokers with empty list.
104+ ActionCall : Action to sell jokers with empty list.
104105 """
105106 return {"action" : Actions .SELL_JOKER , "args" : []}
106107
@@ -111,7 +112,7 @@ def rearrange_jokers(self, env: dict[str, Any]) -> ActionSchema:
111112 env (dict[str, Any]): The current game environment state.
112113
113114 Returns:
114- ActionSchema : Action to rearrange jokers with empty list.
115+ ActionCall : Action to rearrange jokers with empty list.
115116 """
116117 return {"action" : Actions .REARRANGE_JOKERS , "args" : []}
117118
@@ -122,7 +123,7 @@ def use_or_sell_consumables(self, env: dict[str, Any]) -> ActionSchema:
122123 env (dict[str, Any]): The current game environment state.
123124
124125 Returns:
125- ActionSchema : Action to use consumables with empty list.
126+ ActionCall : Action to use consumables with empty list.
126127 """
127128 return {"action" : Actions .USE_CONSUMABLE , "args" : []}
128129
@@ -133,7 +134,7 @@ def rearrange_consumables(self, env: dict[str, Any]) -> ActionSchema:
133134 env (dict[str, Any]): The current game environment state.
134135
135136 Returns:
136- ActionSchema : Action to rearrange consumables with empty list.
137+ ActionCall : Action to rearrange consumables with empty list.
137138 """
138139 return {"action" : Actions .REARRANGE_CONSUMABLES , "args" : []}
139140
@@ -144,13 +145,27 @@ def rearrange_hand(self, env: dict[str, Any]) -> ActionSchema:
144145 env (dict[str, Any]): The current game environment state.
145146
146147 Returns:
147- ActionSchema : Action to rearrange hand with empty list.
148+ ActionCall : Action to rearrange hand with empty list.
148149 """
149150 return {"action" : Actions .REARRANGE_HAND , "args" : []}
150151
151152
152153def main () -> None :
153- bot = MyFirstBot ()
154+ """Main function to run the example bot with command-line argument support."""
155+ parser = argparse .ArgumentParser (description = "Run the example Balatro bot" )
156+ parser .add_argument (
157+ "--log" ,
158+ choices = ["DEBUG" , "INFO" , "WARNING" , "ERROR" ],
159+ default = "DEBUG" ,
160+ help = "Set the console logging level (default: DEBUG)" ,
161+ )
162+
163+ args = parser .parse_args ()
164+
165+ # Configure logging with the specified level
166+ configure_bot_logging (args .log )
167+
168+ bot = ExampleBot ()
154169 bot .running = True
155170 bot .run ()
156171
0 commit comments