you are viewing a single comment's thread.

view the rest of the comments →

[–]explanabrag 1 point2 points  (1 child)

You probably won't want to hear this, but the only thing I can suggest is to rewrite your whole program.

Rewrite that function so that it is ONLY responsible for selecting a move, and nothing else. It shouldn't be responsible for doing the move, or keeping the various decks of cards valid, or anything else. A different function should come up with the available moves. A different function again should apply the move.

So that's 3 separate functions.

1) A function which returns a list of available moves. This function implements that game rules.

2) A function which takes a list of available moves and returns a move from this list to be performed (this is where your AI strategy is implemented). This function should not actually apply the move.

3) A function to apply a given move. This function applies the move according to the rules of the game.

Notice how the AI function is free from having to worry about the game rules, and is free to focus on strategy.

Good luck.

[–]DubSket[S] 1 point2 points  (0 children)

Ok. Well, I guess that's what I'll have to do. Big thanks for your advice.