Skip to content

Rubenmp/GrowCastleBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grow Castle bot

Bot for the game Grow Castle. It uses phone mirroring with image recognition to interact with the game. The default behaviour is to replay the last wave indefinitely.

Grow Castle Bot Demo

Features

Most of the features can be customized with configuration variables in file GrowCastle.py.

  • Waves
    • Infinite waves, selection behaviour using the variable waves_selection_pattern, possible values:
      • REPLAY: always replay the last wave
      • BATTLE: continue with the next waves
      • MIXED: 1/10 combination of both scenarios (one BATTLE every 10 rounds, the other 9 waves will be REPLAY)
    • Game speed will be increased automatically if possible.
    • Click on the treasures found in the waves.
  • Watch advertisements depending on variable watch_advertisements (default True).
  • Update features
    • Coins: upgrade castle. It depends on variable upgrade_castle_periodically
    • Diamonds: upgrade castle canons. It depends on variable spend_diamonds_on_canons (default True). If the variable is False it could potentially lose diamonds due to the amount limit.

Requirements

You must have several programs installed in your computer:

  • Install an emulator to mirror your phone into your computer.
  • Install Sikulix for image recognition and interface interactions.
  • (Optional) Basic knowledge about Python scripting language if you want to modify the behaviour.
  • Donwload GrowCastleBot

Execution

Run the phone emulator on your computer (connecting your phone using USB)

$ scrcpy

Open a terminal in GrowCastleBot root folder and execute the bot (SIKULIX_JAR_DIR is the installation folder of SikuliX):

$ java -jar SIKULIX_JAR_DIR/sikulixide-2.0.5.jar -r GrowCastle.sikuli

(Optional) In the demo video an alias RunGrowCastleBot was created and executed.

$ alias RunGrowCastleBot='java -jar SIKULIX_JAR_DIR/sikulixide-2.0.5.jar -r GrowCastle.sikuli'
$ RunGrowCastleBot

Improvements

  • Detect wave result (Victory/Defeat)
    • It would allow to battle the next wave or replay depending on previous results (or replay easier waves if the last wave failed, although is theoretically not possible when played automatically).
    • Attempt done, Sikulix is not fast enough to detect the "Victory" logo that lasts 0.5 seconds. It's possible to detect it using the level (lv) icon shown on the main screen. Taking snapshots (stackoverflow, docs) before and after the wave would allow images comparison, detecting if the level changed (Victory) or not (Defeat) using a similarity threshold.