Dominion Strategy Forum

Please login or register.

Login with username, password and session length
Pages: 1 [2] 3 4 ... 7  All

Author Topic: Geronimoo's Dominion Simulator: the ultimate simulation tool  (Read 227493 times)

0 Members and 1 Guest are viewing this topic.

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominion Simulator available for download!
« Reply #25 on: June 23, 2011, 08:36:10 am »
0

Quote
I don't think so. Determining what cards to buy has proven to be easy using just a few paramaters, but determining the correct play for a card involves many many decisions that we humans make without thinking, but will need to be explained one by one to the simulator. Just think about a card like Forge when you played Tactician the turn before: you know have 2^9 ways to play Forge... :)

I don't think it's easy, but it is not as difficult as you outline here. You "just" have to programm the system such that the user can specify the rules (for each card), you don't have to find these rules. And then the rules don't have to be perfect, Forge is kind of the worst case szenario. But also there some top-down rules like in the buys would improve the play of this cards a lot, even if it wouldn't be perfect.

Edit: just read how it handles Workshop etc., this seems very clever and will probably fit most situations. When knowing how it works, you probably can even play with the Buyrules to get good play for Ironworks (haven't figured it out yet).
Other question: Multiple buys is probably also difficult? I guess the easies solution here is to allow a condition on the number of available buys, so that one can test it and have say in a Smithy + Native Village setting

if (#Buys>1) && (other conditions)
Smithy > Gold (so that one would by Smithy+NV instead of Gold in this case)

I think just including this option will do it, than the user can do the rest and think about how he wants to split the money under which conditions...

Edit2: Oh, or you can just do it by CountInPlay(Bridge)>0 or whatever card gives you +Buys.
« Last Edit: June 23, 2011, 08:55:04 am by DStu »
Logged

flymolo

  • Herbalist
  • **
  • Offline Offline
  • Posts: 7
  • Respect: 0
    • View Profile
Re: Dominion Simulator available for download!
« Reply #26 on: June 23, 2011, 09:36:09 am »
0


4)let experienced players who know JAVA program extra play rules for the cards (at least level10s probably but I doubt we can be picky here?)
Although this will probably lead to thousands of lines of ugly code and more bugs it's the most feasible option to improve the simulator in the near future. This will of course require me to make the code available to the public which I'm still pondering about... What platform would you suggest if I decide to do that (I have no experience with open source)

sourceforge.net and github are the most common.  Sourceforge is easier unless you are already familiar with git.
You choose who has access to change the code directly.  Normally other people will submit patches to one of the people with commit access.  That is how code quality is maintained, and tests.

As to license
if you don't care that someone changes the code and never gives you those changes even if they are selling it: Apache License or BSD
If you want the code to be distributed if someone distributes binaries: GPL
If you are worried that someone will turn you program into a web service and not release the code: AGPL 3.0
Logged

rrenaud

  • Administrator
  • *****
  • Offline Offline
  • Posts: 991
  • Uncivilized Barbarian of Statistics
  • Respect: +1197
    • View Profile
    • CouncilRoom
Re: Dominion Simulator available for download!
« Reply #27 on: June 23, 2011, 09:52:31 am »
0

Well, I've never seen a genetic algorithm that was worth the time it takes to run, but I am using a different machine learning technique (stochastic gradient descent) in my code to determine what to buy. It's basically just fitting a hugely multivariate function whose input is your deck and an opponent's deck, and whose output is the probability that you win against that opponent.

It seems like I could adapt this kind of thing to the play of an individual hand, by making the input be your hand, number of actions, cards in play, etc. and the output be... money? Value of cards gained/bought? Improvement in your win probability as determined by the other function? I kind of like that last one.

What I would need is a lot of data about the intermediate stages one's hand goes through. I don't think dominionstats (the CouncilRoom code) currently does this; it only tracks the changes to decks, not hands. Is there existing code that can parse this from the game logs, or would I have to write it?

The iso logs don't contain enough information to get card play by card play game state info.  You don't see what cards people draw when they play +card actions :(.
Logged

Thanar

  • Bishop
  • ****
  • Offline Offline
  • Posts: 123
  • Respect: +138
    • View Profile
Re: Dominion Simulator available for download!
« Reply #28 on: June 23, 2011, 11:55:26 am »
0

First, a big "Thank you!" to Geronimoo for creating this tool and making it publicly available.

Second, a minor bug/limitation: When I first ran it, only the upper left quadrant of the UI showed up (i.e. no VP curve, Money curve, or Results chart). Knowing a bit about programming, I guessed that  my 1024x768 screen size was preventing the window from resizing to fit those additional UI elements. Sure enough, extending my screen size to 1280x960 solved the problem. Trying to resize the screen back down after the program started resulted in a wacky looking UI with most elements missing again. There may be an easy fix for this by just reducing the size of these graph & chart elements a bit to squeak in under 1024x768, or at least some kind of warning or note of the minimum screen size.

Third, I did discover a non-optimality in the _Single Chapel strategy after noticing that it would open Chapel/nothing on a 5/2 split when the $5 hand happened first. This can be easily fixed by adding condition (if available $ < 5) to the Buy Chapel rule, preventing it from triggering until the $2 hand in that one case, resulting in the optimal Silver/Chapel opening. This _Single Chapel Better strategy beats _Single Chapel 48% to 46%. When restricted to a 5/2 start, it wins 65% to 29%.

I'd imagine that similar improvements might be found for the buy rules of other strategies to avoid non-optimal opening buys.
« Last Edit: June 23, 2011, 11:59:10 am by Thanar »
Logged

WanderingWinder

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 5275
  • ...doesn't really matter to me
  • Respect: +4389
    • View Profile
    • WanderingWinder YouTube Page
Re: Dominion Simulator available for download!
« Reply #29 on: June 23, 2011, 12:56:38 pm »
0

He didn't tune the _Single X strategies at all. And yeah, I've been able to improve somewhat on several of the baseline strategies.

fp

  • Thief
  • ****
  • Offline Offline
  • Posts: 94
  • Respect: +6
    • View Profile
Re: Dominion Simulator available for download!
« Reply #30 on: June 24, 2011, 01:54:16 pm »
0

Silly question:

1) How do you get this to work on Mac OSX?
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominion Simulator available for download!
« Reply #31 on: June 25, 2011, 05:08:59 am »
0

Don't know, but I can tell you how it works under Linux. As there is a UNIX under the Mac/OS, it should work also.

1) Check if you have Java (open terminal, type: java and see if it knows the command), if not get Java from somewhere, http://www.java.com/de/download/ would be an idea. Install it. (Don't know how this works on a Mac)
2) Download the Simulator
3) Open terminal and move into the directory where the Simulator was downloaded to
4) type: java -jar DominionSimulator.jar
Logged

WanderingWinder

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 5275
  • ...doesn't really matter to me
  • Respect: +4389
    • View Profile
    • WanderingWinder YouTube Page
Re: Dominion Simulator available for download!
« Reply #32 on: June 30, 2011, 02:45:43 pm »
0

How does your sim deal with multiple buys? Does it always buy the first thing it can, and then with whatever money is left, buy the next thing? Is there anyway to make it think "oh, I've got 11 and two buys, it's better to get wharf and gold than Province and silver"?
Also, how does it deal with cards like Mint and Grand Market where you may not want to play all your money? Not well, I'd guess, as I can't think of a simple way around it, and don't have suggestions.
Not complaining, just wondering.

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominion Simulator available for download!
« Reply #33 on: June 30, 2011, 02:53:54 pm »
0

With n buys, it goes from the top n times.
You can condition on "inPlay(Bridge)>0" or something like that. Buys would be nicer, but this works for easy setting.
Logged

Geronimoo

  • Saboteur
  • *****
  • Offline Offline
  • Posts: 1059
  • Respect: +868
    • View Profile
    • Geronimoo's Dominion Simulator
Re: Dominion Simulator available for download!
« Reply #34 on: July 01, 2011, 05:06:00 am »
0

Like DStu said multiple buys are not accounted for automatically and you should add a condition like "if count in play Bridge (or Woodcutter...)>0". You can also use the condition "if available $ > X" in combation with the former to get the desired behaviour. I might implement something to support multiple buys (if you have suggestions how I to best handle this, they're very welcome).

If you have a Mint in your buy rules, the Simulator won't care if you just played 5 Platinums and buy that Mint anyway :) You can always add the "if count in play Gold =0" to the buy rules of Mint to avoid trashing good treasures.

If you have a Grand Market in your buy rules the Simulator will not play his Coppers if he can buy a Grand Market with the other money available (I built this in because Grand Market is a card I'd expect to see in a lot of simulations).
Logged

WanderingWinder

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 5275
  • ...doesn't really matter to me
  • Respect: +4389
    • View Profile
    • WanderingWinder YouTube Page
Re: Dominion Simulator available for download!
« Reply #35 on: July 01, 2011, 09:11:48 am »
0

Nice on the Grand Market front. The only thing I have for the buys thing is simply measuring buys, but I don't know if that's so feasible, and what you have is, I suppose good for 98% of cases.
I have no idea how you'd come up with something for mint - you probably could, but it would be really really complicated.
Thanks!

philosophyguy

  • Minion
  • *****
  • Offline Offline
  • Posts: 575
  • Respect: +299
    • View Profile
Re: Dominion Simulator available for download!
« Reply #36 on: July 01, 2011, 02:09:34 pm »
0

Does the simulator implement discard rules for cards like Alchemist and Herbalist? If not, can I make a feature request to add the ability to program discard rules in a similar manner to buy rules? (e.g., if Potion in play >= 1 and Alchemist in play > 0, discard Alchemist to top of deck).
Logged

Geronimoo

  • Saboteur
  • *****
  • Offline Offline
  • Posts: 1059
  • Respect: +868
    • View Profile
    • Geronimoo's Dominion Simulator
Re: Dominion Simulator available for download!
« Reply #37 on: July 01, 2011, 02:20:09 pm »
0

Alchemist should always be returned to the top when there's a Potion in play.

If you're not sure if the Simulator does something or not, you can always check the game log (sample game).
Logged

WanderingWinder

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 5275
  • ...doesn't really matter to me
  • Respect: +4389
    • View Profile
    • WanderingWinder YouTube Page
Re: Dominion Simulator available for download!
« Reply #38 on: July 06, 2011, 11:41:40 pm »
0

Geronimoo, does your sim have some kind of anti-self-destruct wherein it won't buy the last province if it is over 6 behind? Because I was looking at a sample game log and found this:

*** Chapel/Money(Plr 2)'s turn 24 ***
Chapel/Money(Plr 2)'s cards in Hand: [Gold, Gold, Silver, Silver, Duchy]
Chapel/Money(Plr 2) played 2 Golds, 2 Silvers, has $10 to spend and 1 buy
SUICIDE!! Can not buy Province
Duchy is no more available to buy
Chapel/Money(Plr 2) buys a Estate
Chapel/Money(Plr 2) draws 5 cards
Chapel/Money(Plr 2)'s cards in Hand: [Province, Duchy, Duchy, Gold, Silver]
     
      *** Monument(Plr 1)'s turn 24 ***
      Monument(Plr 1)'s cards in Hand: [Silver, Copper, Province, Silver, Gold]
      Monument(Plr 1) played 1 Gold, 2 Silvers, 1 Copper, has $8 to spend and 1 buy
      Monument(Plr 1) buys a Province
      Monument(Plr 1) draws 5 cards
      Monument(Plr 1)'s cards in Hand: [Copper, Silver, Copper, Monument, Copper]

!!!!!!!Game ends!!!!!!!!

the Empty Piles : [Duchy, Province]
the Trashed Cards : [Estate, Copper, Copper, Copper, Estate, Copper, Copper, Copper, Estate]



Chapel/Money(Plr 2) has 37 points (0 VP-tokens)!
Chapel/Money(Plr 2) shows this deck (23 cards) : [1 Copper, 5 Silver, 7 Gold, 1 Estate, 4 Duchy, 4 Province, 1 Chapel]

Monument(Plr 1) has 49 points (10 VP-tokens)!
Monument(Plr 1) shows this deck (33 cards) : [7 Copper, 7 Silver, 3 Gold, 3 Estate, 4 Duchy, 4 Province, 5 Monument]

(Edited to Bolden important bit)

Geronimoo

  • Saboteur
  • *****
  • Offline Offline
  • Posts: 1059
  • Respect: +868
    • View Profile
    • Geronimoo's Dominion Simulator
Re: Dominion Simulator available for download!
« Reply #39 on: July 08, 2011, 05:19:05 am »
0

yes, the simulator will not make any purchase that will result in a loss
Logged

Razzishi

  • Conspirator
  • ****
  • Offline Offline
  • Posts: 216
  • Shuffle iT Username: Eye Urn
  • Respect: +121
    • View Profile
Re: Dominion Simulator available for download!
« Reply #40 on: July 19, 2011, 01:27:42 pm »
0

Great program; I downloaded it awhile ago and only really got to see what it was capable of recently.  A few things that I found potentially useful to add to the buy rules have been mentioned already: number of cards in deck, and number of available buys.  In the latter case, it is not sufficient to check for cards giving +Buy in play, because it's possible you already have used the buy it gave you.  Another thing that I'd be interested in is having the ability to put in whatever number you want in places and not be limited by 1-20.  I have times wished I could use fractions when working with * and / operations, and other times wanted to choose numbers larger than 20.  While I can use the additional + number box in some cases, there's other times that I need it for something else.

There's at least one play rule that could use some tweaking, involving King's Court, Grand Market and Bridge.  If there are no more cards in your deck, the program will still copy Grand Market in preference to Bridge.  In such a case, the income + cost reduction of Bridge is superior to the income of GM and the extra actions will generally not be relevant if you've drawn your whole deck and are able to copy multiple Bridges; if you have no deck left with additional King's Court uses to come, you probably have plenty of actions from copied Grand Markets and so long as you copy all your Bridges you only need 1 action to play any number of GMs once you run out of KCs.  With the current rules, it tries to copy every GM in the deck first and thus tends to end up playing some Bridges normally and not reduce the cost of the top green card enough to buy them out that turn when it easily could have.

I think there's a bit of a bug in the VP and money graphs, or at least odd way of handling the last few turns.  It appears as though the number displayed is the determined by adding all the numbers for that turn and dividing by the number of games simulated, and counting a 0 for a game that turn if the game had already finished a previous turn.  This leads to the graph consistently dipping the last few turns, as some games will end sooner than others.  Thus the graphs present a somewhat inaccurate view of how the deck performs the last few turns.
Logged
Stop reading my signature.

DG

  • Governor
  • *****
  • Offline Offline
  • Posts: 4074
  • Respect: +2624
    • View Profile
Re: Dominion Simulator available for download!
« Reply #41 on: July 19, 2011, 01:58:39 pm »
0

I found a logic problem with the card play in the simulator today. If you put a command into the simulator to buy exactly one  gold if there is a no gold in the deck, ahead of buying provinces, then problems can arise. With a remodel and gold in hand it decides to remodel the gold into a province, but looks at the buy list and remodels the gold into a gold instead.

Logged

Geronimoo

  • Saboteur
  • *****
  • Offline Offline
  • Posts: 1059
  • Respect: +868
    • View Profile
    • Geronimoo's Dominion Simulator
Re: Dominion Simulator available for download!
« Reply #42 on: July 19, 2011, 06:02:09 pm »
0

@Razzishi:
I'll try to add the "number of buys left" and >20 number choices in my next release. I originally had a field to let people type in the number themselves which allowed fractions, but it looked ugly and was cumbersome to work with and I haven't ever found the need to use fractions myself.

@DG:
That's indeed a problem. Maybe you can add some extra buy conditions to avoid this behaviour?
Logged

fp

  • Thief
  • ****
  • Offline Offline
  • Posts: 94
  • Respect: +6
    • View Profile
Re: Dominion Simulator available for download!
« Reply #43 on: July 19, 2011, 09:46:55 pm »
0

Don't know, but I can tell you how it works under Linux. As there is a UNIX under the Mac/OS, it should work also.

1) Check if you have Java (open terminal, type: java and see if it knows the command), if not get Java from somewhere, http://www.java.com/de/download/ would be an idea. Install it. (Don't know how this works on a Mac)
2) Download the Simulator
3) Open terminal and move into the directory where the Simulator was downloaded to
4) type: java -jar DominionSimulator.jar

