Dominion Strategy Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 5 6 [7] 8 9 ... 13  All

Author Topic: Dominiate: a Dominion simulator that runs on the Web  (Read 247940 times)

0 Members and 1 Guest are viewing this topic.

rspeer

  • Witch
  • *****
  • Offline Offline
  • Posts: 469
  • Respect: +877
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #150 on: November 29, 2011, 06:40:14 am »
0

What we gain in speed that way, we lose in inscrutability. When the code is clear and accessible, it invites people to join the project.

Here's another suggestion. Let's just replace the default action priority list with a priority value function, which delegates to a method on each relevant card. Then only the cards in hand will be evaluated. Plus, we get to define this on the card itself (much like Geronimoo does), and this gives us a nice hook for letting people define variant cards and test them.
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #151 on: November 29, 2011, 06:53:35 am »
0

I don't think that the code would be a mess, and for most part of the project, you could ignore it.
But of course hacky modification of written code is somehow dangerous, especially in the long run if you are not totally clean. And "clean" probably then means really consider everything that JS can present you, which certainly I can't.

So your idea would be to give each card a value (probably function) that calculates its playPriority.
You would have to modify the card to modify the priority?

That might work. I also think that it's much easier to do little changes with this function, as to do small modifications, say exchange the priority of two cards would be much easier, as you don't have to rewrite the whole code for actionPriority (which would be especially funny if you want to keep the KC/TR-code), but only need to edit these two cards and exchange their playPriority.

Edit: Probably you could also have both a function and a value, as the value is easier to modify, and the function could be defaulted to
Code: [Select]
  priorityFunc (my, state) ->
    return priorityValue

Edit2: I haven't read your code for KC/TR. Does this work with this concept?
« Last Edit: November 29, 2011, 06:56:26 am by DStu »
Logged

danshep

  • Navigator
  • ****
  • Offline Offline
  • Posts: 70
  • Respect: +15
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #152 on: November 29, 2011, 06:02:59 pm »
0

I'll try and find time to turn my mangled explanation into working code. It's not as complicated as I make it sound.
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #153 on: December 01, 2011, 12:54:24 pm »
0

Ok, than I will not mess around with this yet. And rspeers proposal is probably a big change, best done by himself.

Another topic: http://forum.dominionstrategy.com/index.php?topic=144.msg17103#msg17103
I bragged that I can do it in 4 lines of code in this sim (Actually it would be 2 if the 10 starting cards would be defined in 1 line and not 2 for readability...).

Is this interesting somehow. I think one really only must take
Code: (gameState.coffee line 19) [Select]
@discard = [c.Copper, c.Copper, c.Copper, c.Copper, c.Copper,
                c.Copper, c.Copper, c.Estate, c.Estate, c.Estate]
and replace the array by a function from the ai, like
Code: [Select]
@discard = ai.startingDeck()
And define the standardDeck in
Code: (basicAI.coffee line XYZ) [Select]
startingDeck () ->  [c.Copper, c.Copper, c.Copper, c.Copper, c.Copper,
                             c.Copper, c.Copper, c.Estate, c.Estate, c.Estate]
Then anybody could overwrite the startingDeckFunction as he wishes.
Logged

Jorbles

  • Saboteur
  • *****
  • Offline Offline
  • Posts: 1468
  • Respect: +531
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #154 on: December 15, 2011, 08:25:25 pm »
0

You know what would be a great feature that I don't think would be very hard to add? A piece of data that shows the average/median turn a game ends on after a simulation has been run. What do other people think?

I tend to think of strategies as being good/bad based on how fast they are and I know it would depend on your opponent's strategy, but if you play a strategy against itself it would let you know how fast the strategy is compared to others.
Logged

rspeer

  • Witch
  • *****
  • Offline Offline
  • Posts: 469
  • Respect: +877
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #155 on: December 22, 2011, 03:03:48 am »
0

I have a branch where I'm assigning values to everything in the actionPriority list. It's slow going because it's quite tedious and requires jumping all around cards.coffee while trying to remember what three-digit number I was on.

Showing the median turn a game ends on would be a great idea. Especially if it can be shown on the same graph as the average VP -- put a vertical line at the median game length, maybe even shade in from the 25th to 75th percentiles.
Logged

