Skip to content
Advertisement

Trying to program my computer player to be smarter in the card game “Go Fish”. More specific info in body

”’ This is the card game “Go Fish”, and I am trying to make my computer player smarter. As of right now, when player 2 asks for a card, it does so with the random.choice function like this (player_2_choice = random.choice(player_2_hand). I want to try and restrict the available choices by comparing player_2_hand to two different lists. One is for_player_2 = [], which is a collection of cards that player1 has asked for and player2 didn’t have. If player2 didn’t have the card, that means the card is still in player1’s hand, so the computer player should know to ask for that card if they draw it later. The other list is remembered_cards = [], which is a collection of cards that player2 asks player1 for and player1 doesn’t have the card in their hand, so player2 should know not to ask for that card for a set amount of turns because player2 knows that player1 doesn’t have that card. Will post most of the program and comment as much as I can to help explain what I am trying to do. Just looking for suggestions on what I could do. Not allowed to use classes, thats part of another assignment. When making the comparisons between for_player_2 and player_2_hand, and remembered_cards and player_2_hand, I need to only compare the first letter of each element to find the match-Example: for_player_2 = [‘2H’] player_2_hand = [‘2C’, ‘3C’, ‘4c’, ‘KC’, ‘AC’] — The check would see that 2H is for_player_2 and the 2C in player_2_hand match, so that would be the value stored in player_2_choice. Then that would be the card player_2 asks for. ”’

JavaScript

Advertisement

Answer

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement