Skip to content

Add an optimize strategy button to the windows 8 client

NathanTeeuwen edited this page Apr 8, 2015 · 1 revision

The Windows 8 client currently has the ability to compare strategies. The user drags over a set of cards, and an initial guess is made to create a purchase order for that set of cards. The user may tweak when exactly to buy a card, or how many to get. Unfortunately this is a manual process. We would like to add another button next to "Simulate Game". The "Optimize Strategy" Button, when pressed, should leave the current number of rules unchanged. However, it should play around with the numbers, in an attempt to optimize win% vs the other opposing strategy. For example, by default the strategy might indicate to buy a province when the player owns at least 2 gold. Maybe it should start after 3 gold, maybe 1. "Optimize Strategy" button should attempt to remove this manual modification process.

Tasks Recommended

  1. Launch Win8Client.sln Run the program, and compose a few strategies in the UI

  2. Launch Dominion.sln Set TestPrograms/ComparePlayers as the startup project. Watch what it does. Check out the generated HTML report and log files.

  3. Read over the strategies in the folder Dominion.BuildInStrategies\Strategies. Notice how the buy order written in code here roughly reflects options that are available in the Win8Client.

  4. Modify TestPrograms/ComparePlayers/Program.cs to compare a couple of the different strategies from step 3.

  5. Investigate and learn about the source code Win8Client/StraetgyDescription. Become familiar with how this object description is assembled in the UI, and how conceptually it relates to the strategies from step 3) above. It is the numbers in this strategy that you will want to change and modify.

  6. Launch Dominion.sln Set the startup project to TestPrograms\TestStrategyOptimizer. This demonstrates how the very rudimentary genetic algorthim present optimizes a bigmoney strategy. Unfortnately this code does not sue the strategy descriptions that we learned about in step 5). The code for the genetic algorithm lives in Dominion.Straegy.Optimizer. We will need to parameterize this algorithm to mutate Descriptions that were learned about in step 5)

That's all you the information you should need :) After completing steps 1 - 6, you should have enough background to create a button that when clicked, will leverage the Strategy Optimizer to find permutations of the strategy that more optimally play the selected purchase order. I would recommend that when viewing strategy 1, the button optimizes only strategy 1. The user can then select strategy 2 and reclick the button. Eventually we can have the optimizer run continuously in the background and modify the stratey until stopped. As a beginning goal, I would have the button asynchronously run a simulation for a few seconds and return what it has complete, display the results in the UI. Don't block the UI :)

Longer term, it would be cool to try and find an optimal subset set of cards to be played in a given Dominion. However, for starters I think we should allow the person to pick the set of cards and general conditions for purchase, and just have the computer mutate the counts and threshholds of the purchase order.

Clone this wiki locally