ecq

  • Conspirator
  • ****
  • Offline Offline
  • Posts: 224
  • Respect: +162
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #156 on: December 27, 2011, 09:21:11 pm »
0

I'm having trouble getting the command-line client working, using the latest coffeescript, node, and dominiate code.

Basic info:

Code: [Select]
ecq ~/proj/dominiate [master] $ uname -mrs
Darwin 11.2.0 x86_64
ecq ~/proj/dominiate [master] $ node -v
v0.6.6
ecq ~/proj/dominiate [master] $ coffee -v
CoffeeScript version 1.2.0
ecq ~/proj/dominiate [master] $ git log --oneline -n 1
b26f896 mark Secret Chamber as done -- fixes #36

First problem:

Code: [Select]
ecq ~/proj/dominiate [master] $ ./play.coffee  strategies/BigMoney.coffee strategies/BigSmithy.coffee
SyntaxError: In /Users/patrick/proj/dominiate/basicAI.coffee, unmatched OUTDENT on line 438
    at SyntaxError (unknown source)
    at Lexer.error (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/lexer.js:584:13)
    at Lexer.pair (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/lexer.js:539:40)
    at Lexer.outdentToken (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/lexer.js:298:16)
    at Lexer.lineToken (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/lexer.js:276:14)
    at Lexer.tokenize (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/lexer.js:28:94)
    at /usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:40:34
    at Object..coffee (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:18:17)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)

The indentation for the default action priority list appears to be incorrect.  This is easy enough to fix, but I'm hoping the fact that I see it sheds some light on things.  Fixing that issue and moving on...

Code: [Select]
ecq ~/proj/dominiate [master*] $ git diff
diff --git a/basicAI.coffee b/basicAI.coffee
index 2127661..2d1b7c4 100644
--- a/basicAI.coffee
+++ b/basicAI.coffee
@@ -435,7 +435,7 @@ class BasicAI
     "Treasure Map"
     "Ambassador"
     "Throne Room"
-  ]
+    ]
   
   # `multipliedActionPriority` is similar to `actionPriority`, but is used when
   # we have played a Throne Room or King's Court.
ecq ~/proj/dominiate [master*] $ ./play.coffee  strategies/BigMoney.coffee strategies/BigSmithy.coffee
TypeError: object is not a function
    at Array.CALL_NON_FUNCTION_AS_CONSTRUCTOR (native)
    at /Users/patrick/proj/dominiate/play.coffee:14:10
    at /Users/patrick/proj/dominiate/play.coffee:33:23
    at /Users/patrick/proj/dominiate/play.coffee:36:6
    at Object.<anonymous> (/Users/patrick/proj/dominiate/play.coffee:64:3)
    at Object.<anonymous> (/Users/patrick/proj/dominiate/play.coffee:70:4)
    at Module._compile (module.js:432:26)
    at Object.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:68:25)
    at /usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:135:29
    at /usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:110:18

This is where things get tricky for me, because I've barely used node.js.  Google suggests the problem is a circular reference.  Despite what the stack trace says, the offending line seems to be line 12: "ai = new BasicAI()" in play.coffee.  For some reason BasicAI is an array containing the BasicAI constructor, when it should be the constructor itself.  I poked around a little and found that on line 1201 of basicAI.coffee, immediately after defining the BasicAI class, BasicAI is an array.  Weird.

In case it was a circular reference, I tried swapping lines 6 and 7 of play.coffee (the lines that require gameState and basicAI) to see if that made a difference.  It does.  Swapping those two lines allows the program to run without exceptions, but neither AI buys anything and the simulation just runs on forever.

Thoughts?  Am I missing something simple?  What versions are known to work?  I'm not sure if this is the best place to post this info, or if the github bug tracker is more appropriate.  Let me know if I should move it.

Thanks for the help and the awesome project.  I can't wait to use it.
Logged

rspeer

  • Witch
  • *****
  • Offline Offline
  • Posts: 469
  • Respect: +877
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #157 on: December 29, 2011, 03:04:59 pm »
0

Hm, I suppose that's the problem with a fast-moving programming language. I'm running on Node 0.4.10 (and that was a cutting-edge version when I started).

