Skip to content

๐Ÿ’ช Reinforce strategies

coccoinomane edited this page May 14, 2022 · 1 revision

Crabada can be played in different ways, especially when it comes to reinforcing.

Choose the strategy to use with the USER_X_TEAM_Y_REINFORCE_STRATEGY parameter in .env:

Name Description Notes Credits
NoReinforce Do not reinforce Useful to spare gas
HighestBp Highest-BP low-cost crab Good for looting on a budget
HighestMp Highest-MP low-cost crab Good for mining on a budget
HighestBpHighCost Highest-BP crab Use with high max price @coinmasterlisting
HighestMpHighCost Highest-MP crab Use with high max price @coinmasterlisting
CheapestCrab Cheapest crab Get a chance at mining revenge
HighestBpFromInventory Highest-BP from the inventory Use with a fallback strat @yigitest
HighestMpFromInventory Highest-MP from the inventory Use with a fallback strat @yigitest
FirstFromInventory First available crab in the inventory Use with a fallback strat @yigitest

- Fallback strategies

Sometimes a strategy will not be able to find a suitable crab. For example, a high-cost strategy might return a crab that is too expensive for the user, or an inventory strategy might fail because thereย are no free crabs in the user's inventory.

To account for these cases, you can specify multiple strategies as comma-separated values. For example, if you specify:

USER_X_TEAM_Y_REINFORCE_STRATEGY="HighestBpFromInventory, HighestBpHighCost, HighestBp"

Then, the bot will:

  1. Attempt to self-reinforce with a high-BP crab from the user's inventory.
  2. If there are no free crabs in the inventory, attempt to borrow the highest-BP crab in the tavern.
  3. If the highest-BP crab is too expensive, attempt to borrow the highest-BP among the cheapest crabs in the tavern.

- Avoid the competition

The Highest non-inventory strategies support the optional parameter REINFORCEMENT_TO_PICK. Set it to 2, 3, 4 to pick the 2nd, 3rd, 4th-best crab, and so on. Since most bots will compete for the first crab, setting this parameter to a higher-than-1 value can reduce the risk of a reverted transaction. Use this strategy if you constantly fail to get the first crab.

Important: No matter which strategy you choose, the bot will never borrow a crab that is more expensive than REINFORCEMENT_MAX_PRICE.

- Create your own strategy

Creating a strategy is very simple:

  1. Duplicate a strategy you like and pick a class name.
  2. Customize the three methods in the class: query(), process() and pick().
  3. Make sure your strategy never borrows crabs more expensive than USER_X_REINFORCEMENT_MAX_PRICE.
  4. Add the strategy name to the list in the file ReinforceStrategyFactory.py
  5. Configure .env to use your new strategy via the USER_X_TEAM_Y_REINFORCE_STRATEGY parameter.

To test the strategy withouth sending transactions, use the testMakeReinforceStrategy.py script.

Clone this wiki locally