Dominion Strategy Forum

Please login or register.

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

Author Topic: count gains needed to end game or Provinces left?  (Read 4183 times)

0 Members and 1 Guest are viewing this topic.

Geronimoo

  • Saboteur
  • *****
  • Offline Offline
  • Posts: 1059
  • Respect: +868
    • View Profile
    • Geronimoo's Dominion Simulator
count gains needed to end game or Provinces left?
« on: September 30, 2011, 03:40:59 am »
0

I'm busy refacotring all the built-in bots in my simulator, but I need your help.

Should I replace all these:

if 'count cards left in supply(provinces)' <= X

by

if '#buys/gains needed to end game' <=X

The latter is a heuristic used mainly in rspeer's simulator and it seems better than counting Provinces, but I'm not sure. If you have arguments for or against it, I'd be glad to hear them.
Logged

WanderingWinder

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 5275
  • ...doesn't really matter to me
  • Respect: +4385
    • View Profile
    • WanderingWinder YouTube Page
Re: count gains needed to end game or Provinces left?
« Reply #1 on: September 30, 2011, 09:39:37 am »
0

...test it? I have no idea. The thing is, some situations are going to call for one or the other, but most of the time there isn't a difference, and most of the time there IS a difference, the latter way will be what you need. So, if you're just going to pick, go with that one.

Geronimoo

  • Saboteur
  • *****
  • Offline Offline
  • Posts: 1059
  • Respect: +868
    • View Profile
    • Geronimoo's Dominion Simulator
Re: count gains needed to end game or Provinces left?
« Reply #2 on: September 30, 2011, 10:08:51 am »
0

I did some tests and as expected they function pretty much the same, although the '#buys needed to end game' has a small overall advantage (1-2%). There is one big downside though: simulations take about 50% longer because the entire board needs to be scanned instead of just counting the Province or Colony pile.
Logged

Buggz

  • Spy
  • ****
  • Offline Offline
  • Posts: 88
  • Respect: +12
    • View Profile
Re: count gains needed to end game or Provinces left?
« Reply #3 on: September 30, 2011, 11:18:50 am »
0

I'm sure some smart optimisations could negate most of that disadvantage, e.g. by only observing stacks with 4 or fewer cards left. That way you'll mostly scan the province/colony stacks and only the other stacks when actually needed. Maybe only when two or more stacks are in that "danger zone". I guess it could be ignored if the kingdom is lacking in +buy too, removing the extra computation from another couple of games.
Logged

DG

  • Governor
  • *****
  • Offline Offline
  • Posts: 4074
  • Respect: +2624
    • View Profile
Re: count gains needed to end game or Provinces left?
« Reply #4 on: September 30, 2011, 11:39:20 am »
0

Quote
There is one big downside though: simulations take about 50% longer because the entire board needs to be scanned instead of just counting the Province or Colony pile.
I've put together a complicated script using your simulator in the past and I did wonder about optimisation. I'd suggest letting the user define a calculation as a row in the purchasing script and then allow reference to that calculation further down. This would then at least prevent repeated calculation within the script of values such as "count vp - maximum opponent's vp".

I can't think of any other problem using "#buys/gains needed to end game" as long as the user can override this and use provinces when necessary (for tournaments etc). You'd know better than us whether the card play rules will be affected for issues such as forging a province into a province, just to exhaust the supply.
Logged

HiveMindEmulator

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2222
  • Respect: +2118
    • View Profile
Re: count gains needed to end game or Provinces left?
« Reply #5 on: September 30, 2011, 12:13:32 pm »
0

50% longer is kind of a lot. That's a bit surprising. I guess the issue is that the condition shows up at the top of the buy list constantly. It's probably better to maintain a state of the 3 smallest piles and update it after every buy.

I'd suggest letting the user define a calculation as a row in the purchasing script and then allow reference to that calculation further down. This would then at least prevent repeated calculation within the script of values such as "count vp - maximum opponent's vp".
This is the kind of thing compilers usually handle, but maybe the script interpreter doesn't. I don't know, as I haven't ever really tried to optimize stuff in high-level languages. Perhaps by explicitly storing the calculation result in a variable it will make it more likely that it will cache the result and just use that? Otherwise, you might want to add a step where you pass once through the script and search for duplicate lines and fix it...

Failing any of that, you can probably safely leave it as 'provinces remaining' for the BM-type bots that are unlikely to run into 3-pile stuff. If someone is doing some serious comparing to another strategy that does pile, they can change it. For the big combo bots where it matters more, you should probably go ahead and change it to 'gains to end'.
Logged

rspeer

  • Witch
  • *****
  • Offline Offline
  • Posts: 469
  • Respect: +877
    • View Profile