Later I'll try upgrading Node and see what goes wrong.
Logged

rspeer

  • Witch
  • *****
  • Offline Offline
  • Posts: 469
  • Respect: +877
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #158 on: December 30, 2011, 07:09:10 am »
0

Okay, it seems that the change was entirely in CoffeeScript. I upgraded to Node v0.6.6 and Dominiate continues to run correctly. So the problems can only be in syntax that has changed in CoffeeScript 1.2.

This means that a possible quick fix is to install CoffeeScript 1.1 for now. Certainly not a state I want to leave things in, of course.
Logged

ecq

  • Conspirator
  • ****
  • Offline Offline
  • Posts: 224
  • Respect: +162
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #159 on: December 30, 2011, 12:16:42 pm »
0

Thanks for the help.  CoffeeScript v1.1.0 works fine for me.  I filed a bug to fix v1.2.0: https://github.com/rspeer/dominiate/issues/56.  I also sent a pull request with code that fixes a couple of the issues.
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #160 on: January 08, 2012, 07:44:41 am »
0

So, I added a first guess for support of costum starting state in my repo .

You can redefine the starting state there by overwriting the functions
startingDraw: () -> []
and
startingDiscard: () -> []

to whatever cards you like to have in your deck. It's a zero-variable function because I don't understand how coffeescript handles variables, so functions are easier.
Not much tested and no support for enable/disable shuffling or anything fancy like played Durations from last turn, so no pullrequest yet, just for information...

edit: OK, realized (while wanting to test something else) that perhaps I should also care for the supplies when I change the starting state. Anyway, I also have a 0.something  version of the "don't kill yourself rule". It should work like that:

Before proposing tha ai some cards to choose from to buy, erase all that that will cause it to lose if it will buy it and afterwards finish the buyphase as usual.
If that works, it is even better as what Geronimoo does, because, if I have figured it out correctly only tests if the current buy will kill you, without considering if further buys might rescue you again (because maybe Province/Estate will win you, when Province alone will make you lose).
Also online on my page now.
« Last Edit: January 08, 2012, 10:11:43 am by DStu »
Logged

rspeer

  • Witch
  • *****
  • Offline Offline
  • Posts: 469
  • Respect: +877
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #161 on: January 26, 2012, 03:36:45 am »
0

Thanks for all the contributions, and sorry that I've been away. I've merged them all and pushed the changes to the Web version, and nothing seems to be on fire yet!

Quick summary: ecq (blits) refactored code so that "fast mode" is the only mode, fixed the incompatibilities with CoffeeScript 1.2.0, got rid of some card-specific hacks, fixed Courtyard strategies, and implemented Scheme. DStu added the "no suicide rule". (Any chance we can beat Geronimoo to the Penultimate Province Rule?)

Would there happen to be anyone who feels like writing test cases that make sure the game actually follows the rules of Dominion? A bit of a thankless job, I know, but it will pay off massively in that we can try all kinds of new optimizations and reworkings without worrying about breaking the gameplay. With these merges, for example, I had to track down a very easy-to-miss bug where AIs could use Lighthouses as Moats and reuse Horse Traders -- but I'm not complaining about that too much, because there were so many useful changes in here.
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #162 on: January 26, 2012, 03:58:58 am »
0

Quote
Quick summary: ecq (blits) refactored code so that "fast mode" is the only mode, fixed the incompatibilities with CoffeeScript 1.2.0, got rid of some card-specific hacks, fixed Courtyard strategies, and implemented Scheme. DStu added the "no suicide rule". (Any chance we can beat Geronimoo to the Penultimate Province Rule?)

Beside that "no suicide" only works in the buy-phase until now, we already beat Geronimoo in the following scenario: You have $10 and 2 buys, 1 Province left and are 6VPs behind. Geronimoo buys 2 Duchies (because Province is forbidden, next prio is Duchy), we buy Province and Estate and win, because buys are only forbidden if you lose after the buy-phase is completed.
Logged

ecq

  • Conspirator
  • ****
  • Offline Offline
  • Posts: 224
  • Respect: +162
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #163 on: January 27, 2012, 08:52:44 pm »
0