I receive the following error message:

Code: [Select]
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:676)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:317)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:375)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:54)
Logged

danshep

  • Navigator
  • ****
  • Offline Offline
  • Posts: 70
  • Respect: +15
    • View Profile
Re: Dominion Simulator available for download!
« Reply #44 on: July 20, 2011, 01:44:12 am »
0

That error message means that the simulator was compiled with a later version of java than the version you have installed. Upgrade your java runtime if you can.
Logged

Davio

  • 2012 Dutch Champion
  • *
  • Offline Offline
  • Posts: 4787
  • Respect: +3413
    • View Profile
Re: Dominion Simulator available for download!
« Reply #45 on: August 01, 2011, 08:54:24 am »
0


4)let experienced players who know JAVA program extra play rules for the cards (at least level10s probably but I doubt we can be picky here?)
Although this will probably lead to thousands of lines of ugly code and more bugs it's the most feasible option to improve the simulator in the near future. This will of course require me to make the code available to the public which I'm still pondering about... What platform would you suggest if I decide to do that (I have no experience with open source)

sourceforge.net and github are the most common.  Sourceforge is easier unless you are already familiar with git.
You choose who has access to change the code directly.  Normally other people will submit patches to one of the people with commit access.  That is how code quality is maintained, and tests.

As to license
if you don't care that someone changes the code and never gives you those changes even if they are selling it: Apache License or BSD
If you want the code to be distributed if someone distributes binaries: GPL
If you are worried that someone will turn you program into a web service and not release the code: AGPL 3.0
I would very much like to see this get some sort of Open Source status.
I am a computer programmer by trade and would very much like to contribute to this project.