Re: count gains needed to end game or Provinces left?
« Reply #6 on: October 03, 2011, 07:14:42 pm »
0

In my simulator, I definitely had to cache this, because it's checked so many times per turn. I got at least a 2x speedup when I did.

My strategy: check if there's a cached value for gainsToEndGame, and return it if so. Otherwise, calculate it and put it in the cache. Whenever a card is gained or returned to the Supply, clear the cached value.

(I clear the value instead of recalculating it right then, because multiple cards could be gained in quick succession, with no need to calculate gainsToEndGame in between.)
Logged

buggibum

  • Ambassador
  • ***
  • Offline Offline
  • Posts: 31
  • Respect: +4
    • View Profile
Re: count gains needed to end game or Provinces left?
« Reply #7 on: January 05, 2012, 08:20:14 pm »
0

I know im late, but im getting in your simulator lately.

Can you explain what

"if '#buys/gains needed to end game' <=X"

actually means? Is it related to your own buys needed to end the game or to everyone's buys to end the game?
Logged

Razzishi

  • Conspirator
  • ****
  • Offline Offline
  • Posts: 216
  • Shuffle iT Username: Eye Urn
  • Respect: +121
    • View Profile
Re: count gains needed to end game or Provinces left?
« Reply #8 on: January 05, 2012, 10:32:17 pm »
+1

I know im late, but im getting in your simulator lately.

Can you explain what

"if '#buys/gains needed to end game' <=X"

actually means? Is it related to your own buys needed to end the game or to everyone's buys to end the game?

The minimum needed cards that need to be gained from the supply in order to end the game.  Its upper bound is the number of Provinces remaining, but can be lower if less cards need to be gained in order to cause the game to end from 3 piles being empty.  On a remaining board of a bunch of full stacks, 4 Provinces, 0 Ill-gotten Gains, 0 Curses, and 1 Estate, the value is 1.  Change it to 1 Curse and 1 Estate, and the value is 3.  Fill up any of those piles, and the highest it gets is 4.
Logged
Stop reading my signature.

def

  • Conspirator
  • ****
  • Offline Offline
  • Posts: 239
  • Respect: +166
    • View Profile
Re: count gains needed to end game or Provinces left?
« Reply #9 on: January 06, 2012, 04:08:22 pm »
0

Why is it 3 and not 2 with 1 Curse and 1 Estate left?
Bonus question: With 1 IGG and 1 Curse left for a three-pile ending, does the simulator recognize it as "1 gain needed"?
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: count gains needed to end game or Provinces left?
« Reply #10 on: January 06, 2012, 05:09:32 pm »
0

Bonus question: With 1 IGG and 1 Curse left for a three-pile ending, does the simulator recognize it as "1 gain needed"?

I guess no, and actually that's still 2 gains, the one just tend to imply the other...
Logged

rod-

  • Conspirator
  • ****
  • Offline Offline
  • Posts: 213
  • Respect: +49
    • View Profile
Re: count gains needed to end game or Provinces left?
« Reply #11 on: January 06, 2012, 05:15:06 pm »
0

Related question:  what would the proper syntax be to code in something like :

If #buys needed to end the game <= #buys & cost=#coins, buy #thingsneededtoendthegame (If score > oppscore)

Logged

DG

  • Governor
  • *****
  • Offline Offline
  • Posts: 4074
  • Respect: +2624
    • View Profile
Re: count gains needed to end game or Provinces left?
« Reply #12 on: January 06, 2012, 08:41:07 pm »
0

This sort of script will buy out one last supply pile. If you wanted to buy out cards across many piles then you're going to run into trouble calculating the total coins needed to do so.

Code: [Select]
<player name="Example"
 author=""
 description="">
 <type name="UserCreated"/>
 <type name="Province"/>
 <type name="TwoPlayer"/>
 <type name="Bot"/>
   <buy name="Hamlet">
      <condition>
         <left type="countCardsInSupply" attribute="Hamlet"/>
         <operator type="smallerOrEqualThan" />
         <right type="countBuysLeft"/>
      </condition>
      <condition>
         <left type="countVP"/>
         <operator type="greaterThan" />
         <right type="countMAXOpponentVP"/>
      </condition>
      <condition>
         <left type="countEmptyPiles"/>
         <operator type="equalTo" />
         <right type="constant" attribute="2.0"/>
      </condition>
      <condition>
         <left type="countCardsInSupply" attribute="Hamlet"/>
         <operator type="smallerOrEqualThan" />
         <right type="countAvailableMoney"/>
         <extra_operation type="divideBy" attribute="2.0" />
      </condition>
   </buy>
</player>
Logged
Pages: [1]
 

Page created in 0.049 seconds with 20 queries.