Thanks for all the contributions, and sorry that I've been away. I've merged them all and pushed the changes to the Web version, and nothing seems to be on fire yet!

Quick summary: ecq (blits) refactored code so that "fast mode" is the only mode, fixed the incompatibilities with CoffeeScript 1.2.0, got rid of some card-specific hacks, fixed Courtyard strategies, and implemented Scheme. DStu added the "no suicide rule". (Any chance we can beat Geronimoo to the Penultimate Province Rule?)

Would there happen to be anyone who feels like writing test cases that make sure the game actually follows the rules of Dominion? A bit of a thankless job, I know, but it will pay off massively in that we can try all kinds of new optimizations and reworkings without worrying about breaking the gameplay. With these merges, for example, I had to track down a very easy-to-miss bug where AIs could use Lighthouses as Moats and reuse Horse Traders -- but I'm not complaining about that too much, because there were so many useful changes in here.

I sent you a PM on GitHub asking about next steps.  Testing stuff was one possibility.  I don't mind writing test cases or ideally setting things up so it's easy for all of us to write test cases.  It's not my favorite thing to do, but it seems like a prerequisite for bigger and better things.  I could use some input on testing framework.  Cucumber-js is one option that I played with https://github.com/bilts/dominiate/commit/cbe8cc730c58f03a23cdcdda06d68f12ad31116c.  I've also had positive experiences with Jasmine on other projects.

Related: What's the best way to send you those sorts of messages?  Should I just post here or PM on this forum?
Logged

theory

  • Administrator
  • *****
  • Offline Offline
  • Posts: 3603
  • Respect: +6121
    • View Profile
    • Dominion Strategy
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #164 on: January 31, 2012, 06:14:56 am »
0

How should I redefine the Tactician play rule?  Right now it seems to discard it at any opportunity.  How would I set it to discard only after playing everything else (so long as one card is left) and there is < $X in the hand?

Also, when I had buggy code (for example, I had requires: ["Tactician, Tunnel"] instead of requires: ["Tactician", "Tunnel"]), it didn't tell me, but instead just weirded out and ended up reverting me back to BankWharf.
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #165 on: January 31, 2012, 06:33:57 am »
+1

How should I redefine the Tactician play rule?  Right now it seems to discard it at any opportunity.  How would I set it to discard only after playing everything else (so long as one card is left) and there is < $X in the hand?

You should not mess with Tactician, it does exectly what it does. What you need to redefine is actionPriority, because you don't want to play the Tactician at every opportunity.
For playing it after anything else, you want it to be behind all the +Actions in the actionPriority-list, for your second you want something like
Code: [Select]
...
"Tactician" if pessimisticMoneyInHand(state) <= $x
...
ceterum censeo: You should redefine the actionPriority anyway for most bots just with the cards you care for, that speeds up the bot quite a bit.

edit: OK, I see, when you have played a Village before you also want to play all other terminals before. In that case you want
Code: [Select]
"Tactician" if countPlayableTerminals(state) == 1
at the position it is now, and some an additional single "Tactician" some pretty low.
« Last Edit: January 31, 2012, 06:38:37 am by DStu »
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #166 on: February 14, 2012, 03:06:53 am »
0

Trader onGain doesn't work?

I have the two following issues: Bot a) Trader/Market:
Code: [Select]
# Play Big Money including Banks, except buy Wharf with every $5 buy.
{
  name: 'Trader/Market'
  author: 'DStu'
  requires: ['Trader', 'Cache']
  gainPriority: (state, my) -> [
    "Province" if my.getTotalMoney() >= 16
    "Duchy" if state.gainsToEndGame() <= 4
    "Estate" if state.gainsToEndGame() <= 2
    "Market"
    "Trader" if my.countInDeck("Trader") < 2
    "Silver"
    "Copper" if my.countInHand("Trader") > 0
  ]
 
  actionPriority: (state, my) -> [
  ]
 
  trashPriority: (state, my) -> [
     "Trader" if my.getAvailableMoney() < 5
     "Estate" if state.gainsToEndGame() > 4
     "Curse"
     "Copper"
  ]
}

