Skip to content

Commit

Permalink
fixed pseudolegalcards to be card_index and not card
Browse files Browse the repository at this point in the history
  • Loading branch information
lunathanael committed Mar 12, 2024
1 parent 653d70b commit d089218
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion clash_royale/envs/game_engine/game_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def legal_actions(self, player_id: int) -> npt.NDArray[np.float64]:
"""
actions = np.zeros(shape=(32, 18, 4), dtype=np.float64)

hand: List[Card]
hand: List[int]
if player_id == 0:
hand = self.player1.get_pseudo_legal_cards()
else:
Expand Down
12 changes: 6 additions & 6 deletions clash_royale/envs/game_engine/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self,
specifying the cards' names in the deck.
"""

self.elixir: int = 0
self.elixir: float = 0
self.fps: int = fps

random.shuffle(deck)
Expand All @@ -40,16 +40,16 @@ def reset(self, elixir: int = 5) -> None:

self.elixir: float = elixir

def get_pseudo_legal_cards(self) -> List[Card]:
def get_pseudo_legal_cards(self) -> List[int]:
"""
This method is used to get all cards that can be
played given the current amount of elixir.
"""

legal_cards: list[Card] = []
for card in self.hand:
if card.elixir <= self.elixir:
legal_cards.append(card)
legal_cards: list[int] = []
for card_index in len(self.hand):
if self.hand[card_index].elixir <= self.elixir:
legal_cards.append(card_index)

return legal_cards

Expand Down

0 comments on commit d089218

Please sign in to comment.