diff --git a/ai_comp/ai.py b/ai_comp/ai.py index 7b0b8d9..56359c1 100644 --- a/ai_comp/ai.py +++ b/ai_comp/ai.py @@ -36,6 +36,12 @@ class BaseAI: def make_a_play(self, sub_state): pass + def update_memory(self): + return + + def reset_memory(self): + return + def get_valid_plays(self, leading): all_plays = self.player.get_deck_values() possible_plays = None @@ -64,7 +70,6 @@ class RandomAI(BaseAI): :return: int - the bid """ - return 0 if self.player: current_round_bid = self.table_status["bid"] // 10 current_suit_bid = self.table_status["bid"] % 10 @@ -115,6 +120,9 @@ class VivianAI(RandomAI): self.bid_weigh = 0.3 + self.unplayed_cards = [] + [self.unplayed_cards.append([i+2 for i in range(13)]) for _ in range(4)] + def request_reshuffle(self): return True @@ -178,6 +186,34 @@ class VivianAI(RandomAI): [all_nums.remove(num) for num in weak_nums] return weakest_suit*100 + max(weak_nums) + def make_an_play(self, sub_state): + """ + + :param sub_state: + :return: int - card value + """ + # TODO: Recall last round and update memory + + # Get valid plays + if sub_state == 0: + valid_plays = self.get_valid_plays(True) + else: + valid_plays = self.get_valid_plays(False) + + card_viability = [0] * len(valid_plays) + + def update_memory(self): + played_cards = [card.value for card in self.table_status["played cards"]] + + for val in played_cards: + suit = cards.get_card_suit(val) + num = cards.get_card_number(val) + + self.unplayed_cards[suit-1].remove(num) + + def reset_memory(self): + self.unplayed_cards = [] + [self.unplayed_cards.append([i+2 for i in range(13)]) for _ in range(4)] def estimate_wins(self): player_cards = self.player.get_deck_values() diff --git a/table.py b/table.py index fa38881..1c88b01 100644 --- a/table.py +++ b/table.py @@ -619,6 +619,10 @@ class Table: for deck in self.players_playzone: self.discard_deck.append(deck.remove_card()) + for player in self.players: + if player.AI: + player.AI.update_memory() + if self.players[winning_player].role == PlayerRole.DEFENDER: self.table_status['defender']['wins'] += 1 elif self.players[winning_player].role == PlayerRole.ATTACKER: @@ -658,6 +662,8 @@ class Table: self.discard_deck.append(player.remove_card()) player.score = 0 player.role = PlayerRole.UNKNOWN + if player.AI: + player.AI.reset_memory() for i in range(NUM_OF_PLAYERS): self.update_players_role(i) @@ -673,14 +679,6 @@ class Table: print(len(self.discard_deck)) self.update_table.emit() - def process_player_input(self, player_input): - # TODO: add processing player input - if player_input[0] == "select": - pass - elif player_input[0] == "play": - pass - - pass class TestView(view.PygView):