Best card choice in card game in C#

前端 未结 3 1526
遥遥无期
遥遥无期 2021-01-19 16:47

The problem consists in choosing the best option at every moment of the game following these rules:

  • You can only pick the leftmost or the rightmost card.

3条回答
  •  北海茫月
    2021-01-19 16:48

    You should look at the Min-Max Algorithm, possibly with Alpha-Beta pruning

    Min-Max is the idea that your opponent will always choose the best choice for themselves, thus you can run each possible scenario to discover the best choice that will result in you beating your opponent. "ie, given I make move x, my opponent will take move y, then I'll take..." etc, all the way to the end of the game. Thus, you can determine who will win.

    Alpha-Beta pruning is similar that it looks at possible scenarios, but it determines if a list of possible scenarios will ever produce a winning outcome. If you know that if you make "move x" then you will always loose no matter what, you don't need to spend more time looking at "move x then move y". You can "prune" off the whole branch of choices from "move x" because you know it will never be helpful.

提交回复
热议问题