Solution for modified version of solitaire card game

75 Views Asked by At

I am currently solving the problem for a modified version of solitarie game, but my solution is of brute-forcing all the possible paths until the end of the gameplay and the complexity is quite embarrassing as of yet, in the game there are set cards with different colors, lets say A colors having B cards each (in each colors with number from 1 to B) so total cards in the deck should be A*B. there is a 3 x 3 nodes on the board and in each node can hold upto B cards (so technically the grid should be like 3 x 3 x B) not necessarily of same color but always in sequence (in increasing order if you look from top and vice versa) , player can pick one card from the top of the deck(arranged by system) and put it on the board if needed else could also pass to the next card in the deck by placing the current card to another stack, and one can also keep on passing until all the deck is finished and then player need to pick the card from the top of the stack where player keep on pushing the passed cards but now player cant pass the card, if the card can not be placed on the board anywhere during drawing the card from the deck or from the stack of passed card, the game is considered as locked state, and if sequence is completed having all of the cards with same color then the node is cleared and all those cards will be dumped out of the game therefore having more space of the remaining cards, During the gameplay the player can move the cards from nodes to nodes if the moves are possible (example in node 1 if there are 2 cards like B2 and G1 and in node 2 there is one card R2 so G1 is eligible to move on R2 as well because its is in sequence but that shall not qualify that set as cleared to get dumped out of the game). my intention is to somehow control the difficulty of the gameplay such that if i want to make the user loose, he/she should loose or at-least near about to loose, for easy gameplay, i dealt the deck in sequence with same color(example 3 Red, 2 Red, 1 Red, 3 Green, 2 Green, 1 Green) to give easy win, and swapped some cards use F/Y method based on difficulty but it will work at some extent but if i want to figure out the most difficult arrangements possible in the deck to make the user loose maximum time, i cant find some solution to that, i have calculated all the possible arrangements of the card i.e., (A*B)! and have brute-forced to calculate all the possible gameplay and storing the counts of the possible dead ends in the given arrangement of the deck, its coming out with complexity of something like this [(AB)!][(9^(AB))+ (9^(AB-1))+(9^(AB-2))+(9^(A*B-3))+...+(9^1)] which is unlikely to implement in any game(although i am trying to improve it by using heuristic greedy approach but not succeeded as of yet), if someone have thought's how to solve this problem, that would be great. i am looking forward for the approach.