Geronimoo, you can always review the changes yourself before you approve them.

We can start with card strategies for simple cards.
For instance Smithy: If you already have $8 (with 1 Buy) and there are 3 remaining Estates in your draw pile, play the Smithy.
If the next three cards are 2 Golds and 1 Silver, don't play it.

Something like that.

Obviously, correctly choosing one of Pawn's 6 options is not so easy.
Logged

BSG: Cagprezimal Adama
Mage Knight: Arythea

Captain_Frisk

  • Saboteur
  • *****
  • Offline Offline
  • Posts: 1257
  • Respect: +1263
    • View Profile
Re: Dominion Simulator available for download!
« Reply #46 on: August 04, 2011, 05:32:39 pm »
0

How on earth does the countMaxOpponentsVP work?  Is that the theoretical maximum vp of the opponent, or the current max?

I tried "improving" the big money ultimate strategy that wouldn't buy the final province if it would cause you to lose... assuming that you wouldn't buy the final province unless opponentVP - YourVP >= 6 (I was playing from 2nd place).

Naturally, this dropped my win rate from 43% to 20%.

What am I doing wrong?
   <buy name="Province">
      <condition>
         <left type="countCardsInSupply" attribute="Province"/>
         <operator type="greaterOrEqualThan" />
         <right type="constant" attribute="2.0"/>
      </condition>
   </buy>
   <buy name="Province">
      <condition>
         <left type="countVP"/>
         <operator type="greaterOrEqualThan" />
         <right type="countMAXOpponentVP"/>
         <extra_operation type="minus" attribute="6.0" />
      </condition>
      <condition>
         <left type="countCardsInSupply" attribute="Province"/>
         <operator type="equalTo" />
         <right type="constant" attribute="1.0"/>
      </condition>
   </buy>