Code: [Select]
== Trader/Market's turn 3 ==
[...]
Trader/Market draws 5 cards: [Estate, Copper, Trader, Copper, Estate].

== BigSmithy's turn 4 ==
[...]

== Trader/Market's turn 4 ==
Trader/Market plays Copper.
Trader/Market plays Copper.
Coins: 2, Potions: 0, Buys: 1
Trader/Market buys Copper.
(Trader/Market shuffles.)
Trader/Market draws 5 cards: [Silver, Copper, Copper, Estate, Copper].
Why doesn't it show the Trader? Similarly with Cache:

Code: [Select]
# Play Big Money including Banks, except buy Wharf with every $5 buy.
{
  name: 'Trader/Cache'
  author: 'DStu'
  requires: ['Trader', 'Cache']
  gainPriority: (state, my) -> [
    "Province" if my.getTotalMoney() >= 16
    "Duchy" if state.gainsToEndGame() <= 4
    "Estate" if state.gainsToEndGame() <= 2
    "Cache" if my.countInHand("Trader") > 0
    "Gold"
    "Cache"
    "Trader" if my.countInDeck("Trader") < 2
    "Silver"
  ]
 
  actionPriority: (state, my) -> [
    "Trader" if (my.getAvailableMoney() < 5 and this.wantsToTrash(state) )
    "Trader" if (my.countInHand("Trader") > 1 and this.wantsToTrash(state) )
  ]
 
  trashPriority: (state, my) -> [
     "Trader" if my.getAvailableMoney() < 5
     "Estate" if state.gainsToEndGame() > 4
     "Curse"
     "Copper"
  ]
}

Code: [Select]
== Trader/Cache's turn 7 ==
[...]
Trader/Cache draws 5 cards: [Copper, Trader, Silver, Copper, Gold].

== BigSmithy's turn 8 ==
[...]
== Trader/Cache's turn 8 ==
Trader/Cache plays Gold.
Trader/Cache plays Silver.
Trader/Cache plays Copper.
Trader/Cache plays Copper.
Coins: 7, Potions: 0, Buys: 1
Trader/Cache buys Cache.
Trader/Cache gains Copper.
Trader/Cache gains Copper.
Trader/Cache draws 5 cards: [Copper, Silver, Copper, Silver, Copper].
Logged

ecq

  • Conspirator
  • ****
  • Offline Offline
  • Posts: 224
  • Respect: +162
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #167 on: February 14, 2012, 08:38:11 am »
0

Trader onGain doesn't work?

I discovered this issue yesterday as well.  We were probably both looking at the same thread in the General section.  I fixed it and have a pull request open: https://github.com/rspeer/dominiate/pull/72
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #168 on: February 14, 2012, 09:09:42 am »
0

Trader onGain doesn't work?

I discovered this issue yesterday as well.  We were probably both looking at the same thread in the General section.  I fixed it and have a pull request open: https://github.com/rspeer/dominiate/pull/72

Code: [Select]
+  isReaction: true
lol, and me was looking through the chooseByPriorityAndValue: (state, choices, priorityfunc, valuefunc)...
Logged

ecq

  • Conspirator
  • ****
  • Offline Offline
  • Posts: 224
  • Respect: +162
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #169 on: February 14, 2012, 11:24:25 am »
0

heh, it was a simple fix, but I went on a wild goose chase tracking it down
Logged

blueblimp

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2849
  • Respect: +1559
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #170 on: March 01, 2012, 05:42:27 pm »
0

