Dominion Strategy Forum

Please login or register.

Login with username, password and session length
Pages: [1]

Author Topic: Learning simulator logic  (Read 1548 times)

0 Members and 1 Guest are viewing this topic.

philosophyguy

  • Minion
  • *****
  • Offline Offline
  • Posts: 575
  • Respect: +299
    • View Profile
Learning simulator logic
« on: April 21, 2012, 01:00:12 pm »
0

I'd like to post a request for people who have created interesting simulator logic to post their code and explain how the code works. WW's commentary on his Ironworks/Silk Roads bot after the simulator tournament was very helpful in understanding what the bot was doing, and I learned a lot about how to build different scenarios into the simulator. I'd appreciate if others can likewise post code snippets and explain what they do. Examples of useful things to learn could include:
  • How to build in logic for when a simulator should use the gain Copper ability with IGG for weird scenarios like having 4 IGGs in hand (you probably want to buy a Province, but how does the simulator know to take the coppers there but not with only 3 IGGs in hand and no other treasure?)
  • How to determine whether playing Haggler is useful or whether it will force you to gain a junk card
  • Changing play priority of cursing attacks once curses have run out

This is just a sample of ideas off the top of my head. Just consider this a place to show, and explain, how you got the simulator to do something nifty.
Logged

blueblimp

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2849
  • Respect: +1559
    • View Profile
Re: Learning simulator logic
« Reply #1 on: April 21, 2012, 03:25:54 pm »
0

(Edit: The rule of thumb is: most play behaviour you can't change. What I've done here is try to show what the built-in play behaviour is.)

I'm not an expert at optimizing bots, but for a lot of questions, the best way to figure things out is to read the source code. Unfortunately this requires a basic understanding of Java. The second-best way is to look at the play rules on Geronimoo's simulator website.

The play rules for IGG. To know exactly what "increase this turn's buying power" means, it seems necessary to read the source code. Looking at Ill_Gotten_GainsCard.java, we can see that it calls the DomPlayer.addingThisIncreasesBuyingPower method. This in turn calls DomPlayer.getTotalPotentialCurrency, which uses the DomCard.getPotentialCoinValue method. For treasures, unless overridden, this method returns the DomCardName.coinValue field. For IGG, this is set to 2, because an IGG can produce up to 2 coins. So when playing the first IGG, the other 3 IGG's would be considered Silvers for the purpose of buying power, so that's why the simulator knows it's possible to buy a Province.

Sometimes, it's not obvious what coinValue should be. For example, Quarry is given a coin value of 3. I assume this is because bots that buy Quarry will usually be buying lots of actions, and for buying actions with a single buy, a Quarry is effectively a Gold.

For Haggler, the website doesn't say anything about its play rules during the action phase, only what happens during the buy phase. Looking at HagglerCard.java, it does not seem to alter its play based on expected purchase, so there wouldn't be any way to control it except by modifying the source code. Probably the right way to do this is to override the DomCard.wantsToBePlayed method.

Re: cursing attacks, let's look at Witch as an example. It doesn't have play rules listed on the website, but looking at WitchCard.java, it seems that it already alters its play priority once curses run out. When there are no curses left, it changes its play priority to be the same as a Moat. Looking at Young Witch though, it does not seem to alter its play priority.
Logged

DG

  • Governor
  • *****
  • Offline Offline
  • Posts: 4074
  • Respect: +2624
    • View Profile
Re: Learning simulator logic
« Reply #2 on: April 21, 2012, 07:14:14 pm »
0

I'll talk about the Geronimoo simulator since I don't know much about the rSpeer project. You've asked some genuinely difficult questions.

I'm not sure about IGGs. You might be able to persuade the simulator to take copper in certain situations by adding an extra line in the purchase script for copper. Otherwise you are left largely in the hands of the simulator play rules for decisions like these, another example being when to trash a mining village for +2 coins.

The haggler is also difficult however you can sometimes use available$ to determine whether the card is being bought or gained by the haggler. If you had a line such as "Buy Hunting Party if available$ is < 5" and put it after a line to buy a province and before of a line to purchase gold in your script then the simulator should both buy province/gain hunting party and buy gold/gain hunting party. To stop your haggler buying silver and gaining copper you can change the silver purchasing to "Buy Silver if count in play haggler = 0" with a second line "Buy Silver if available$ < 3". I suspect the available$ will not be a reliable measure whenever you are gaining other cards during the turn or have multiple buys.

The play priority rules are determined by the simulator. The sea hag already changes its play priority and trash priority when the curses are exhausted and it would be advantageous if other cursing actions did the same. In this general situation though we need to accept the simulator has a large number of hard coded decisions written by Geronimoo and if we need customization then the rSpeer project is the way to go. On the flip side, the Geronimoo simulator generally has good play decisions.
Logged
Pages: [1]
 

Page created in 0.102 seconds with 21 queries.