-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Various QOL fixes * Various QOL fixes * Various QOL fixes
- Loading branch information
Showing
16 changed files
with
151 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,3 @@ | |
class ArrowsAction(SpellAction): | ||
CARD = Cards.ARROWS | ||
RADIUS = 4 | ||
MIN_TO_HIT = 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from clashroyalebuildabot import Cards | ||
from clashroyalebuildabot.actions.overhead_action import OverheadAction | ||
|
||
|
||
class BatsAction(OverheadAction): | ||
CARD = Cards.BATS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,3 @@ | |
class FireballAction(SpellAction): | ||
CARD = Cards.FIREBALL | ||
RADIUS = 2.5 | ||
MIN_TO_HIT = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,6 @@ | ||
import math | ||
|
||
from clashroyalebuildabot import Cards | ||
from clashroyalebuildabot.actions.action import Action | ||
from clashroyalebuildabot.actions.overhead_action import OverheadAction | ||
|
||
|
||
class MinionsAction(Action): | ||
class MinionsAction(OverheadAction): | ||
CARD = Cards.MINIONS | ||
|
||
def calculate_score(self, state): | ||
score = [0.5] if state.numbers["elixir"]["number"] == 10 else [0] | ||
for v in state.enemies.values(): | ||
for position in v["positions"]: | ||
distance = math.hypot( | ||
position.tile_x - self.tile_x, | ||
position.tile_y - self.tile_y, | ||
) | ||
if distance < 1: | ||
score = [1, -distance] | ||
return score |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import math | ||
|
||
from clashroyalebuildabot.actions.action import Action | ||
|
||
|
||
class OverheadAction(Action): | ||
""" | ||
Play the card directly on top of enemy units | ||
""" | ||
|
||
def calculate_score(self, state): | ||
score = [0.5] if state.numbers["elixir"]["number"] == 10 else [0] | ||
for det in state.enemies: | ||
distance = math.hypot( | ||
det.position.tile_x - self.tile_x, | ||
det.position.tile_y - self.tile_y, | ||
) | ||
if distance < 1: | ||
score = [1, -distance] | ||
return score |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,28 @@ | ||
import math | ||
|
||
from clashroyalebuildabot.actions.action import Action | ||
from clashroyalebuildabot.namespaces.units import Units | ||
|
||
|
||
class SpellAction(Action): | ||
RADIUS = None | ||
MIN_TO_HIT = None | ||
MIN_SCORE = 5 | ||
UNIT_TO_SCORE = {Units.SKELETON: 1} | ||
|
||
def calculate_score(self, state): | ||
hit_units = 0 | ||
hit_score = 0 | ||
max_distance = float("inf") | ||
for v in state.enemies.values(): | ||
for position in v["positions"]: | ||
distance = math.hypot( | ||
self.tile_x - position.tile_x, | ||
self.tile_y - position.tile_y + 2, | ||
) | ||
if distance <= self.RADIUS - 1: | ||
hit_units += 1 | ||
max_distance = min(max_distance, -distance) | ||
for det in state.enemies: | ||
distance = math.hypot( | ||
self.tile_x - det.position.tile_x, | ||
self.tile_y - det.position.tile_y + 2, | ||
) | ||
if distance <= self.RADIUS - 1: | ||
hit_score += self.UNIT_TO_SCORE.get(det.unit, 2) | ||
max_distance = min(max_distance, -distance) | ||
|
||
return [ | ||
1 if hit_units >= self.MIN_TO_HIT else 0, | ||
hit_units, | ||
1 if hit_score >= self.MIN_SCORE else 0, | ||
hit_score, | ||
max_distance, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,3 @@ | |
class ZapAction(SpellAction): | ||
CARD = Cards.ZAP | ||
RADIUS = 2.5 | ||
MIN_TO_HIT = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.