Should the game logs be cleared when I hit the reset button? It doesn't seem to do so when I try. I'm using Chrome. (I can look more deeply if you want, but I'm curious what the intended functionality here is.)

Also, I'm trying to force my bot to only use Ironworks to gain Great Halls and not buy them directly, using the rule '"Great Hall" if my.phase isnt "buy"'. It seems to ignore the if though and just go ahead and buy Great Halls anytime. Is this supposed to work? Is there a better way? (Edit: Seems that the solution is to use state.phase rather than my.phase.)
« Last Edit: March 01, 2012, 06:06:07 pm by blueblimp »
Logged

blueblimp

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2849
  • Respect: +1559
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #171 on: March 01, 2012, 06:30:51 pm »
+1

I'm not sure whether this is a bug, but it is awkward to prevent bots from trashing coppers aggressively with Chapel. Even if copper is not in the trashPriority list, it will still get trashed. I think this is a bug because there are included bots that try to avoid trashing coppers in some situations, such as the ChapelWitch bot, but it won't work.

I believe this is because copper receives a trash value of 0 because it is worth zero vp and costs zero. In the function chooseByPriorityAndValue, since bestValue is initialized to -Infinity and the value of the null choice is zero and the null choice is at the end of the choice list, this means copper will be chosen to be trashed.

I've attached a simple example bot that tries to entirely avoid trashing coppers so that you can see this behaviour in action.

Code: [Select]
# Try to use Chapel to trash ONLY estates, never coppers.
{
  name: 'ChapelEstatesOnly'
  requires: ['Chapel']

  gainPriority: (state, my) -> [
    "Province"
    "Gold"
    "Chapel" if my.countInDeck("Chapel") == 0
    "Silver"
  ]

  trashPriority: (state, my) -> [
    "Estate"
  ]
}

Setting all trash values to -1 blocks copper trashing:

Code: [Select]

# Try to use Chapel to trash ONLY estates, never coppers.
{
  name: 'ChapelEstatesOnlyFixed'
  requires: ['Chapel']

  gainPriority: (state, my) -> [
    "Province"
    "Gold"
    "Chapel" if my.countInDeck("Chapel") == 0
    "Silver"
  ]

  trashPriority: (state, my) -> [
    "Estate"
  ]

  # Need this for it to work!
  # This blocks all trashing we don't authorize by priority.
  trashValue: (state, card, my) ->
    -1
}
« Last Edit: March 01, 2012, 06:34:51 pm by blueblimp »
Logged

ecq

  • Conspirator
  • ****
  • Offline Offline
  • Posts: 224
  • Respect: +162
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #172 on: March 05, 2012, 12:03:08 pm »
+2

I've been considering how to test the simulators and had kind of a neat idea this weekend.  We could grab a couple of days worth of Isotropic logs, reject games with unimplemented cards and/or Masquerade, and exercise the code using the remaining game logs.  We'd parse the logs, feed hands and decisions from the game through the simulator, and ensure that everything made sense.

Obviously this is imperfect because Isotropic doesn't tell you precisely what was drawn or discarded, but it could serve as baseline sanity checks for the game and card implementations, making sure we're counting money, buys, actions, and VP correctly.

I think it'd be hard to implement, but maybe not as hard as writing the equivalent set of tests manually, and probably less error-prone.  Obviously we'd still need tests for AI decisions, strange edge cases, and things that aren't available from scanning logs.

I'm betting Geronimoo's simulator could benefit from this idea as well, but I know Dominiate is actively looking for tests.
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #173 on: April 10, 2012, 12:19:43 pm »
0

Anybody any idea why this
Code: [Select]
{
  name: 'IGG'
  author: 'DStu'
  requires: ["Ill-Gotten Gains"]
  gainPriority: (state, my) -> [
    "Province"
    "Ill-Gotten Gains"
    "Duchy"
    "Estate" if state.gainsToEndGame() <= 2
    "Gold"
    "Silver"
  ]
 
  gainCopperPriority: (state, my) ->
    if my.coinGainMargin(state) <= my.countInHand("Ill-Gotten Gains")
      [yes]
    else
      [no]
}
is rejected from the simulator? It always resets to DoubleJack when I hit the simulate-button. Obviously it doesn't like my.coinGainMargin, but I don't understand why...
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #174 on: April 10, 2012, 03:29:23 pm »
0

Ok, got it, coinGainMargin does not belong to the gamestate, but to the AI. so it's
Code: [Select]
gainCopperPriority: (state, my) ->
    if my.ai.coinGainMargin(state) <= my.countInHand("Ill-Gotten Gains")
      [yes]
    else
      [no]

Committed this version as improvement, the old one does not even support the rush against BigMoney, see http://dominionstrategy.com/2012/02/06/hinterlands-ill-gotten-gains/#comment-14370
Logged
Pages: 1 ... 5 6 [7] 8 9 ... 13  All
 

Page created in 0.847 seconds with 22 queries.