From d33066e7457d3bbb2d13312ee19e0a18f41aa33f Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 18:01:13 -0400 Subject: [PATCH 01/27] ignore venv and vscode files --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 8c8f1c2..1df14dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ **/__pycache__ .idea/ src/data/screenshots +.venv +.vscode From 945281f70f8f28af26abe7becb9e34ead67e8755 Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 18:09:48 -0400 Subject: [PATCH 02/27] move files to named module folder --- {src => clashroyalebuildabot}/bot/action.py | 0 {src => clashroyalebuildabot}/bot/bot.py | 0 .../bot/pete/pete_action.py | 0 {src => clashroyalebuildabot}/bot/pete/pete_bot.py | 0 .../bot/random/random_bot.py | 0 .../bot/standard/standard_action.py | 0 .../bot/standard/standard_bot.py | 0 .../two_six_hog_cycle/two_six_hog_cycle_action.py | 0 .../bot/two_six_hog_cycle/two_six_hog_cycle_bot.py | 0 {src => clashroyalebuildabot}/data/cards.csv | 0 {src => clashroyalebuildabot}/data/constants.py | 0 .../data/images/cards/archer_queen.png | Bin .../data/images/cards/archers.png | Bin .../data/images/cards/arrows.png | Bin .../data/images/cards/balloon.png | Bin .../data/images/cards/bandit.png | Bin .../data/images/cards/barbarian_hut.png | Bin .../data/images/cards/barbarians.png | Bin .../data/images/cards/bats.png | Bin .../data/images/cards/battle_ram.png | Bin .../data/images/cards/blank.png | Bin .../data/images/cards/bomb_tower.png | Bin .../data/images/cards/bomber.png | Bin .../data/images/cards/bowler.png | Bin .../data/images/cards/cannon.png | Bin .../data/images/cards/cannon_cart.png | Bin .../data/images/cards/clone.png | Bin .../data/images/cards/dark_prince.png | Bin .../data/images/cards/dart_goblin.png | Bin .../data/images/cards/electro_wizard.png | Bin .../data/images/cards/elite_barbarians.png | Bin .../data/images/cards/elixir_collector.png | Bin .../data/images/cards/executioner.png | Bin .../data/images/cards/fire_spirit.png | Bin .../data/images/cards/fireball.png | Bin .../data/images/cards/flying_machine.png | Bin .../data/images/cards/freeze.png | Bin .../data/images/cards/furnace.png | Bin .../data/images/cards/giant.png | Bin .../data/images/cards/giant_skeleton.png | Bin .../data/images/cards/goblin_barrel.png | Bin .../data/images/cards/goblin_cage.png | Bin .../data/images/cards/goblin_gang.png | Bin .../data/images/cards/goblin_hut.png | Bin .../data/images/cards/goblins.png | Bin .../data/images/cards/golden_knight.png | Bin .../data/images/cards/golem.png | Bin .../data/images/cards/graveyard.png | Bin .../data/images/cards/guards.png | Bin .../data/images/cards/heal.png | Bin .../data/images/cards/hog_rider.png | Bin .../data/images/cards/hungry_dragon.png | Bin .../data/images/cards/ice_golem.png | Bin .../data/images/cards/ice_spirit.png | Bin .../data/images/cards/ice_wizard.png | Bin .../data/images/cards/inferno_dragon.png | Bin .../data/images/cards/inferno_tower.png | Bin .../data/images/cards/knight.png | Bin .../data/images/cards/lava_hound.png | Bin .../data/images/cards/lightning.png | Bin .../data/images/cards/lumberjack.png | Bin .../data/images/cards/mega_knight.png | Bin .../data/images/cards/mega_minion.png | Bin .../data/images/cards/miner.png | Bin .../data/images/cards/minion_horde.png | Bin .../data/images/cards/minions.png | Bin .../data/images/cards/minipekka.png | Bin .../data/images/cards/mirror.png | Bin .../data/images/cards/mortar.png | Bin .../data/images/cards/musketeer.png | Bin .../data/images/cards/night_witch.png | Bin .../data/images/cards/pekka.png | Bin .../data/images/cards/poison.png | Bin .../data/images/cards/prince.png | Bin .../data/images/cards/princess.png | Bin .../data/images/cards/rage.png | Bin .../data/images/cards/rocket.png | Bin .../data/images/cards/royal_giant.png | Bin .../data/images/cards/skeleton_army.png | Bin .../data/images/cards/skeleton_barrel.png | Bin .../data/images/cards/skeleton_king.png | Bin .../data/images/cards/skeletons.png | Bin .../data/images/cards/sparky.png | Bin .../data/images/cards/spear_goblins.png | Bin .../data/images/cards/tesla.png | Bin .../data/images/cards/the_log.png | Bin .../data/images/cards/three_musketeers.png | Bin .../data/images/cards/tombstone.png | Bin .../data/images/cards/tornado.png | Bin .../data/images/cards/valkyrie.png | Bin .../data/images/cards/witch.png | Bin .../data/images/cards/wizard.png | Bin .../data/images/cards/x_bow.png | Bin .../data/images/cards/zap.png | Bin .../data/images/digits/0.png | Bin .../data/images/digits/1.png | Bin .../data/images/digits/2.png | Bin .../data/images/digits/3.png | Bin .../data/images/digits/4.png | Bin .../data/images/digits/5.png | Bin .../data/images/digits/6.png | Bin .../data/images/digits/7.png | Bin .../data/images/digits/8.png | Bin .../data/images/digits/9.png | Bin .../data/images/screen/end_of_game.png | Bin .../data/images/screen/lobby.png | Bin {src => clashroyalebuildabot}/data/number.onnx | Bin {src => clashroyalebuildabot}/data/unit.onnx | Bin {src => clashroyalebuildabot}/screen.py | 0 .../state/card_detector.py | 0 {src => clashroyalebuildabot}/state/detector.py | 0 .../state/number_detector.py | 0 .../state/onnx_detector.py | 0 .../state/screen_detector.py | 0 .../state/unit_detector.py | 0 115 files changed, 0 insertions(+), 0 deletions(-) rename {src => clashroyalebuildabot}/bot/action.py (100%) rename {src => clashroyalebuildabot}/bot/bot.py (100%) rename {src => clashroyalebuildabot}/bot/pete/pete_action.py (100%) rename {src => clashroyalebuildabot}/bot/pete/pete_bot.py (100%) rename {src => clashroyalebuildabot}/bot/random/random_bot.py (100%) rename {src => clashroyalebuildabot}/bot/standard/standard_action.py (100%) rename {src => clashroyalebuildabot}/bot/standard/standard_bot.py (100%) rename {src => clashroyalebuildabot}/bot/two_six_hog_cycle/two_six_hog_cycle_action.py (100%) rename {src => clashroyalebuildabot}/bot/two_six_hog_cycle/two_six_hog_cycle_bot.py (100%) rename {src => clashroyalebuildabot}/data/cards.csv (100%) rename {src => clashroyalebuildabot}/data/constants.py (100%) rename {src => clashroyalebuildabot}/data/images/cards/archer_queen.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/archers.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/arrows.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/balloon.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/bandit.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/barbarian_hut.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/barbarians.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/bats.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/battle_ram.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/blank.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/bomb_tower.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/bomber.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/bowler.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/cannon.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/cannon_cart.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/clone.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/dark_prince.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/dart_goblin.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/electro_wizard.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/elite_barbarians.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/elixir_collector.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/executioner.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/fire_spirit.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/fireball.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/flying_machine.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/freeze.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/furnace.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/giant.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/giant_skeleton.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/goblin_barrel.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/goblin_cage.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/goblin_gang.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/goblin_hut.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/goblins.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/golden_knight.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/golem.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/graveyard.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/guards.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/heal.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/hog_rider.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/hungry_dragon.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/ice_golem.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/ice_spirit.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/ice_wizard.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/inferno_dragon.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/inferno_tower.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/knight.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/lava_hound.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/lightning.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/lumberjack.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/mega_knight.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/mega_minion.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/miner.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/minion_horde.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/minions.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/minipekka.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/mirror.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/mortar.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/musketeer.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/night_witch.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/pekka.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/poison.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/prince.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/princess.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/rage.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/rocket.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/royal_giant.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/skeleton_army.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/skeleton_barrel.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/skeleton_king.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/skeletons.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/sparky.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/spear_goblins.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/tesla.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/the_log.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/three_musketeers.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/tombstone.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/tornado.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/valkyrie.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/witch.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/wizard.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/x_bow.png (100%) rename {src => clashroyalebuildabot}/data/images/cards/zap.png (100%) rename {src => clashroyalebuildabot}/data/images/digits/0.png (100%) rename {src => clashroyalebuildabot}/data/images/digits/1.png (100%) rename {src => clashroyalebuildabot}/data/images/digits/2.png (100%) rename {src => clashroyalebuildabot}/data/images/digits/3.png (100%) rename {src => clashroyalebuildabot}/data/images/digits/4.png (100%) rename {src => clashroyalebuildabot}/data/images/digits/5.png (100%) rename {src => clashroyalebuildabot}/data/images/digits/6.png (100%) rename {src => clashroyalebuildabot}/data/images/digits/7.png (100%) rename {src => clashroyalebuildabot}/data/images/digits/8.png (100%) rename {src => clashroyalebuildabot}/data/images/digits/9.png (100%) rename {src => clashroyalebuildabot}/data/images/screen/end_of_game.png (100%) rename {src => clashroyalebuildabot}/data/images/screen/lobby.png (100%) rename {src => clashroyalebuildabot}/data/number.onnx (100%) rename {src => clashroyalebuildabot}/data/unit.onnx (100%) rename {src => clashroyalebuildabot}/screen.py (100%) rename {src => clashroyalebuildabot}/state/card_detector.py (100%) rename {src => clashroyalebuildabot}/state/detector.py (100%) rename {src => clashroyalebuildabot}/state/number_detector.py (100%) rename {src => clashroyalebuildabot}/state/onnx_detector.py (100%) rename {src => clashroyalebuildabot}/state/screen_detector.py (100%) rename {src => clashroyalebuildabot}/state/unit_detector.py (100%) diff --git a/src/bot/action.py b/clashroyalebuildabot/bot/action.py similarity index 100% rename from src/bot/action.py rename to clashroyalebuildabot/bot/action.py diff --git a/src/bot/bot.py b/clashroyalebuildabot/bot/bot.py similarity index 100% rename from src/bot/bot.py rename to clashroyalebuildabot/bot/bot.py diff --git a/src/bot/pete/pete_action.py b/clashroyalebuildabot/bot/pete/pete_action.py similarity index 100% rename from src/bot/pete/pete_action.py rename to clashroyalebuildabot/bot/pete/pete_action.py diff --git a/src/bot/pete/pete_bot.py b/clashroyalebuildabot/bot/pete/pete_bot.py similarity index 100% rename from src/bot/pete/pete_bot.py rename to clashroyalebuildabot/bot/pete/pete_bot.py diff --git a/src/bot/random/random_bot.py b/clashroyalebuildabot/bot/random/random_bot.py similarity index 100% rename from src/bot/random/random_bot.py rename to clashroyalebuildabot/bot/random/random_bot.py diff --git a/src/bot/standard/standard_action.py b/clashroyalebuildabot/bot/standard/standard_action.py similarity index 100% rename from src/bot/standard/standard_action.py rename to clashroyalebuildabot/bot/standard/standard_action.py diff --git a/src/bot/standard/standard_bot.py b/clashroyalebuildabot/bot/standard/standard_bot.py similarity index 100% rename from src/bot/standard/standard_bot.py rename to clashroyalebuildabot/bot/standard/standard_bot.py diff --git a/src/bot/two_six_hog_cycle/two_six_hog_cycle_action.py b/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_action.py similarity index 100% rename from src/bot/two_six_hog_cycle/two_six_hog_cycle_action.py rename to clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_action.py diff --git a/src/bot/two_six_hog_cycle/two_six_hog_cycle_bot.py b/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_bot.py similarity index 100% rename from src/bot/two_six_hog_cycle/two_six_hog_cycle_bot.py rename to clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_bot.py diff --git a/src/data/cards.csv b/clashroyalebuildabot/data/cards.csv similarity index 100% rename from src/data/cards.csv rename to clashroyalebuildabot/data/cards.csv diff --git a/src/data/constants.py b/clashroyalebuildabot/data/constants.py similarity index 100% rename from src/data/constants.py rename to clashroyalebuildabot/data/constants.py diff --git a/src/data/images/cards/archer_queen.png b/clashroyalebuildabot/data/images/cards/archer_queen.png similarity index 100% rename from src/data/images/cards/archer_queen.png rename to clashroyalebuildabot/data/images/cards/archer_queen.png diff --git a/src/data/images/cards/archers.png b/clashroyalebuildabot/data/images/cards/archers.png similarity index 100% rename from src/data/images/cards/archers.png rename to clashroyalebuildabot/data/images/cards/archers.png diff --git a/src/data/images/cards/arrows.png b/clashroyalebuildabot/data/images/cards/arrows.png similarity index 100% rename from src/data/images/cards/arrows.png rename to clashroyalebuildabot/data/images/cards/arrows.png diff --git a/src/data/images/cards/balloon.png b/clashroyalebuildabot/data/images/cards/balloon.png similarity index 100% rename from src/data/images/cards/balloon.png rename to clashroyalebuildabot/data/images/cards/balloon.png diff --git a/src/data/images/cards/bandit.png b/clashroyalebuildabot/data/images/cards/bandit.png similarity index 100% rename from src/data/images/cards/bandit.png rename to clashroyalebuildabot/data/images/cards/bandit.png diff --git a/src/data/images/cards/barbarian_hut.png b/clashroyalebuildabot/data/images/cards/barbarian_hut.png similarity index 100% rename from src/data/images/cards/barbarian_hut.png rename to clashroyalebuildabot/data/images/cards/barbarian_hut.png diff --git a/src/data/images/cards/barbarians.png b/clashroyalebuildabot/data/images/cards/barbarians.png similarity index 100% rename from src/data/images/cards/barbarians.png rename to clashroyalebuildabot/data/images/cards/barbarians.png diff --git a/src/data/images/cards/bats.png b/clashroyalebuildabot/data/images/cards/bats.png similarity index 100% rename from src/data/images/cards/bats.png rename to clashroyalebuildabot/data/images/cards/bats.png diff --git a/src/data/images/cards/battle_ram.png b/clashroyalebuildabot/data/images/cards/battle_ram.png similarity index 100% rename from src/data/images/cards/battle_ram.png rename to clashroyalebuildabot/data/images/cards/battle_ram.png diff --git a/src/data/images/cards/blank.png b/clashroyalebuildabot/data/images/cards/blank.png similarity index 100% rename from src/data/images/cards/blank.png rename to clashroyalebuildabot/data/images/cards/blank.png diff --git a/src/data/images/cards/bomb_tower.png b/clashroyalebuildabot/data/images/cards/bomb_tower.png similarity index 100% rename from src/data/images/cards/bomb_tower.png rename to clashroyalebuildabot/data/images/cards/bomb_tower.png diff --git a/src/data/images/cards/bomber.png b/clashroyalebuildabot/data/images/cards/bomber.png similarity index 100% rename from src/data/images/cards/bomber.png rename to clashroyalebuildabot/data/images/cards/bomber.png diff --git a/src/data/images/cards/bowler.png b/clashroyalebuildabot/data/images/cards/bowler.png similarity index 100% rename from src/data/images/cards/bowler.png rename to clashroyalebuildabot/data/images/cards/bowler.png diff --git a/src/data/images/cards/cannon.png b/clashroyalebuildabot/data/images/cards/cannon.png similarity index 100% rename from src/data/images/cards/cannon.png rename to clashroyalebuildabot/data/images/cards/cannon.png diff --git a/src/data/images/cards/cannon_cart.png b/clashroyalebuildabot/data/images/cards/cannon_cart.png similarity index 100% rename from src/data/images/cards/cannon_cart.png rename to clashroyalebuildabot/data/images/cards/cannon_cart.png diff --git a/src/data/images/cards/clone.png b/clashroyalebuildabot/data/images/cards/clone.png similarity index 100% rename from src/data/images/cards/clone.png rename to clashroyalebuildabot/data/images/cards/clone.png diff --git a/src/data/images/cards/dark_prince.png b/clashroyalebuildabot/data/images/cards/dark_prince.png similarity index 100% rename from src/data/images/cards/dark_prince.png rename to clashroyalebuildabot/data/images/cards/dark_prince.png diff --git a/src/data/images/cards/dart_goblin.png b/clashroyalebuildabot/data/images/cards/dart_goblin.png similarity index 100% rename from src/data/images/cards/dart_goblin.png rename to clashroyalebuildabot/data/images/cards/dart_goblin.png diff --git a/src/data/images/cards/electro_wizard.png b/clashroyalebuildabot/data/images/cards/electro_wizard.png similarity index 100% rename from src/data/images/cards/electro_wizard.png rename to clashroyalebuildabot/data/images/cards/electro_wizard.png diff --git a/src/data/images/cards/elite_barbarians.png b/clashroyalebuildabot/data/images/cards/elite_barbarians.png similarity index 100% rename from src/data/images/cards/elite_barbarians.png rename to clashroyalebuildabot/data/images/cards/elite_barbarians.png diff --git a/src/data/images/cards/elixir_collector.png b/clashroyalebuildabot/data/images/cards/elixir_collector.png similarity index 100% rename from src/data/images/cards/elixir_collector.png rename to clashroyalebuildabot/data/images/cards/elixir_collector.png diff --git a/src/data/images/cards/executioner.png b/clashroyalebuildabot/data/images/cards/executioner.png similarity index 100% rename from src/data/images/cards/executioner.png rename to clashroyalebuildabot/data/images/cards/executioner.png diff --git a/src/data/images/cards/fire_spirit.png b/clashroyalebuildabot/data/images/cards/fire_spirit.png similarity index 100% rename from src/data/images/cards/fire_spirit.png rename to clashroyalebuildabot/data/images/cards/fire_spirit.png diff --git a/src/data/images/cards/fireball.png b/clashroyalebuildabot/data/images/cards/fireball.png similarity index 100% rename from src/data/images/cards/fireball.png rename to clashroyalebuildabot/data/images/cards/fireball.png diff --git a/src/data/images/cards/flying_machine.png b/clashroyalebuildabot/data/images/cards/flying_machine.png similarity index 100% rename from src/data/images/cards/flying_machine.png rename to clashroyalebuildabot/data/images/cards/flying_machine.png diff --git a/src/data/images/cards/freeze.png b/clashroyalebuildabot/data/images/cards/freeze.png similarity index 100% rename from src/data/images/cards/freeze.png rename to clashroyalebuildabot/data/images/cards/freeze.png diff --git a/src/data/images/cards/furnace.png b/clashroyalebuildabot/data/images/cards/furnace.png similarity index 100% rename from src/data/images/cards/furnace.png rename to clashroyalebuildabot/data/images/cards/furnace.png diff --git a/src/data/images/cards/giant.png b/clashroyalebuildabot/data/images/cards/giant.png similarity index 100% rename from src/data/images/cards/giant.png rename to clashroyalebuildabot/data/images/cards/giant.png diff --git a/src/data/images/cards/giant_skeleton.png b/clashroyalebuildabot/data/images/cards/giant_skeleton.png similarity index 100% rename from src/data/images/cards/giant_skeleton.png rename to clashroyalebuildabot/data/images/cards/giant_skeleton.png diff --git a/src/data/images/cards/goblin_barrel.png b/clashroyalebuildabot/data/images/cards/goblin_barrel.png similarity index 100% rename from src/data/images/cards/goblin_barrel.png rename to clashroyalebuildabot/data/images/cards/goblin_barrel.png diff --git a/src/data/images/cards/goblin_cage.png b/clashroyalebuildabot/data/images/cards/goblin_cage.png similarity index 100% rename from src/data/images/cards/goblin_cage.png rename to clashroyalebuildabot/data/images/cards/goblin_cage.png diff --git a/src/data/images/cards/goblin_gang.png b/clashroyalebuildabot/data/images/cards/goblin_gang.png similarity index 100% rename from src/data/images/cards/goblin_gang.png rename to clashroyalebuildabot/data/images/cards/goblin_gang.png diff --git a/src/data/images/cards/goblin_hut.png b/clashroyalebuildabot/data/images/cards/goblin_hut.png similarity index 100% rename from src/data/images/cards/goblin_hut.png rename to clashroyalebuildabot/data/images/cards/goblin_hut.png diff --git a/src/data/images/cards/goblins.png b/clashroyalebuildabot/data/images/cards/goblins.png similarity index 100% rename from src/data/images/cards/goblins.png rename to clashroyalebuildabot/data/images/cards/goblins.png diff --git a/src/data/images/cards/golden_knight.png b/clashroyalebuildabot/data/images/cards/golden_knight.png similarity index 100% rename from src/data/images/cards/golden_knight.png rename to clashroyalebuildabot/data/images/cards/golden_knight.png diff --git a/src/data/images/cards/golem.png b/clashroyalebuildabot/data/images/cards/golem.png similarity index 100% rename from src/data/images/cards/golem.png rename to clashroyalebuildabot/data/images/cards/golem.png diff --git a/src/data/images/cards/graveyard.png b/clashroyalebuildabot/data/images/cards/graveyard.png similarity index 100% rename from src/data/images/cards/graveyard.png rename to clashroyalebuildabot/data/images/cards/graveyard.png diff --git a/src/data/images/cards/guards.png b/clashroyalebuildabot/data/images/cards/guards.png similarity index 100% rename from src/data/images/cards/guards.png rename to clashroyalebuildabot/data/images/cards/guards.png diff --git a/src/data/images/cards/heal.png b/clashroyalebuildabot/data/images/cards/heal.png similarity index 100% rename from src/data/images/cards/heal.png rename to clashroyalebuildabot/data/images/cards/heal.png diff --git a/src/data/images/cards/hog_rider.png b/clashroyalebuildabot/data/images/cards/hog_rider.png similarity index 100% rename from src/data/images/cards/hog_rider.png rename to clashroyalebuildabot/data/images/cards/hog_rider.png diff --git a/src/data/images/cards/hungry_dragon.png b/clashroyalebuildabot/data/images/cards/hungry_dragon.png similarity index 100% rename from src/data/images/cards/hungry_dragon.png rename to clashroyalebuildabot/data/images/cards/hungry_dragon.png diff --git a/src/data/images/cards/ice_golem.png b/clashroyalebuildabot/data/images/cards/ice_golem.png similarity index 100% rename from src/data/images/cards/ice_golem.png rename to clashroyalebuildabot/data/images/cards/ice_golem.png diff --git a/src/data/images/cards/ice_spirit.png b/clashroyalebuildabot/data/images/cards/ice_spirit.png similarity index 100% rename from src/data/images/cards/ice_spirit.png rename to clashroyalebuildabot/data/images/cards/ice_spirit.png diff --git a/src/data/images/cards/ice_wizard.png b/clashroyalebuildabot/data/images/cards/ice_wizard.png similarity index 100% rename from src/data/images/cards/ice_wizard.png rename to clashroyalebuildabot/data/images/cards/ice_wizard.png diff --git a/src/data/images/cards/inferno_dragon.png b/clashroyalebuildabot/data/images/cards/inferno_dragon.png similarity index 100% rename from src/data/images/cards/inferno_dragon.png rename to clashroyalebuildabot/data/images/cards/inferno_dragon.png diff --git a/src/data/images/cards/inferno_tower.png b/clashroyalebuildabot/data/images/cards/inferno_tower.png similarity index 100% rename from src/data/images/cards/inferno_tower.png rename to clashroyalebuildabot/data/images/cards/inferno_tower.png diff --git a/src/data/images/cards/knight.png b/clashroyalebuildabot/data/images/cards/knight.png similarity index 100% rename from src/data/images/cards/knight.png rename to clashroyalebuildabot/data/images/cards/knight.png diff --git a/src/data/images/cards/lava_hound.png b/clashroyalebuildabot/data/images/cards/lava_hound.png similarity index 100% rename from src/data/images/cards/lava_hound.png rename to clashroyalebuildabot/data/images/cards/lava_hound.png diff --git a/src/data/images/cards/lightning.png b/clashroyalebuildabot/data/images/cards/lightning.png similarity index 100% rename from src/data/images/cards/lightning.png rename to clashroyalebuildabot/data/images/cards/lightning.png diff --git a/src/data/images/cards/lumberjack.png b/clashroyalebuildabot/data/images/cards/lumberjack.png similarity index 100% rename from src/data/images/cards/lumberjack.png rename to clashroyalebuildabot/data/images/cards/lumberjack.png diff --git a/src/data/images/cards/mega_knight.png b/clashroyalebuildabot/data/images/cards/mega_knight.png similarity index 100% rename from src/data/images/cards/mega_knight.png rename to clashroyalebuildabot/data/images/cards/mega_knight.png diff --git a/src/data/images/cards/mega_minion.png b/clashroyalebuildabot/data/images/cards/mega_minion.png similarity index 100% rename from src/data/images/cards/mega_minion.png rename to clashroyalebuildabot/data/images/cards/mega_minion.png diff --git a/src/data/images/cards/miner.png b/clashroyalebuildabot/data/images/cards/miner.png similarity index 100% rename from src/data/images/cards/miner.png rename to clashroyalebuildabot/data/images/cards/miner.png diff --git a/src/data/images/cards/minion_horde.png b/clashroyalebuildabot/data/images/cards/minion_horde.png similarity index 100% rename from src/data/images/cards/minion_horde.png rename to clashroyalebuildabot/data/images/cards/minion_horde.png diff --git a/src/data/images/cards/minions.png b/clashroyalebuildabot/data/images/cards/minions.png similarity index 100% rename from src/data/images/cards/minions.png rename to clashroyalebuildabot/data/images/cards/minions.png diff --git a/src/data/images/cards/minipekka.png b/clashroyalebuildabot/data/images/cards/minipekka.png similarity index 100% rename from src/data/images/cards/minipekka.png rename to clashroyalebuildabot/data/images/cards/minipekka.png diff --git a/src/data/images/cards/mirror.png b/clashroyalebuildabot/data/images/cards/mirror.png similarity index 100% rename from src/data/images/cards/mirror.png rename to clashroyalebuildabot/data/images/cards/mirror.png diff --git a/src/data/images/cards/mortar.png b/clashroyalebuildabot/data/images/cards/mortar.png similarity index 100% rename from src/data/images/cards/mortar.png rename to clashroyalebuildabot/data/images/cards/mortar.png diff --git a/src/data/images/cards/musketeer.png b/clashroyalebuildabot/data/images/cards/musketeer.png similarity index 100% rename from src/data/images/cards/musketeer.png rename to clashroyalebuildabot/data/images/cards/musketeer.png diff --git a/src/data/images/cards/night_witch.png b/clashroyalebuildabot/data/images/cards/night_witch.png similarity index 100% rename from src/data/images/cards/night_witch.png rename to clashroyalebuildabot/data/images/cards/night_witch.png diff --git a/src/data/images/cards/pekka.png b/clashroyalebuildabot/data/images/cards/pekka.png similarity index 100% rename from src/data/images/cards/pekka.png rename to clashroyalebuildabot/data/images/cards/pekka.png diff --git a/src/data/images/cards/poison.png b/clashroyalebuildabot/data/images/cards/poison.png similarity index 100% rename from src/data/images/cards/poison.png rename to clashroyalebuildabot/data/images/cards/poison.png diff --git a/src/data/images/cards/prince.png b/clashroyalebuildabot/data/images/cards/prince.png similarity index 100% rename from src/data/images/cards/prince.png rename to clashroyalebuildabot/data/images/cards/prince.png diff --git a/src/data/images/cards/princess.png b/clashroyalebuildabot/data/images/cards/princess.png similarity index 100% rename from src/data/images/cards/princess.png rename to clashroyalebuildabot/data/images/cards/princess.png diff --git a/src/data/images/cards/rage.png b/clashroyalebuildabot/data/images/cards/rage.png similarity index 100% rename from src/data/images/cards/rage.png rename to clashroyalebuildabot/data/images/cards/rage.png diff --git a/src/data/images/cards/rocket.png b/clashroyalebuildabot/data/images/cards/rocket.png similarity index 100% rename from src/data/images/cards/rocket.png rename to clashroyalebuildabot/data/images/cards/rocket.png diff --git a/src/data/images/cards/royal_giant.png b/clashroyalebuildabot/data/images/cards/royal_giant.png similarity index 100% rename from src/data/images/cards/royal_giant.png rename to clashroyalebuildabot/data/images/cards/royal_giant.png diff --git a/src/data/images/cards/skeleton_army.png b/clashroyalebuildabot/data/images/cards/skeleton_army.png similarity index 100% rename from src/data/images/cards/skeleton_army.png rename to clashroyalebuildabot/data/images/cards/skeleton_army.png diff --git a/src/data/images/cards/skeleton_barrel.png b/clashroyalebuildabot/data/images/cards/skeleton_barrel.png similarity index 100% rename from src/data/images/cards/skeleton_barrel.png rename to clashroyalebuildabot/data/images/cards/skeleton_barrel.png diff --git a/src/data/images/cards/skeleton_king.png b/clashroyalebuildabot/data/images/cards/skeleton_king.png similarity index 100% rename from src/data/images/cards/skeleton_king.png rename to clashroyalebuildabot/data/images/cards/skeleton_king.png diff --git a/src/data/images/cards/skeletons.png b/clashroyalebuildabot/data/images/cards/skeletons.png similarity index 100% rename from src/data/images/cards/skeletons.png rename to clashroyalebuildabot/data/images/cards/skeletons.png diff --git a/src/data/images/cards/sparky.png b/clashroyalebuildabot/data/images/cards/sparky.png similarity index 100% rename from src/data/images/cards/sparky.png rename to clashroyalebuildabot/data/images/cards/sparky.png diff --git a/src/data/images/cards/spear_goblins.png b/clashroyalebuildabot/data/images/cards/spear_goblins.png similarity index 100% rename from src/data/images/cards/spear_goblins.png rename to clashroyalebuildabot/data/images/cards/spear_goblins.png diff --git a/src/data/images/cards/tesla.png b/clashroyalebuildabot/data/images/cards/tesla.png similarity index 100% rename from src/data/images/cards/tesla.png rename to clashroyalebuildabot/data/images/cards/tesla.png diff --git a/src/data/images/cards/the_log.png b/clashroyalebuildabot/data/images/cards/the_log.png similarity index 100% rename from src/data/images/cards/the_log.png rename to clashroyalebuildabot/data/images/cards/the_log.png diff --git a/src/data/images/cards/three_musketeers.png b/clashroyalebuildabot/data/images/cards/three_musketeers.png similarity index 100% rename from src/data/images/cards/three_musketeers.png rename to clashroyalebuildabot/data/images/cards/three_musketeers.png diff --git a/src/data/images/cards/tombstone.png b/clashroyalebuildabot/data/images/cards/tombstone.png similarity index 100% rename from src/data/images/cards/tombstone.png rename to clashroyalebuildabot/data/images/cards/tombstone.png diff --git a/src/data/images/cards/tornado.png b/clashroyalebuildabot/data/images/cards/tornado.png similarity index 100% rename from src/data/images/cards/tornado.png rename to clashroyalebuildabot/data/images/cards/tornado.png diff --git a/src/data/images/cards/valkyrie.png b/clashroyalebuildabot/data/images/cards/valkyrie.png similarity index 100% rename from src/data/images/cards/valkyrie.png rename to clashroyalebuildabot/data/images/cards/valkyrie.png diff --git a/src/data/images/cards/witch.png b/clashroyalebuildabot/data/images/cards/witch.png similarity index 100% rename from src/data/images/cards/witch.png rename to clashroyalebuildabot/data/images/cards/witch.png diff --git a/src/data/images/cards/wizard.png b/clashroyalebuildabot/data/images/cards/wizard.png similarity index 100% rename from src/data/images/cards/wizard.png rename to clashroyalebuildabot/data/images/cards/wizard.png diff --git a/src/data/images/cards/x_bow.png b/clashroyalebuildabot/data/images/cards/x_bow.png similarity index 100% rename from src/data/images/cards/x_bow.png rename to clashroyalebuildabot/data/images/cards/x_bow.png diff --git a/src/data/images/cards/zap.png b/clashroyalebuildabot/data/images/cards/zap.png similarity index 100% rename from src/data/images/cards/zap.png rename to clashroyalebuildabot/data/images/cards/zap.png diff --git a/src/data/images/digits/0.png b/clashroyalebuildabot/data/images/digits/0.png similarity index 100% rename from src/data/images/digits/0.png rename to clashroyalebuildabot/data/images/digits/0.png diff --git a/src/data/images/digits/1.png b/clashroyalebuildabot/data/images/digits/1.png similarity index 100% rename from src/data/images/digits/1.png rename to clashroyalebuildabot/data/images/digits/1.png diff --git a/src/data/images/digits/2.png b/clashroyalebuildabot/data/images/digits/2.png similarity index 100% rename from src/data/images/digits/2.png rename to clashroyalebuildabot/data/images/digits/2.png diff --git a/src/data/images/digits/3.png b/clashroyalebuildabot/data/images/digits/3.png similarity index 100% rename from src/data/images/digits/3.png rename to clashroyalebuildabot/data/images/digits/3.png diff --git a/src/data/images/digits/4.png b/clashroyalebuildabot/data/images/digits/4.png similarity index 100% rename from src/data/images/digits/4.png rename to clashroyalebuildabot/data/images/digits/4.png diff --git a/src/data/images/digits/5.png b/clashroyalebuildabot/data/images/digits/5.png similarity index 100% rename from src/data/images/digits/5.png rename to clashroyalebuildabot/data/images/digits/5.png diff --git a/src/data/images/digits/6.png b/clashroyalebuildabot/data/images/digits/6.png similarity index 100% rename from src/data/images/digits/6.png rename to clashroyalebuildabot/data/images/digits/6.png diff --git a/src/data/images/digits/7.png b/clashroyalebuildabot/data/images/digits/7.png similarity index 100% rename from src/data/images/digits/7.png rename to clashroyalebuildabot/data/images/digits/7.png diff --git a/src/data/images/digits/8.png b/clashroyalebuildabot/data/images/digits/8.png similarity index 100% rename from src/data/images/digits/8.png rename to clashroyalebuildabot/data/images/digits/8.png diff --git a/src/data/images/digits/9.png b/clashroyalebuildabot/data/images/digits/9.png similarity index 100% rename from src/data/images/digits/9.png rename to clashroyalebuildabot/data/images/digits/9.png diff --git a/src/data/images/screen/end_of_game.png b/clashroyalebuildabot/data/images/screen/end_of_game.png similarity index 100% rename from src/data/images/screen/end_of_game.png rename to clashroyalebuildabot/data/images/screen/end_of_game.png diff --git a/src/data/images/screen/lobby.png b/clashroyalebuildabot/data/images/screen/lobby.png similarity index 100% rename from src/data/images/screen/lobby.png rename to clashroyalebuildabot/data/images/screen/lobby.png diff --git a/src/data/number.onnx b/clashroyalebuildabot/data/number.onnx similarity index 100% rename from src/data/number.onnx rename to clashroyalebuildabot/data/number.onnx diff --git a/src/data/unit.onnx b/clashroyalebuildabot/data/unit.onnx similarity index 100% rename from src/data/unit.onnx rename to clashroyalebuildabot/data/unit.onnx diff --git a/src/screen.py b/clashroyalebuildabot/screen.py similarity index 100% rename from src/screen.py rename to clashroyalebuildabot/screen.py diff --git a/src/state/card_detector.py b/clashroyalebuildabot/state/card_detector.py similarity index 100% rename from src/state/card_detector.py rename to clashroyalebuildabot/state/card_detector.py diff --git a/src/state/detector.py b/clashroyalebuildabot/state/detector.py similarity index 100% rename from src/state/detector.py rename to clashroyalebuildabot/state/detector.py diff --git a/src/state/number_detector.py b/clashroyalebuildabot/state/number_detector.py similarity index 100% rename from src/state/number_detector.py rename to clashroyalebuildabot/state/number_detector.py diff --git a/src/state/onnx_detector.py b/clashroyalebuildabot/state/onnx_detector.py similarity index 100% rename from src/state/onnx_detector.py rename to clashroyalebuildabot/state/onnx_detector.py diff --git a/src/state/screen_detector.py b/clashroyalebuildabot/state/screen_detector.py similarity index 100% rename from src/state/screen_detector.py rename to clashroyalebuildabot/state/screen_detector.py diff --git a/src/state/unit_detector.py b/clashroyalebuildabot/state/unit_detector.py similarity index 100% rename from src/state/unit_detector.py rename to clashroyalebuildabot/state/unit_detector.py From 30f77b3e1422be8dca84b01096efefa59ee663b4 Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 18:11:57 -0400 Subject: [PATCH 03/27] add pypi package workflow --- .github/workflows/pypi-package.yml | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/pypi-package.yml diff --git a/.github/workflows/pypi-package.yml b/.github/workflows/pypi-package.yml new file mode 100644 index 0000000..a4f3cd7 --- /dev/null +++ b/.github/workflows/pypi-package.yml @@ -0,0 +1,40 @@ +# This workflow will install build a pypi distribution of this package +# For more information see: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ + +name: Python Package + +on: + push: + tags: # on tags with versions + - "v*.*.*" + +jobs: + build-n-publish: + name: Build and publish Python distributions to PyPI + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@master + - uses: little-core-labs/get-git-tag@v3.0.1 + - name: Set up Python 3.10 + uses: actions/setup-python@v1 + with: + python-version: "3.10" + - name: Install pypa/build + run: >- + python -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: >- + python -m + build + --sdist + --wheel + --outdir dist/ + . + - name: Publish distribution to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.PYPI_API_TOKEN }} # MUST SET GITHUB REPO SECRET https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets + repository_url: https://test.pypi.org/legacy/ # REMOVE LINE IN PROD From db0eba7173a561320cf4e25136ab488f30c751eb Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 18:14:57 -0400 Subject: [PATCH 04/27] moved main example use into example --- example/main.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 example/main.py diff --git a/example/main.py b/example/main.py new file mode 100644 index 0000000..0ecb4ed --- /dev/null +++ b/example/main.py @@ -0,0 +1,12 @@ +from clashroyalebuildabot.bot.standard.standard_bot import StandardBot + + +def main(): + card_names = ['minions', 'archers', 'arrows', 'giant', + 'minipekka', 'fireball', 'knight', 'musketeer'] + bot = StandardBot(card_names, debug=True) + bot.run() + + +if __name__ == '__main__': + main() \ No newline at end of file From 71818f55fb44da98c9f36832e81a37e8d7d2ddd3 Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 18:16:24 -0400 Subject: [PATCH 05/27] moved to example --- main.py | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 main.py diff --git a/main.py b/main.py deleted file mode 100644 index 1478b37..0000000 --- a/main.py +++ /dev/null @@ -1,12 +0,0 @@ -from src.bot.standard.standard_bot import StandardBot - - -def main(): - card_names = ['minions', 'archers', 'arrows', 'giant', - 'minipekka', 'fireball', 'knight', 'musketeer'] - bot = StandardBot(card_names, debug=True) - bot.run() - - -if __name__ == '__main__': - main() \ No newline at end of file From dfb242fe6b038c911c37d2f99b69e04bdf020fdc Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 18:16:39 -0400 Subject: [PATCH 06/27] updated gitignore with dir name changes --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1df14dd..d3c0304 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ **/__pycache__ .idea/ -src/data/screenshots +clashroyalebuildabot/data/screenshots .venv .vscode From 5ad4b0f7b69cc9514748dd219d03b35a9c942395 Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 18:17:10 -0400 Subject: [PATCH 07/27] changed imports to package imports with rename --- clashroyalebuildabot/bot/bot.py | 8 ++++---- clashroyalebuildabot/bot/pete/pete_action.py | 2 +- clashroyalebuildabot/bot/pete/pete_bot.py | 6 +++--- clashroyalebuildabot/bot/random/random_bot.py | 2 +- clashroyalebuildabot/bot/standard/standard_action.py | 2 +- clashroyalebuildabot/bot/standard/standard_bot.py | 6 +++--- .../bot/two_six_hog_cycle/two_six_hog_cycle_action.py | 2 +- .../bot/two_six_hog_cycle/two_six_hog_cycle_bot.py | 6 +++--- clashroyalebuildabot/screen.py | 2 +- clashroyalebuildabot/state/card_detector.py | 2 +- clashroyalebuildabot/state/detector.py | 10 +++++----- clashroyalebuildabot/state/number_detector.py | 4 ++-- clashroyalebuildabot/state/screen_detector.py | 2 +- clashroyalebuildabot/state/unit_detector.py | 4 ++-- 14 files changed, 29 insertions(+), 29 deletions(-) diff --git a/clashroyalebuildabot/bot/bot.py b/clashroyalebuildabot/bot/bot.py index 95474e5..886b77a 100644 --- a/clashroyalebuildabot/bot/bot.py +++ b/clashroyalebuildabot/bot/bot.py @@ -1,7 +1,7 @@ import time -from src.bot.action import Action -from src.data.constants import ( +from clashroyalebuildabot.bot.action import Action +from clashroyalebuildabot.data.constants import ( ALLY_TILES, LEFT_PRINCESS_TILES, RIGHT_PRINCESS_TILES, @@ -17,8 +17,8 @@ TILE_INIT_Y, DISPLAY_HEIGHT ) -from src.screen import Screen -from src.state.detector import Detector +from clashroyalebuildabot.screen import Screen +from clashroyalebuildabot.state.detector import Detector class Bot: diff --git a/clashroyalebuildabot/bot/pete/pete_action.py b/clashroyalebuildabot/bot/pete/pete_action.py index 15306cf..18dec75 100644 --- a/clashroyalebuildabot/bot/pete/pete_action.py +++ b/clashroyalebuildabot/bot/pete/pete_action.py @@ -1,4 +1,4 @@ -from src.bot.action import Action +from clashroyalebuildabot.bot.action import Action class PeteAction(Action): diff --git a/clashroyalebuildabot/bot/pete/pete_bot.py b/clashroyalebuildabot/bot/pete/pete_bot.py index 7286e25..da5c897 100644 --- a/clashroyalebuildabot/bot/pete/pete_bot.py +++ b/clashroyalebuildabot/bot/pete/pete_bot.py @@ -1,9 +1,9 @@ import random import time -from src.bot.bot import Bot -from src.bot.pete.pete_action import PeteAction -from src.data.constants import DISPLAY_WIDTH, SCREENSHOT_WIDTH, DISPLAY_HEIGHT, SCREENSHOT_HEIGHT +from clashroyalebuildabot.bot.bot import Bot +from clashroyalebuildabot.bot.pete.pete_action import PeteAction +from clashroyalebuildabot.data.constants import DISPLAY_WIDTH, SCREENSHOT_WIDTH, DISPLAY_HEIGHT, SCREENSHOT_HEIGHT class PeteBot(Bot): diff --git a/clashroyalebuildabot/bot/random/random_bot.py b/clashroyalebuildabot/bot/random/random_bot.py index ba87d72..a3f97c0 100644 --- a/clashroyalebuildabot/bot/random/random_bot.py +++ b/clashroyalebuildabot/bot/random/random_bot.py @@ -1,4 +1,4 @@ -from src.bot.bot import Bot +from clashroyalebuildabot.bot.bot import Bot import time import random diff --git a/clashroyalebuildabot/bot/standard/standard_action.py b/clashroyalebuildabot/bot/standard/standard_action.py index bcf3ca7..f9c6975 100644 --- a/clashroyalebuildabot/bot/standard/standard_action.py +++ b/clashroyalebuildabot/bot/standard/standard_action.py @@ -1,4 +1,4 @@ -from src.bot.action import Action +from clashroyalebuildabot.bot.action import Action class StandardAction(Action): diff --git a/clashroyalebuildabot/bot/standard/standard_bot.py b/clashroyalebuildabot/bot/standard/standard_bot.py index ebbd85f..44f4e6e 100644 --- a/clashroyalebuildabot/bot/standard/standard_bot.py +++ b/clashroyalebuildabot/bot/standard/standard_bot.py @@ -1,9 +1,9 @@ import random import time -from src.bot.bot import Bot -from src.bot.standard.standard_action import StandardAction -from src.data.constants import DISPLAY_WIDTH, SCREENSHOT_WIDTH, DISPLAY_HEIGHT, SCREENSHOT_HEIGHT +from clashroyalebuildabot.bot.bot import Bot +from clashroyalebuildabot.bot.standard.standard_action import StandardAction +from clashroyalebuildabot.data.constants import DISPLAY_WIDTH, SCREENSHOT_WIDTH, DISPLAY_HEIGHT, SCREENSHOT_HEIGHT class StandardBot(Bot): diff --git a/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_action.py b/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_action.py index 90b5b59..32c5f91 100644 --- a/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_action.py +++ b/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_action.py @@ -1,4 +1,4 @@ -from src.bot.action import Action +from clashroyalebuildabot.bot.action import Action class TwoSixHogCycleAction(Action): diff --git a/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_bot.py b/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_bot.py index 2a284a6..b7d8c1a 100644 --- a/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_bot.py +++ b/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_bot.py @@ -1,9 +1,9 @@ import random import time -from src.bot.two_six_hog_cycle.two_six_hog_cycle_action import TwoSixHogCycleAction -from src.bot.bot import Bot -from src.data.constants import DISPLAY_WIDTH, SCREENSHOT_WIDTH, DISPLAY_HEIGHT, SCREENSHOT_HEIGHT +from clashroyalebuildabot.bot.two_six_hog_cycle.two_six_hog_cycle_action import TwoSixHogCycleAction +from clashroyalebuildabot.bot.bot import Bot +from clashroyalebuildabot.data.constants import DISPLAY_WIDTH, SCREENSHOT_WIDTH, DISPLAY_HEIGHT, SCREENSHOT_HEIGHT class TwoSixHogCycle(Bot): diff --git a/clashroyalebuildabot/screen.py b/clashroyalebuildabot/screen.py index f15ea2f..19e3142 100644 --- a/clashroyalebuildabot/screen.py +++ b/clashroyalebuildabot/screen.py @@ -4,7 +4,7 @@ from PIL import Image from ppadb.client import Client -from src.data.constants import SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT +from clashroyalebuildabot.data.constants import SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT class Screen: diff --git a/clashroyalebuildabot/state/card_detector.py b/clashroyalebuildabot/state/card_detector.py index d1f9e04..a76b0d2 100644 --- a/clashroyalebuildabot/state/card_detector.py +++ b/clashroyalebuildabot/state/card_detector.py @@ -2,7 +2,7 @@ from PIL import Image import numpy as np -from src.data.constants import CARD_CONFIG, DATA_DIR, MULTI_HASH_SCALE, MULTI_HASH_INTERCEPT, DECK_SIZE, HAND_SIZE +from clashroyalebuildabot.data.constants import CARD_CONFIG, DATA_DIR, MULTI_HASH_SCALE, MULTI_HASH_INTERCEPT, DECK_SIZE, HAND_SIZE from scipy.optimize import linear_sum_assignment diff --git a/clashroyalebuildabot/state/detector.py b/clashroyalebuildabot/state/detector.py index 4aff4e6..1dfdf1e 100644 --- a/clashroyalebuildabot/state/detector.py +++ b/clashroyalebuildabot/state/detector.py @@ -2,11 +2,11 @@ from PIL import ImageDraw, ImageFont -from src.state.card_detector import CardDetector -from src.state.number_detector import NumberDetector -from src.state.unit_detector import UnitDetector -from src.state.screen_detector import ScreenDetector -from src.data.constants import DATA_DIR, SCREENSHOTS_DIR, CARD_CONFIG, DECK_SIZE +from clashroyalebuildabot.state.card_detector import CardDetector +from clashroyalebuildabot.state.number_detector import NumberDetector +from clashroyalebuildabot.state.unit_detector import UnitDetector +from clashroyalebuildabot.state.screen_detector import ScreenDetector +from clashroyalebuildabot.data.constants import DATA_DIR, SCREENSHOTS_DIR, CARD_CONFIG, DECK_SIZE class Detector: diff --git a/clashroyalebuildabot/state/number_detector.py b/clashroyalebuildabot/state/number_detector.py index a1e509a..a436611 100644 --- a/clashroyalebuildabot/state/number_detector.py +++ b/clashroyalebuildabot/state/number_detector.py @@ -1,9 +1,9 @@ import numpy as np from PIL import Image -from src.data.constants import NUMBER_CONFIG, ELIXIR_BOUNDING_BOX, KING_HP, PRINCESS_HP, KING_LEVEL_2_X, \ +from clashroyalebuildabot.data.constants import NUMBER_CONFIG, ELIXIR_BOUNDING_BOX, KING_HP, PRINCESS_HP, KING_LEVEL_2_X, \ NUMBER_MIN_CONFIDENCE, NUMBER_HEIGHT, NUMBER_WIDTH -from src.state.onnx_detector import OnnxDetector +from clashroyalebuildabot.state.onnx_detector import OnnxDetector class NumberDetector(OnnxDetector): diff --git a/clashroyalebuildabot/state/screen_detector.py b/clashroyalebuildabot/state/screen_detector.py index 04f2125..0aa2c63 100644 --- a/clashroyalebuildabot/state/screen_detector.py +++ b/clashroyalebuildabot/state/screen_detector.py @@ -3,7 +3,7 @@ import numpy as np from PIL import Image -from src.data.constants import SCREEN_CONFIG, DATA_DIR +from clashroyalebuildabot.data.constants import SCREEN_CONFIG, DATA_DIR class ScreenDetector: diff --git a/clashroyalebuildabot/state/unit_detector.py b/clashroyalebuildabot/state/unit_detector.py index 877c296..85ee359 100644 --- a/clashroyalebuildabot/state/unit_detector.py +++ b/clashroyalebuildabot/state/unit_detector.py @@ -2,8 +2,8 @@ import numpy as np from PIL import Image -from src.data.constants import UNITS, UNIT_Y_END, UNIT_Y_START, UNIT_SIZE, DATA_DIR -from src.state.onnx_detector import OnnxDetector +from clashroyalebuildabot.data.constants import UNITS, UNIT_Y_END, UNIT_Y_START, UNIT_SIZE, DATA_DIR +from clashroyalebuildabot.state.onnx_detector import OnnxDetector class UnitDetector(OnnxDetector): From 235e7f946cc11758d0808aa32197bfcfebadc555 Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 18:47:29 -0400 Subject: [PATCH 08/27] define package exports and setup --- .gitignore | 1 + clashroyalebuildabot/__init__.py | 21 ++++++++++ clashroyalebuildabot/bot/__init__.py | 11 ++++++ clashroyalebuildabot/bot/pete/__init__.py | 3 ++ clashroyalebuildabot/bot/random/__init__.py | 3 ++ clashroyalebuildabot/bot/standard/__init__.py | 3 ++ .../bot/two_six_hog_cycle/__init__.py | 3 ++ clashroyalebuildabot/data/__init__.py | 3 ++ clashroyalebuildabot/state/__init__.py | 14 +++++++ setup.py | 38 +++++++++++++++++++ 10 files changed, 100 insertions(+) create mode 100644 clashroyalebuildabot/__init__.py create mode 100644 clashroyalebuildabot/bot/__init__.py create mode 100644 clashroyalebuildabot/bot/pete/__init__.py create mode 100644 clashroyalebuildabot/bot/random/__init__.py create mode 100644 clashroyalebuildabot/bot/standard/__init__.py create mode 100644 clashroyalebuildabot/bot/two_six_hog_cycle/__init__.py create mode 100644 clashroyalebuildabot/data/__init__.py create mode 100644 clashroyalebuildabot/state/__init__.py create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index d3c0304..dd694f5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ clashroyalebuildabot/data/screenshots .venv .vscode +*.egg-info \ No newline at end of file diff --git a/clashroyalebuildabot/__init__.py b/clashroyalebuildabot/__init__.py new file mode 100644 index 0000000..deafdf7 --- /dev/null +++ b/clashroyalebuildabot/__init__.py @@ -0,0 +1,21 @@ +# Exports for clashroyalebuildabot +from .bot import PeteBot, RandomBot, StandardBot, TwoSixHogCycle +from .data import constants +from .screen import Screen +from .state import (CardDetector, Detector, NumberDetector, OnnxDetector, + ScreenDetector, UnitDetector) + +__all__ = [ + "StandardBot", + "RandomBot", + "PeteBot", + "TwoSixHogCycle", + "constants", + "Detector", + "OnnxDetector", + "ScreenDetector", + "NumberDetector", + "UnitDetector", + "CardDetector", + "Screen" +] diff --git a/clashroyalebuildabot/bot/__init__.py b/clashroyalebuildabot/bot/__init__.py new file mode 100644 index 0000000..835467c --- /dev/null +++ b/clashroyalebuildabot/bot/__init__.py @@ -0,0 +1,11 @@ +# Exports for bot submodule +from .two_six_hog_cycle import TwoSixHogCycle +from .pete import PeteBot +from .random import RandomBot +from .standard import StandardBot +__all__ = [ + "TwoSixHogCycle", + "PeteBot", + "RandomBot", + "StandardBot" +] diff --git a/clashroyalebuildabot/bot/pete/__init__.py b/clashroyalebuildabot/bot/pete/__init__.py new file mode 100644 index 0000000..c045f47 --- /dev/null +++ b/clashroyalebuildabot/bot/pete/__init__.py @@ -0,0 +1,3 @@ +# Exports for bot.pete submodule +from .pete_bot import PeteBot +__all__ = ["PeteBot"] diff --git a/clashroyalebuildabot/bot/random/__init__.py b/clashroyalebuildabot/bot/random/__init__.py new file mode 100644 index 0000000..e2309db --- /dev/null +++ b/clashroyalebuildabot/bot/random/__init__.py @@ -0,0 +1,3 @@ +# Exports for bot.random submodule +from .random_bot import RandomBot +__all__ = ["RandomBot"] diff --git a/clashroyalebuildabot/bot/standard/__init__.py b/clashroyalebuildabot/bot/standard/__init__.py new file mode 100644 index 0000000..b6bd2a5 --- /dev/null +++ b/clashroyalebuildabot/bot/standard/__init__.py @@ -0,0 +1,3 @@ +# Exports for bot.standard submodule +from .standard_bot import StandardBot +__all__ = ["StandardBot"] diff --git a/clashroyalebuildabot/bot/two_six_hog_cycle/__init__.py b/clashroyalebuildabot/bot/two_six_hog_cycle/__init__.py new file mode 100644 index 0000000..9feffb4 --- /dev/null +++ b/clashroyalebuildabot/bot/two_six_hog_cycle/__init__.py @@ -0,0 +1,3 @@ +# Exports for bot.two_six_hog_cycle submodule +from .two_six_hog_cycle_bot import TwoSixHogCycle +__all__ = ["TwoSixHogCycle"] diff --git a/clashroyalebuildabot/data/__init__.py b/clashroyalebuildabot/data/__init__.py new file mode 100644 index 0000000..ea3bd7e --- /dev/null +++ b/clashroyalebuildabot/data/__init__.py @@ -0,0 +1,3 @@ +# Exports for data submodule +from . import constants +__all__ = ["constants"] diff --git a/clashroyalebuildabot/state/__init__.py b/clashroyalebuildabot/state/__init__.py new file mode 100644 index 0000000..ad1e9b5 --- /dev/null +++ b/clashroyalebuildabot/state/__init__.py @@ -0,0 +1,14 @@ +# Exports for state submodule +from .detector import Detector +from .onnx_detector import OnnxDetector +from .screen_detector import ScreenDetector +from .number_detector import NumberDetector +from .unit_detector import UnitDetector +from .card_detector import CardDetector + +__all__ = ["Detector", + "OnnxDetector", + "ScreenDetector", + "NumberDetector", + "UnitDetector", + "CardDetector"] diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..0f9649d --- /dev/null +++ b/setup.py @@ -0,0 +1,38 @@ +import os +from setuptools import setup, find_packages + +with open("README.md", "r", encoding="utf-8") as f: + LONG_DESCRIPTION = f.read() + +# get github workflow env vars +try: + version = (os.environ['GIT_TAG_NAME']).replace('v', '') +except KeyError: + print('Defaulting to dev') + version = 'dev' + +setup( + name='ClashRoyaleBuildABot', + version=version, + description='A platform for creating bots to play Clash Royale', + long_description=LONG_DESCRIPTION, + long_description_content_type='text/markdown', + keywords='machine-learning ai computer-vision adb clashroyale bluestacks yolov5', + author='pbatch', + url='https://github.com/Pbatch/ClashRoyaleBuildABot', + download_url='https://github.com/Pbatch/ClashRoyaleBuildABot/releases', + install_requires=[ + "Pillow", "numpy", "scipy", + "onnxruntime", "pure-python-adb", + ], + packages=find_packages(), + python_requires='>=3.6', + zip_safe=False, + classifiers=[ + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + ], +) From f54b0c9e95a6f6b1363648ffe88cadbb39fa19b7 Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 18:47:43 -0400 Subject: [PATCH 09/27] add workflow to publish to pypi on tag --- .github/workflows/pypi-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pypi-package.yml b/.github/workflows/pypi-package.yml index a4f3cd7..a1be97f 100644 --- a/.github/workflows/pypi-package.yml +++ b/.github/workflows/pypi-package.yml @@ -15,10 +15,10 @@ jobs: steps: - uses: actions/checkout@master - uses: little-core-labs/get-git-tag@v3.0.1 - - name: Set up Python 3.10 + - name: Set up Python 3.9 uses: actions/setup-python@v1 with: - python-version: "3.10" + python-version: "3.9" - name: Install pypa/build run: >- python -m From 0b53d455c381d1dba9d6da102257109db8c6eb8b Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 18:55:52 -0400 Subject: [PATCH 10/27] fix ppadb reference --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0f9649d..969aef8 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ download_url='https://github.com/Pbatch/ClashRoyaleBuildABot/releases', install_requires=[ "Pillow", "numpy", "scipy", - "onnxruntime", "pure-python-adb", + "onnxruntime", "ppadb", ], packages=find_packages(), python_requires='>=3.6', From e02175bdb0f2b379fd71729995cb018ab69255e2 Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 19:06:57 -0400 Subject: [PATCH 11/27] specify pure-python-adb package version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 969aef8..51064a3 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ download_url='https://github.com/Pbatch/ClashRoyaleBuildABot/releases', install_requires=[ "Pillow", "numpy", "scipy", - "onnxruntime", "ppadb", + "onnxruntime", "pure-python-adb>=0.3.0.dev0", ], packages=find_packages(), python_requires='>=3.6', From d1cf8c8f9a083b1a7d4aab0b669181e4d1c889d1 Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 19:36:00 -0400 Subject: [PATCH 12/27] specify pure-python-adb package version --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 51064a3..c56a929 100644 --- a/setup.py +++ b/setup.py @@ -22,8 +22,9 @@ url='https://github.com/Pbatch/ClashRoyaleBuildABot', download_url='https://github.com/Pbatch/ClashRoyaleBuildABot/releases', install_requires=[ + "pure-python-adb==0.3.0.dev0", "Pillow", "numpy", "scipy", - "onnxruntime", "pure-python-adb>=0.3.0.dev0", + "onnxruntime", ], packages=find_packages(), python_requires='>=3.6', From 65421a90a9f85be7db4a0b95b4618f627e8738e0 Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 19:42:31 -0400 Subject: [PATCH 13/27] testing with additional dependency --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c56a929..4b4b0a6 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ url='https://github.com/Pbatch/ClashRoyaleBuildABot', download_url='https://github.com/Pbatch/ClashRoyaleBuildABot/releases', install_requires=[ - "pure-python-adb==0.3.0.dev0", + "adb-shell>=0.4.0", "pure-python-adb>=0.3.0.dev0", "Pillow", "numpy", "scipy", "onnxruntime", ], From b3ee5aec834bde6625ae448ebab18455b708c0ad Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 19:49:42 -0400 Subject: [PATCH 14/27] do not specify version for ppadb --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4b4b0a6..ad429de 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ url='https://github.com/Pbatch/ClashRoyaleBuildABot', download_url='https://github.com/Pbatch/ClashRoyaleBuildABot/releases', install_requires=[ - "adb-shell>=0.4.0", "pure-python-adb>=0.3.0.dev0", + "pure-python-adb", "Pillow", "numpy", "scipy", "onnxruntime", ], From 2ee7c74198abc8b2501e5eadcb631400402dfbad Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 19:54:25 -0400 Subject: [PATCH 15/27] specify requirements versions --- requirements.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index d602ffb..f600dc7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,7 @@ -Pillow -numpy -onnxruntime -scipy -pure-python-adb \ No newline at end of file +flatbuffers==2.0 +numpy==1.23.0 +onnxruntime==1.11.1 +Pillow==9.1.1 +protobuf==4.21.1 +pure-python-adb==0.3.0.dev0 +scipy==1.8.1 From 38918e12d75c78e34cba6366bf440f43bdf6f17b Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 19:56:38 -0400 Subject: [PATCH 16/27] fix example to use new imports --- example/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/main.py b/example/main.py index 0ecb4ed..f718943 100644 --- a/example/main.py +++ b/example/main.py @@ -1,4 +1,4 @@ -from clashroyalebuildabot.bot.standard.standard_bot import StandardBot +from clashroyalebuildabot.bot import StandardBot def main(): From f9cba5ba9393e56033773afb4e98853127e1074b Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 18:16:39 -0400 Subject: [PATCH 17/27] updated gitignore with dir name changes --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1df14dd..d3c0304 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ **/__pycache__ .idea/ -src/data/screenshots +clashroyalebuildabot/data/screenshots .venv .vscode From a1a7e554a6eda19e72779f3842bea9124fcc7eec Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 18:17:10 -0400 Subject: [PATCH 18/27] changed imports to package imports with rename --- clashroyalebuildabot/bot/bot.py | 8 ++++---- clashroyalebuildabot/bot/pete/pete_action.py | 2 +- clashroyalebuildabot/bot/pete/pete_bot.py | 6 +++--- clashroyalebuildabot/bot/random/random_bot.py | 2 +- clashroyalebuildabot/bot/standard/standard_action.py | 2 +- clashroyalebuildabot/bot/standard/standard_bot.py | 6 +++--- .../bot/two_six_hog_cycle/two_six_hog_cycle_action.py | 2 +- .../bot/two_six_hog_cycle/two_six_hog_cycle_bot.py | 6 +++--- clashroyalebuildabot/screen.py | 2 +- clashroyalebuildabot/state/card_detector.py | 2 +- clashroyalebuildabot/state/detector.py | 10 +++++----- clashroyalebuildabot/state/number_detector.py | 4 ++-- clashroyalebuildabot/state/screen_detector.py | 2 +- clashroyalebuildabot/state/unit_detector.py | 4 ++-- 14 files changed, 29 insertions(+), 29 deletions(-) diff --git a/clashroyalebuildabot/bot/bot.py b/clashroyalebuildabot/bot/bot.py index 95474e5..886b77a 100644 --- a/clashroyalebuildabot/bot/bot.py +++ b/clashroyalebuildabot/bot/bot.py @@ -1,7 +1,7 @@ import time -from src.bot.action import Action -from src.data.constants import ( +from clashroyalebuildabot.bot.action import Action +from clashroyalebuildabot.data.constants import ( ALLY_TILES, LEFT_PRINCESS_TILES, RIGHT_PRINCESS_TILES, @@ -17,8 +17,8 @@ TILE_INIT_Y, DISPLAY_HEIGHT ) -from src.screen import Screen -from src.state.detector import Detector +from clashroyalebuildabot.screen import Screen +from clashroyalebuildabot.state.detector import Detector class Bot: diff --git a/clashroyalebuildabot/bot/pete/pete_action.py b/clashroyalebuildabot/bot/pete/pete_action.py index 15306cf..18dec75 100644 --- a/clashroyalebuildabot/bot/pete/pete_action.py +++ b/clashroyalebuildabot/bot/pete/pete_action.py @@ -1,4 +1,4 @@ -from src.bot.action import Action +from clashroyalebuildabot.bot.action import Action class PeteAction(Action): diff --git a/clashroyalebuildabot/bot/pete/pete_bot.py b/clashroyalebuildabot/bot/pete/pete_bot.py index 7286e25..da5c897 100644 --- a/clashroyalebuildabot/bot/pete/pete_bot.py +++ b/clashroyalebuildabot/bot/pete/pete_bot.py @@ -1,9 +1,9 @@ import random import time -from src.bot.bot import Bot -from src.bot.pete.pete_action import PeteAction -from src.data.constants import DISPLAY_WIDTH, SCREENSHOT_WIDTH, DISPLAY_HEIGHT, SCREENSHOT_HEIGHT +from clashroyalebuildabot.bot.bot import Bot +from clashroyalebuildabot.bot.pete.pete_action import PeteAction +from clashroyalebuildabot.data.constants import DISPLAY_WIDTH, SCREENSHOT_WIDTH, DISPLAY_HEIGHT, SCREENSHOT_HEIGHT class PeteBot(Bot): diff --git a/clashroyalebuildabot/bot/random/random_bot.py b/clashroyalebuildabot/bot/random/random_bot.py index ba87d72..a3f97c0 100644 --- a/clashroyalebuildabot/bot/random/random_bot.py +++ b/clashroyalebuildabot/bot/random/random_bot.py @@ -1,4 +1,4 @@ -from src.bot.bot import Bot +from clashroyalebuildabot.bot.bot import Bot import time import random diff --git a/clashroyalebuildabot/bot/standard/standard_action.py b/clashroyalebuildabot/bot/standard/standard_action.py index bcf3ca7..f9c6975 100644 --- a/clashroyalebuildabot/bot/standard/standard_action.py +++ b/clashroyalebuildabot/bot/standard/standard_action.py @@ -1,4 +1,4 @@ -from src.bot.action import Action +from clashroyalebuildabot.bot.action import Action class StandardAction(Action): diff --git a/clashroyalebuildabot/bot/standard/standard_bot.py b/clashroyalebuildabot/bot/standard/standard_bot.py index ebbd85f..44f4e6e 100644 --- a/clashroyalebuildabot/bot/standard/standard_bot.py +++ b/clashroyalebuildabot/bot/standard/standard_bot.py @@ -1,9 +1,9 @@ import random import time -from src.bot.bot import Bot -from src.bot.standard.standard_action import StandardAction -from src.data.constants import DISPLAY_WIDTH, SCREENSHOT_WIDTH, DISPLAY_HEIGHT, SCREENSHOT_HEIGHT +from clashroyalebuildabot.bot.bot import Bot +from clashroyalebuildabot.bot.standard.standard_action import StandardAction +from clashroyalebuildabot.data.constants import DISPLAY_WIDTH, SCREENSHOT_WIDTH, DISPLAY_HEIGHT, SCREENSHOT_HEIGHT class StandardBot(Bot): diff --git a/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_action.py b/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_action.py index 90b5b59..32c5f91 100644 --- a/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_action.py +++ b/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_action.py @@ -1,4 +1,4 @@ -from src.bot.action import Action +from clashroyalebuildabot.bot.action import Action class TwoSixHogCycleAction(Action): diff --git a/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_bot.py b/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_bot.py index 2a284a6..b7d8c1a 100644 --- a/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_bot.py +++ b/clashroyalebuildabot/bot/two_six_hog_cycle/two_six_hog_cycle_bot.py @@ -1,9 +1,9 @@ import random import time -from src.bot.two_six_hog_cycle.two_six_hog_cycle_action import TwoSixHogCycleAction -from src.bot.bot import Bot -from src.data.constants import DISPLAY_WIDTH, SCREENSHOT_WIDTH, DISPLAY_HEIGHT, SCREENSHOT_HEIGHT +from clashroyalebuildabot.bot.two_six_hog_cycle.two_six_hog_cycle_action import TwoSixHogCycleAction +from clashroyalebuildabot.bot.bot import Bot +from clashroyalebuildabot.data.constants import DISPLAY_WIDTH, SCREENSHOT_WIDTH, DISPLAY_HEIGHT, SCREENSHOT_HEIGHT class TwoSixHogCycle(Bot): diff --git a/clashroyalebuildabot/screen.py b/clashroyalebuildabot/screen.py index f15ea2f..19e3142 100644 --- a/clashroyalebuildabot/screen.py +++ b/clashroyalebuildabot/screen.py @@ -4,7 +4,7 @@ from PIL import Image from ppadb.client import Client -from src.data.constants import SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT +from clashroyalebuildabot.data.constants import SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT class Screen: diff --git a/clashroyalebuildabot/state/card_detector.py b/clashroyalebuildabot/state/card_detector.py index d1f9e04..a76b0d2 100644 --- a/clashroyalebuildabot/state/card_detector.py +++ b/clashroyalebuildabot/state/card_detector.py @@ -2,7 +2,7 @@ from PIL import Image import numpy as np -from src.data.constants import CARD_CONFIG, DATA_DIR, MULTI_HASH_SCALE, MULTI_HASH_INTERCEPT, DECK_SIZE, HAND_SIZE +from clashroyalebuildabot.data.constants import CARD_CONFIG, DATA_DIR, MULTI_HASH_SCALE, MULTI_HASH_INTERCEPT, DECK_SIZE, HAND_SIZE from scipy.optimize import linear_sum_assignment diff --git a/clashroyalebuildabot/state/detector.py b/clashroyalebuildabot/state/detector.py index 4aff4e6..1dfdf1e 100644 --- a/clashroyalebuildabot/state/detector.py +++ b/clashroyalebuildabot/state/detector.py @@ -2,11 +2,11 @@ from PIL import ImageDraw, ImageFont -from src.state.card_detector import CardDetector -from src.state.number_detector import NumberDetector -from src.state.unit_detector import UnitDetector -from src.state.screen_detector import ScreenDetector -from src.data.constants import DATA_DIR, SCREENSHOTS_DIR, CARD_CONFIG, DECK_SIZE +from clashroyalebuildabot.state.card_detector import CardDetector +from clashroyalebuildabot.state.number_detector import NumberDetector +from clashroyalebuildabot.state.unit_detector import UnitDetector +from clashroyalebuildabot.state.screen_detector import ScreenDetector +from clashroyalebuildabot.data.constants import DATA_DIR, SCREENSHOTS_DIR, CARD_CONFIG, DECK_SIZE class Detector: diff --git a/clashroyalebuildabot/state/number_detector.py b/clashroyalebuildabot/state/number_detector.py index a1e509a..a436611 100644 --- a/clashroyalebuildabot/state/number_detector.py +++ b/clashroyalebuildabot/state/number_detector.py @@ -1,9 +1,9 @@ import numpy as np from PIL import Image -from src.data.constants import NUMBER_CONFIG, ELIXIR_BOUNDING_BOX, KING_HP, PRINCESS_HP, KING_LEVEL_2_X, \ +from clashroyalebuildabot.data.constants import NUMBER_CONFIG, ELIXIR_BOUNDING_BOX, KING_HP, PRINCESS_HP, KING_LEVEL_2_X, \ NUMBER_MIN_CONFIDENCE, NUMBER_HEIGHT, NUMBER_WIDTH -from src.state.onnx_detector import OnnxDetector +from clashroyalebuildabot.state.onnx_detector import OnnxDetector class NumberDetector(OnnxDetector): diff --git a/clashroyalebuildabot/state/screen_detector.py b/clashroyalebuildabot/state/screen_detector.py index 04f2125..0aa2c63 100644 --- a/clashroyalebuildabot/state/screen_detector.py +++ b/clashroyalebuildabot/state/screen_detector.py @@ -3,7 +3,7 @@ import numpy as np from PIL import Image -from src.data.constants import SCREEN_CONFIG, DATA_DIR +from clashroyalebuildabot.data.constants import SCREEN_CONFIG, DATA_DIR class ScreenDetector: diff --git a/clashroyalebuildabot/state/unit_detector.py b/clashroyalebuildabot/state/unit_detector.py index 877c296..85ee359 100644 --- a/clashroyalebuildabot/state/unit_detector.py +++ b/clashroyalebuildabot/state/unit_detector.py @@ -2,8 +2,8 @@ import numpy as np from PIL import Image -from src.data.constants import UNITS, UNIT_Y_END, UNIT_Y_START, UNIT_SIZE, DATA_DIR -from src.state.onnx_detector import OnnxDetector +from clashroyalebuildabot.data.constants import UNITS, UNIT_Y_END, UNIT_Y_START, UNIT_SIZE, DATA_DIR +from clashroyalebuildabot.state.onnx_detector import OnnxDetector class UnitDetector(OnnxDetector): From f385010994fc4f51ad4112677aa378899a416613 Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 18:47:29 -0400 Subject: [PATCH 19/27] define package exports and setup --- .gitignore | 1 + clashroyalebuildabot/__init__.py | 21 ++++++++++ clashroyalebuildabot/bot/__init__.py | 11 ++++++ clashroyalebuildabot/bot/pete/__init__.py | 3 ++ clashroyalebuildabot/bot/random/__init__.py | 3 ++ clashroyalebuildabot/bot/standard/__init__.py | 3 ++ .../bot/two_six_hog_cycle/__init__.py | 3 ++ clashroyalebuildabot/data/__init__.py | 3 ++ clashroyalebuildabot/state/__init__.py | 14 +++++++ setup.py | 38 +++++++++++++++++++ 10 files changed, 100 insertions(+) create mode 100644 clashroyalebuildabot/__init__.py create mode 100644 clashroyalebuildabot/bot/__init__.py create mode 100644 clashroyalebuildabot/bot/pete/__init__.py create mode 100644 clashroyalebuildabot/bot/random/__init__.py create mode 100644 clashroyalebuildabot/bot/standard/__init__.py create mode 100644 clashroyalebuildabot/bot/two_six_hog_cycle/__init__.py create mode 100644 clashroyalebuildabot/data/__init__.py create mode 100644 clashroyalebuildabot/state/__init__.py create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index d3c0304..dd694f5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ clashroyalebuildabot/data/screenshots .venv .vscode +*.egg-info \ No newline at end of file diff --git a/clashroyalebuildabot/__init__.py b/clashroyalebuildabot/__init__.py new file mode 100644 index 0000000..deafdf7 --- /dev/null +++ b/clashroyalebuildabot/__init__.py @@ -0,0 +1,21 @@ +# Exports for clashroyalebuildabot +from .bot import PeteBot, RandomBot, StandardBot, TwoSixHogCycle +from .data import constants +from .screen import Screen +from .state import (CardDetector, Detector, NumberDetector, OnnxDetector, + ScreenDetector, UnitDetector) + +__all__ = [ + "StandardBot", + "RandomBot", + "PeteBot", + "TwoSixHogCycle", + "constants", + "Detector", + "OnnxDetector", + "ScreenDetector", + "NumberDetector", + "UnitDetector", + "CardDetector", + "Screen" +] diff --git a/clashroyalebuildabot/bot/__init__.py b/clashroyalebuildabot/bot/__init__.py new file mode 100644 index 0000000..835467c --- /dev/null +++ b/clashroyalebuildabot/bot/__init__.py @@ -0,0 +1,11 @@ +# Exports for bot submodule +from .two_six_hog_cycle import TwoSixHogCycle +from .pete import PeteBot +from .random import RandomBot +from .standard import StandardBot +__all__ = [ + "TwoSixHogCycle", + "PeteBot", + "RandomBot", + "StandardBot" +] diff --git a/clashroyalebuildabot/bot/pete/__init__.py b/clashroyalebuildabot/bot/pete/__init__.py new file mode 100644 index 0000000..c045f47 --- /dev/null +++ b/clashroyalebuildabot/bot/pete/__init__.py @@ -0,0 +1,3 @@ +# Exports for bot.pete submodule +from .pete_bot import PeteBot +__all__ = ["PeteBot"] diff --git a/clashroyalebuildabot/bot/random/__init__.py b/clashroyalebuildabot/bot/random/__init__.py new file mode 100644 index 0000000..e2309db --- /dev/null +++ b/clashroyalebuildabot/bot/random/__init__.py @@ -0,0 +1,3 @@ +# Exports for bot.random submodule +from .random_bot import RandomBot +__all__ = ["RandomBot"] diff --git a/clashroyalebuildabot/bot/standard/__init__.py b/clashroyalebuildabot/bot/standard/__init__.py new file mode 100644 index 0000000..b6bd2a5 --- /dev/null +++ b/clashroyalebuildabot/bot/standard/__init__.py @@ -0,0 +1,3 @@ +# Exports for bot.standard submodule +from .standard_bot import StandardBot +__all__ = ["StandardBot"] diff --git a/clashroyalebuildabot/bot/two_six_hog_cycle/__init__.py b/clashroyalebuildabot/bot/two_six_hog_cycle/__init__.py new file mode 100644 index 0000000..9feffb4 --- /dev/null +++ b/clashroyalebuildabot/bot/two_six_hog_cycle/__init__.py @@ -0,0 +1,3 @@ +# Exports for bot.two_six_hog_cycle submodule +from .two_six_hog_cycle_bot import TwoSixHogCycle +__all__ = ["TwoSixHogCycle"] diff --git a/clashroyalebuildabot/data/__init__.py b/clashroyalebuildabot/data/__init__.py new file mode 100644 index 0000000..ea3bd7e --- /dev/null +++ b/clashroyalebuildabot/data/__init__.py @@ -0,0 +1,3 @@ +# Exports for data submodule +from . import constants +__all__ = ["constants"] diff --git a/clashroyalebuildabot/state/__init__.py b/clashroyalebuildabot/state/__init__.py new file mode 100644 index 0000000..ad1e9b5 --- /dev/null +++ b/clashroyalebuildabot/state/__init__.py @@ -0,0 +1,14 @@ +# Exports for state submodule +from .detector import Detector +from .onnx_detector import OnnxDetector +from .screen_detector import ScreenDetector +from .number_detector import NumberDetector +from .unit_detector import UnitDetector +from .card_detector import CardDetector + +__all__ = ["Detector", + "OnnxDetector", + "ScreenDetector", + "NumberDetector", + "UnitDetector", + "CardDetector"] diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..0f9649d --- /dev/null +++ b/setup.py @@ -0,0 +1,38 @@ +import os +from setuptools import setup, find_packages + +with open("README.md", "r", encoding="utf-8") as f: + LONG_DESCRIPTION = f.read() + +# get github workflow env vars +try: + version = (os.environ['GIT_TAG_NAME']).replace('v', '') +except KeyError: + print('Defaulting to dev') + version = 'dev' + +setup( + name='ClashRoyaleBuildABot', + version=version, + description='A platform for creating bots to play Clash Royale', + long_description=LONG_DESCRIPTION, + long_description_content_type='text/markdown', + keywords='machine-learning ai computer-vision adb clashroyale bluestacks yolov5', + author='pbatch', + url='https://github.com/Pbatch/ClashRoyaleBuildABot', + download_url='https://github.com/Pbatch/ClashRoyaleBuildABot/releases', + install_requires=[ + "Pillow", "numpy", "scipy", + "onnxruntime", "pure-python-adb", + ], + packages=find_packages(), + python_requires='>=3.6', + zip_safe=False, + classifiers=[ + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + ], +) From 405612a01d43e95eea871b3589c74f8a38e6bdbb Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 18:47:43 -0400 Subject: [PATCH 20/27] add workflow to publish to pypi on tag --- .github/workflows/pypi-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pypi-package.yml b/.github/workflows/pypi-package.yml index a4f3cd7..a1be97f 100644 --- a/.github/workflows/pypi-package.yml +++ b/.github/workflows/pypi-package.yml @@ -15,10 +15,10 @@ jobs: steps: - uses: actions/checkout@master - uses: little-core-labs/get-git-tag@v3.0.1 - - name: Set up Python 3.10 + - name: Set up Python 3.9 uses: actions/setup-python@v1 with: - python-version: "3.10" + python-version: "3.9" - name: Install pypa/build run: >- python -m From 58d7d01720e4e339df545a4778b1de58c0850600 Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 18:55:52 -0400 Subject: [PATCH 21/27] fix pure-python-adb dependency reference --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0f9649d..ad429de 100644 --- a/setup.py +++ b/setup.py @@ -22,8 +22,9 @@ url='https://github.com/Pbatch/ClashRoyaleBuildABot', download_url='https://github.com/Pbatch/ClashRoyaleBuildABot/releases', install_requires=[ + "pure-python-adb", "Pillow", "numpy", "scipy", - "onnxruntime", "pure-python-adb", + "onnxruntime", ], packages=find_packages(), python_requires='>=3.6', From 1f509a4522702a4d9454eb61e27e4fc41c5432e5 Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 19:54:25 -0400 Subject: [PATCH 22/27] specify requirements versions --- requirements.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index d602ffb..f600dc7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,7 @@ -Pillow -numpy -onnxruntime -scipy -pure-python-adb \ No newline at end of file +flatbuffers==2.0 +numpy==1.23.0 +onnxruntime==1.11.1 +Pillow==9.1.1 +protobuf==4.21.1 +pure-python-adb==0.3.0.dev0 +scipy==1.8.1 From a44e72977ea147f50deaf6f42d0127e6aec7fea8 Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 18:14:57 -0400 Subject: [PATCH 23/27] add example use moved main example use into example fix main's imports to use package --- main.py => example/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename main.py => example/main.py (81%) diff --git a/main.py b/example/main.py similarity index 81% rename from main.py rename to example/main.py index 1478b37..f718943 100644 --- a/main.py +++ b/example/main.py @@ -1,4 +1,4 @@ -from src.bot.standard.standard_bot import StandardBot +from clashroyalebuildabot.bot import StandardBot def main(): From d8d9adbe9f6d20246893a20938b84014aed3bd9b Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 20:10:20 -0400 Subject: [PATCH 24/27] add new line --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index dd694f5..2509c6f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ clashroyalebuildabot/data/screenshots .venv .vscode -*.egg-info \ No newline at end of file +*.egg-info From f7fd82230683fffd07916ddddb39fd4bce7a0e26 Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Thu, 23 Jun 2022 20:29:01 -0400 Subject: [PATCH 25/27] remove testing pypi index --- .github/workflows/pypi-package.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pypi-package.yml b/.github/workflows/pypi-package.yml index a1be97f..686cf1a 100644 --- a/.github/workflows/pypi-package.yml +++ b/.github/workflows/pypi-package.yml @@ -37,4 +37,3 @@ jobs: uses: pypa/gh-action-pypi-publish@master with: password: ${{ secrets.PYPI_API_TOKEN }} # MUST SET GITHUB REPO SECRET https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets - repository_url: https://test.pypi.org/legacy/ # REMOVE LINE IN PROD From 2cdd7216d91eebdfba24d051e2b359c3575e5d19 Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Sat, 25 Jun 2022 01:14:53 -0400 Subject: [PATCH 26/27] add exports for action and bot classes in bot submodule --- clashroyalebuildabot/__init__.py | 6 ++++-- clashroyalebuildabot/bot/__init__.py | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/clashroyalebuildabot/__init__.py b/clashroyalebuildabot/__init__.py index deafdf7..946b397 100644 --- a/clashroyalebuildabot/__init__.py +++ b/clashroyalebuildabot/__init__.py @@ -1,5 +1,5 @@ # Exports for clashroyalebuildabot -from .bot import PeteBot, RandomBot, StandardBot, TwoSixHogCycle +from .bot import PeteBot, RandomBot, StandardBot, TwoSixHogCycle, Action, Bot from .data import constants from .screen import Screen from .state import (CardDetector, Detector, NumberDetector, OnnxDetector, @@ -17,5 +17,7 @@ "NumberDetector", "UnitDetector", "CardDetector", - "Screen" + "Screen", + "Action", + "Bot" ] diff --git a/clashroyalebuildabot/bot/__init__.py b/clashroyalebuildabot/bot/__init__.py index 835467c..404bf8a 100644 --- a/clashroyalebuildabot/bot/__init__.py +++ b/clashroyalebuildabot/bot/__init__.py @@ -3,9 +3,13 @@ from .pete import PeteBot from .random import RandomBot from .standard import StandardBot +from .action import Action +from .bot import Bot __all__ = [ "TwoSixHogCycle", "PeteBot", "RandomBot", - "StandardBot" + "StandardBot", + "Action", + "Bot" ] From 800ed981bcbf416e0a6c512987b6fa7fc0d31fa7 Mon Sep 17 00:00:00 2001 From: Martin Miglio Date: Sat, 25 Jun 2022 01:21:54 -0400 Subject: [PATCH 27/27] Add to examples. Add a custom bot implementation example modeled after StandardBot. --- example/custom_action.py | 169 +++++++++++++++++++++++++++++++++++++++ example/custom_bot.py | 57 +++++++++++++ example/main.py | 10 ++- 3 files changed, 234 insertions(+), 2 deletions(-) create mode 100644 example/custom_action.py create mode 100644 example/custom_bot.py diff --git a/example/custom_action.py b/example/custom_action.py new file mode 100644 index 0000000..0bf7f2b --- /dev/null +++ b/example/custom_action.py @@ -0,0 +1,169 @@ +""" +custom_action.py +standard_action.py reimplemented as an import from a clashroyalebuildabot install +""" + +from clashroyalebuildabot.bot import Action + + +class CustomAction(Action): + score = None + + @staticmethod + def _distance(x1, y1, x2, y2): + return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5 + + def _calculate_spell_score(self, units, radius, min_to_hit): + """ + Calculate the score for a spell card (either fireball or arrows) + + The score is defined as [A, B, C] + A is 1 if we'll hit `min_to_hit` or more units, 0 otherwise + B is the number of units we hit + C is the negative distance to the furthest unit + """ + score = [0, 0, 0] + for k, v in units.items(): + if k[:4] == 'ally': + continue + for unit in v['positions']: + tile_x, tile_y = unit['tile_xy'] + # Assume the unit will move down a few spaces + tile_y -= 2 + + # Add 1 to the score if the spell will hit the unit + distance = self._distance(tile_x, tile_y, self.tile_x, self.tile_y) + if distance <= radius - 1: + score[1] += 1 + score[2] = min(score[2], -distance) + + # Set score[0] to 1 if we think we'll hit enough units + if score[1] >= min_to_hit: + score[0] = 1 + + return score + + def _calculate_knight_score(self, state): + """ + Only play the knight if a ground troop is on our side of the battlefield + Play the knight in the center, vertically aligned with the troop + """ + score = [0] if state['numbers']['elixir']['number'] != 10 else [0.5] + for k, v in state['units'].items(): + if k[:4] == 'ally': + continue + for unit in v['positions']: + tile_x, tile_y = unit['tile_xy'] + if self.tile_y < tile_y <= 14 and v['transport'] == 'ground': + if tile_x > 8 and self.tile_x == 9 or tile_x <= 8 and self.tile_x == 8: + score = [1, self.tile_y - tile_y] + return score + + def _calculate_minions_score(self, state): + """ + Only play minions on top of enemy units + """ + score = [0] if state['numbers']['elixir']['number'] != 10 else [0.5] + for k, v in state['units'].items(): + if k[:4] == 'ally': + continue + for unit in v['positions']: + tile_x, tile_y = unit['tile_xy'] + distance = self._distance(tile_x, tile_y, self.tile_x, self.tile_y) + if distance < 1: + score = [1, -distance] + return score + + def _calculate_fireball_score(self, state): + """ + Only play fireball if at least 3 units will be hit + Try to hit as many units as possible + """ + return self._calculate_spell_score(state['units'], radius=2.5, min_to_hit=3) + + def _calculate_arrows_score(self, state): + """ + Only play arrows if at least 5 units will be hit + Try to hit as many units as possible + """ + return self._calculate_spell_score(state['units'], radius=4, min_to_hit=5) + + def _calculate_archers_score(self, state): + """ + Only play the archers if there is a troop on our side of the battlefield + Play the archers in the center, vertically aligned with the troop + """ + score = [0] if state['numbers']['elixir']['number'] != 10 else [0.5] + for k, v in state['units'].items(): + if k[:4] == 'ally': + continue + for unit in v['positions']: + tile_x, tile_y = unit['tile_xy'] + if self.tile_y < tile_y <= 14: + if tile_x > 8 and self.tile_x == 10 or tile_x <= 8 and self.tile_x == 7: + score = [1, self.tile_y - tile_y] + return score + + def _calculate_giant_score(self, state): + """ + Only place the giant when at 10 elixir + Place it as high up as possible + Try to target the lowest hp tower + """ + score = [0] + left_hp, right_hp = [state['numbers'][f'{direction}_enemy_princess_hp']['number'] + for direction in ['left', 'right']] + if state['numbers']['elixir']['number'] == 10: + if self.tile_x == 3: + score = [1, self.tile_y, left_hp != -1, left_hp <= right_hp] + elif self.tile_x == 14: + score = [1, self.tile_y, right_hp != -1, right_hp <= left_hp] + + return score + + def _calculate_minipekka_score(self, state): + """ + Place minipekka on the bridge as high up as possible + Try to target the lowest hp tower + """ + left_hp, right_hp = [state['numbers'][f'{direction}_enemy_princess_hp']['number'] + for direction in ['left', 'right']] + score = [0] + if self.tile_x == 3: + score = [1, self.tile_y, left_hp != -1, left_hp <= right_hp] + elif self.tile_x == 14: + score = [1, self.tile_y, right_hp != -1, right_hp <= left_hp] + return score + + def _calculate_musketeer_score(self, state): + """ + Place musketeer at 5-6 tiles away from enemies + That should be just within her range + """ + score = [0] + for k, v in state['units'].items(): + if k[:4] == 'ally': + continue + for unit in v['positions']: + tile_x, tile_y = unit['tile_xy'] + distance = self._distance(tile_x, tile_y, self.tile_x, self.tile_y) + if 5 < distance < 6: + score = [1] + elif distance < 5: + score = [0] + return score + + def calculate_score(self, state): + name_to_score = {'knight': self._calculate_knight_score, + 'minions': self._calculate_minions_score, + 'fireball': self._calculate_fireball_score, + 'giant': self._calculate_giant_score, + 'minipekka': self._calculate_minipekka_score, + 'musketeer': self._calculate_musketeer_score, + 'arrows': self._calculate_arrows_score, + 'archers': self._calculate_archers_score + } + score_function = name_to_score[self.name] + score = score_function(state) + self.score = score + return score diff --git a/example/custom_bot.py b/example/custom_bot.py new file mode 100644 index 0000000..665298a --- /dev/null +++ b/example/custom_bot.py @@ -0,0 +1,57 @@ +""" +custom_bot.py +standard_bot.py reimplemented as an import from a clashroyalebuildabot install +""" + +import random +import time + +from clashroyalebuildabot.bot import Bot +from custom_action import CustomAction +from clashroyalebuildabot.data.constants import DISPLAY_WIDTH, SCREENSHOT_WIDTH, DISPLAY_HEIGHT, SCREENSHOT_HEIGHT + + +class CustomBot(Bot): + def __init__(self, card_names, debug=False): + preset_deck = {'minions', 'archers', 'arrows', 'giant', 'minipekka', 'fireball', 'knight', 'musketeer'} + if set(card_names) != preset_deck: + raise ValueError(f'You must use the preset deck with cards {preset_deck} for StandardBot') + super().__init__(card_names, CustomAction, debug=debug) + + def _preprocess(self): + """ + Perform preprocessing on the state + + Estimate the tile of each unit to be the bottom of their bounding box + """ + for k, v in self.state['units'].items(): + for unit in v['positions']: + bbox = unit['bounding_box'] + bbox[0] *= DISPLAY_WIDTH / SCREENSHOT_WIDTH + bbox[1] *= DISPLAY_HEIGHT / SCREENSHOT_HEIGHT + bbox[2] *= DISPLAY_WIDTH / SCREENSHOT_WIDTH + bbox[3] *= DISPLAY_HEIGHT / SCREENSHOT_HEIGHT + bbox_bottom = [((bbox[0] + bbox[2]) / 2), bbox[3]] + unit['tile_xy'] = self._get_nearest_tile(*bbox_bottom) + + def run(self): + while True: + # Set the state of the game + self.set_state() + # Obtain a list of playable actions + actions = self.get_actions() + if actions: + # Shuffle the actions (because action scores might be the same) + random.shuffle(actions) + # Preprocessing + self._preprocess() + # Get the best action + action = max(actions, key=lambda x: x.calculate_score(self.state)) + # Skip the action if it doesn't score high enough + if action.score[0] == 0: + continue + # Play the best action + self.play_action(action) + # Log the result + print(f'Playing {action} with score {action.score} and sleeping for 1 second') + time.sleep(1.0) diff --git a/example/main.py b/example/main.py index f718943..ad77ba7 100644 --- a/example/main.py +++ b/example/main.py @@ -1,10 +1,16 @@ -from clashroyalebuildabot.bot import StandardBot +""" +A CustomBot implementation through import +""" +from custom_bot import CustomBot # see custom_bot.py def main(): + # Set required bot variables card_names = ['minions', 'archers', 'arrows', 'giant', 'minipekka', 'fireball', 'knight', 'musketeer'] - bot = StandardBot(card_names, debug=True) + # Define an instance of CustomBot + bot = CustomBot(card_names, debug=True) + # and run! bot.run()