Skip to content

Commit

Permalink
Merge pull request #35 from marmig0404/main
Browse files Browse the repository at this point in the history
Make project an importable library
  • Loading branch information
Pbatch committed Jun 27, 2022
2 parents 7ad9712 + 800ed98 commit 59db2b8
Show file tree
Hide file tree
Showing 131 changed files with 429 additions and 47 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/pypi-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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.9
uses: actions/setup-python@v1
with:
python-version: "3.9"
- 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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
**/__pycache__
.idea/
src/data/screenshots
clashroyalebuildabot/data/screenshots
.venv
.vscode
*.egg-info
23 changes: 23 additions & 0 deletions clashroyalebuildabot/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Exports for clashroyalebuildabot
from .bot import PeteBot, RandomBot, StandardBot, TwoSixHogCycle, Action, Bot
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",
"Action",
"Bot"
]
15 changes: 15 additions & 0 deletions clashroyalebuildabot/bot/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Exports for bot submodule
from .two_six_hog_cycle import TwoSixHogCycle
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",
"Action",
"Bot"
]
File renamed without changes.
8 changes: 4 additions & 4 deletions src/bot/bot.py → clashroyalebuildabot/bot/bot.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions clashroyalebuildabot/bot/pete/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Exports for bot.pete submodule
from .pete_bot import PeteBot
__all__ = ["PeteBot"]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.bot.action import Action
from clashroyalebuildabot.bot.action import Action


class PeteAction(Action):
Expand Down
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
3 changes: 3 additions & 0 deletions clashroyalebuildabot/bot/random/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Exports for bot.random submodule
from .random_bot import RandomBot
__all__ = ["RandomBot"]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.bot.bot import Bot
from clashroyalebuildabot.bot.bot import Bot
import time
import random

Expand Down
3 changes: 3 additions & 0 deletions clashroyalebuildabot/bot/standard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Exports for bot.standard submodule
from .standard_bot import StandardBot
__all__ = ["StandardBot"]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.bot.action import Action
from clashroyalebuildabot.bot.action import Action


class StandardAction(Action):
Expand Down
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
3 changes: 3 additions & 0 deletions clashroyalebuildabot/bot/two_six_hog_cycle/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Exports for bot.two_six_hog_cycle submodule
from .two_six_hog_cycle_bot import TwoSixHogCycle
__all__ = ["TwoSixHogCycle"]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.bot.action import Action
from clashroyalebuildabot.bot.action import Action


class TwoSixHogCycleAction(Action):
Expand Down
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
3 changes: 3 additions & 0 deletions clashroyalebuildabot/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Exports for data submodule
from . import constants
__all__ = ["constants"]
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/screen.py → clashroyalebuildabot/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions clashroyalebuildabot/state/__init__.py
Original file line number Diff line number Diff line change
@@ -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"]
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
10 changes: 5 additions & 5 deletions src/state/detector.py → clashroyalebuildabot/state/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 59db2b8

Please sign in to comment.