Logged
I support funsockets.... taking as much time as they need to get it right.

WanderingWinder

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 5275
  • ...doesn't really matter to me
  • Respect: +4389
    • View Profile
    • WanderingWinder YouTube Page
Re: Dominion Simulator available for download!
« Reply #47 on: August 04, 2011, 08:41:26 pm »
0

Frisk, I haven't worked out how to get that vxml into my newly-downloaded copy of the sim (new laptop, all other data gone... :( ), but it looks to me like instead of not buying provinces if you are behind by more than 6, you aren't buying provinces until you're AHEAD more than 6...

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominion Simulator available for download!
« Reply #48 on: August 05, 2011, 03:33:39 am »
0

Frisk, I haven't worked out how to get that vxml into my newly-downloaded copy of the sim (new laptop, all other data gone... :( ), but it looks to me like instead of not buying provinces if you are behind by more than 6, you aren't buying provinces until you're AHEAD more than 6...

Not exatly, he buys Provinces if
A) There are at least 2 left or
B1) his VP are at least the once of his opponent MINUS 6 and
B2)  there is exactly one left

In my Simulator Frisk's vxml also gives 43% winchance. The point is that, as far as I understood it, the simulator by itself does not buy cards if they cause you to loose. You can see this in the individual sample game, when the line "SUICIDE!! Can not buy Province" apears (If you want to see it yourself delete the lines for Duchies and Estates, that increases the likelihood that this will happen)
Logged

Geronimoo

  • Saboteur
  • *****
  • Offline Offline
  • Posts: 1059
  • Respect: +868
    • View Profile
    • Geronimoo's Dominion Simulator
Re: Dominion Simulator available for download!
« Reply #49 on: August 05, 2011, 04:38:02 am »
0

As DStu said (and this has been mentioned several times) the simulator bot will not buy ANY card that causes it to lose the game.
Logged
Pages: 1 [2] 3 4 ... 7  All
 

Page created in 0.063 seconds with 20 queries.