I need some help to find algoritm that helps to make optimal decision in card game.
Short game description:
- Single player game - 1 player one deck only for himself
- 24 card deck, card values from 1 to 8, 3 colors of each (Red,Yellow, Blue).
At start of the game deck gets randomly shuffled then player pulls 5 cards (19 left in deck) to his hand and from this point he can only:
- Put away one card (this card is not in game anylonger) and take one card from top of shuffled deck for its place.
- Put away 3 cards that form a one of possible point granting combinations, then takes 3 cards to his hand.
Game ends when cards in deck ends and player have no more possible scoring combinations in hand.
Goal of the game is to obtain as much points as possible.
List of variants (called later combinations:
Three of a kind (8 possible in total):
- 111 - 20 points
- 222 - 30 points
- 333 - 40 points
- 444 - 50 points
- 555 - 60 points
- 666 - 70 points
- 777 - 80 points
- 888 - 90 points
Straight (card can have any color, 144 possible in total):
- 123 - 10 points
- 234 - 20 points
- 345 - 30 points
- 456 - 40 points
- 567 - 50 points
- 678 - 60 points
Straight flush (cards have to be in the same color, RRR/YYY/BBB, 18 possible in total):
- 123 - 50 points
- 234 - 60 points
- 345 - 70 points
- 456 - 80 points
- 567 - 90 points
- 678 - 100 points
I created the whole game logic in JS but suffer to make algoritm that will help me:
- which card to put away from hand? - to get highest chance for combination or:
- which card to put away from hand?- to lose least amount of possible combinations
I don't really know which approach i should take. Or should i combine them somehow and let the formula decide? Currently I'm reading about risk reward ratio maybe thats the way to go?
I have to remember that with each card less i have less and less possible combinations (starting with 170), but sometimes its worth in later stage of the game to sacrifice cheaper combination for higher point score.
So far i tried:
Calculate the probability of each possible remaining combination when putting away each card from hand.(i.e. 5 times) and decide which one is the worst. From my observation this too often force single combination costing a lot of points. On average I score more points than this algorithm. In my opinion solely becouse it does not take into account to sacrifice of some combinations.
Calculate the probability of each possible remaining combination left in deck (not counting cards in hand there). 3+ moves in advance, but I have no clue how to combine the results.
What I am considering
- Calculate the probability of each possible remaining combination for every 2 card subset of 5 card set in hand (so 10 times looking for 1 card to fill the combination) and decide which card from hand is the worst.
Is it possible to somehow add those three together to get optimal/close to optimal solution? Should i brute force each round all possible variants and use conditional probability? - seems far from optimal
Should i add potential loss to my calculations and how to form them? If i take weak combination and later in the game i can not obtain higher ones since they are mutually exclusive.