Dominion Strategy Forum

Please login or register.

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

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

0 Members and 3 Guests are viewing this topic.

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #75 on: September 25, 2011, 12:22:26 pm »
0

And I think I got the Outpost. It does work when:

played in normal turn -> extra turn with 3 cards
played in extra turn -> draw 3 cards, no extra turn

any more weird edge cases I have forgotten?

Logged

Davio

  • 2012 Dutch Champion
  • *
  • Offline Offline
  • Posts: 4787
  • Respect: +3412
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #76 on: September 25, 2011, 01:04:27 pm »
0

Maybe some funkiness with Possession?
But with Possession you play your opponent's turn, not your own, so it doesn't count towards your # of turns.

Do all Duration cards work with the extra turn?
Logged

BSG: Cagprezimal Adama
Mage Knight: Arythea

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #77 on: September 25, 2011, 01:30:21 pm »
0

Maybe some funkiness with Possession?
But with Possession you play your opponent's turn, not your own, so it doesn't count towards your # of turns.

Do all Duration cards work with the extra turn?

Possession is not implemented, so I think we shouldn't care for it for the moment. But that's the card I also had in mind. KC/TR perhaps also must taken care of...
 
Have just tested on Fishing Village until now, but the "extra turn" from the point of view of the programm is just a "normal turn", where we skip the rotation of the player and that get's another intro (don't count turns, different headline). Maybe I should take a look on Tactician, while I don't see what should be different there I'm a lit suspicious.
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #78 on: September 25, 2011, 01:39:39 pm »
0

Oh, found a small bug, it drew 3 cards in cleanup all the time. Would swear that it didn't do it a few hours ago. Anyway, is fixed,.
Logged

michaeljb

  • Saboteur
  • *****
  • Offline Offline
  • Posts: 1422
  • Shuffle iT Username: michaeljb
  • Respect: +2113
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #79 on: September 25, 2011, 02:20:40 pm »
0

Oh, found a small bug, it drew 3 cards in cleanup all the time. Would swear that it didn't do it a few hours ago. Anyway, is fixed,.

Isn't that what Outpost is supposed to do, even if it doesn't get you another extra turn?

Quote from: Outpost
You only draw 3 cards (instead of 5) in this turn's Clean-up phase. Take an extra turn after this one. This can't cause you to take more than two consecutive turns.
Logged
🚂 Give 18xx games a chance 🚂

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #80 on: September 25, 2011, 02:28:04 pm »
0

Oh, found a small bug, it drew 3 cards in cleanup all the time. Would swear that it didn't do it a few hours ago. Anyway, is fixed,.

Isn't that what Outpost is supposed to do, even if it doesn't get you another extra turn?

Quote from: Outpost
You only draw 3 cards (instead of 5) in this turn's Clean-up phase. Take an extra turn after this one. This can't cause you to take more than two consecutive turns.

Yeah, that's what Outpost is supposed to do. But my implementation drew 3 cards no matter what, even if you didn't played (or even bought) an Outpost.
Logged

michaeljb

  • Saboteur
  • *****
  • Offline Offline
  • Posts: 1422
  • Shuffle iT Username: michaeljb
  • Respect: +2113
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #81 on: September 25, 2011, 03:07:58 pm »
0

Oh, ok that makes sense. Should have figured I misunderstood it  ::)
Logged
🚂 Give 18xx games a chance 🚂

rspeer

  • Witch
  • *****
  • Offline Offline
  • Posts: 469
  • Respect: +877
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #82 on: September 25, 2011, 03:10:38 pm »
0

One Coffeescript question:

The actionPriority is implemented by a function that returns an array, if I interpret
Code: [Select]
actionPriority: (state,my) -> [
...
]
correctly? On the other hand, when I follow what happens with the returnvalue of this function, it seems to be a single element...

That's indeed a function that returns an array. Generally I assign the result to something called "priority" and iterate over it with a for...in loop. For example, in chooseByPriorityAndValue:

Code: [Select]
      # Get the priority list.
      priority = priorityfunc(state, my)

      # Now look up all the preferences in that list. The moment we encounter
      # a valid choice, we can return it.
      for preference in priority
        # see if we can make this choice, etc.

Anyway, time to go look at the incoming code on GitHub! Thanks guys!
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #83 on: September 25, 2011, 03:23:33 pm »
0


That's indeed a function that returns an array. Generally I assign the result to something called "priority" and iterate over it with a for...in loop. For example, in chooseByPriorityAndValue:

Thanks, that's good news. Then I'll try to improve the heuristics for putting cards back to deck. Heuristics will be
Code: [Select]
# 1) Put the best action you can't use back on deck
 
  # 2) Put the best treasure you don't need back on deck
 
  # 3) Put the worst card back on deck
Any complains?
« Last Edit: September 25, 2011, 03:27:23 pm by DStu »
Logged

rspeer

  • Witch
  • *****
  • Offline Offline
  • Posts: 469
  • Respect: +877
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #84 on: September 25, 2011, 04:18:16 pm »
0

Sounds great.

I suppose "treasure you don't need" will be calculated by seeing if you would buy something different without that treasure? I believe that's how Geronimoo does it and it would make sense to me. Although that'll require a change to SillyAI, which will buy something different because whee random.
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #85 on: September 25, 2011, 06:20:17 pm »
0

ARRRGGH

Anybody any idea why I might get a
Code: [Select]
TypeError: Cannot read property 'Shanty Town' of undefined
on
Code: [Select]
putOnDeckPriority: (state,my) ->
    # 1) Put the best action you can't use back on deck
    putBackActions = []
    putBackActions = card for card in my.ai.actionPriority(state,my) when ( (card?) and (state.c[card].getActions() == 0) and (card in my.hand))
I strongly suspect (by experiment) that it is the "state.c[card].getActions() == 0", where card="Shanty Town". But that would mean that state.c would be undefined. state is not undefined, as state.log works two lines later...

putOnDeckPriority gets called by the generic  chooseByPriorityAndValue, so I can't believe that there is a wrong parameter for state or something.
Logged

rspeer

  • Witch
  • *****
  • Offline Offline
  • Posts: 469
  • Respect: +877
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #86 on: September 25, 2011, 06:26:39 pm »
0

Try "state.cardInfo", which should be the same object as "c" is in cards.coffee. "state.c" actually is undefined.

I wrote it as "state.c" once in the documentation, but I thought I had fixed it by now.
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #87 on: September 25, 2011, 07:07:16 pm »
0

ah thanks.  Got rid of this error now, but still a long way I'm afraid.
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #88 on: September 26, 2011, 05:17:36 am »
0

ah thanks.  Got rid of this error now, but still a long way I'm afraid.

So got 1a) running afte splitting it up another time
Code: [Select]
    #1a) If no actions left, put back best Action

    #1b) If not enough actions left, put back best Terminal you can't play
b) shoud be easy now, but have to work. But I'm not sure if that's really what one want, as on top of the top of the actionPriorityList usually are Cantrips>Terminals, so one would put back an unplayable Village over an unplayable Mountebank.
On the other hands one of course can't just rate Terminals>Cantrips, cause that would put back an unplayable Woodcutter over Grand Market...

perhaps we really need another list for this...
Logged

rspeer

  • Witch
  • *****
  • Offline Offline
  • Posts: 469
  • Respect: +877
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #89 on: September 26, 2011, 11:18:24 am »
0

Hmm. I don't think I'd want to set up a separate mailing list or anything -- this would make it harder for others to start working on the simulator. This forum is a good place for development discussion, I'd say, because it contains the majority of the people who would use this code.

But the other option for specific discussion about the code would be using GitHub's messaging interface. I'm also setting up the wiki, at https://github.com/rspeer/dominiate/wiki, as a place for more documentation and for development plans.

I just added code that will predict (pessimistically) how much money the player will have at the end of the turn, and what it intends to buy with that money, which can help in deciding when to put back treasure.

It's not so bad to prioritize putting back a Village when there are no actions left. If the simulator is running into a situation with too many terminals this turn, it may run into the same situation next turn, in which case the village will help. Of course there are many situations where this will be a suboptimal decision, but it seems a quite reasonable way to make the decision in the short time the simulator is supposed to spend per turn.
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #90 on: September 26, 2011, 11:22:54 am »
0

Hmm. I don't think I'd want to set up a separate mailing list or anything -- this would make it harder for others to start working on the simulator. This forum is a good place for development discussion, I'd say, because it contains the majority of the people who would use this code.
I was talking about another priorityList for which Action to put back on the deck. Actually like the forums here for discussion.

Quote
It's not so bad to prioritize putting back a Village when there are no actions left. If the simulator is running into a situation with too many terminals this turn, it may run into the same situation next turn, in which case the village will help. Of course there are many situations where this will be a suboptimal decision, but it seems a quite reasonable way to make the decision in the short time the simulator is supposed to spend per turn.
OK, I think I will keep it the way, one can always optimize later...
Logged

Davio

  • 2012 Dutch Champion
  • *
  • Offline Offline
  • Posts: 4787
  • Respect: +3412
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #91 on: September 26, 2011, 01:14:50 pm »
0

I'd rather see a shortlist with the most critical actions and just derive the rest from the standard list.

This shortlist would contain Cursers while Curses last.

Maybe it can be a 3-pronged assault.
1. Pick a Curser from the shortlist if there are Curses left
2. Pick any other Attack (obviously suboptimal, because there are a lot of not so bad attacks)
3. Pick the highest card from the normal list
Logged

BSG: Cagprezimal Adama
Mage Knight: Arythea

DG

  • Governor
  • *****
  • Offline Offline
  • Posts: 4074
  • Respect: +2624
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #92 on: September 26, 2011, 03:08:08 pm »
0

In my humble opinion, the Geronimo simulator is at a stage where its next main improvement would be the customization of card play rules within a simulation. he simulator already models card purchases very well and Geronimo is left to improve the heuristics, which will be an increasingly difficult and endless task. Moreover, any added complexity in the heuristics will make it more difficult for users to eventually change behaviours through simple parameter changes.

Is there any conceptual planning for this simulator as to how users could eventually alter the card play? Is this being considered in the current design?
Logged

rspeer

  • Witch
  • *****
  • Offline Offline
  • Posts: 469
  • Respect: +877
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #93 on: September 26, 2011, 03:13:48 pm »
0

You can alter the card play.

Any of the methods on basicAI, such as actionPriority, discardPriority, or putOnDeckValue, can be overridden by a specific AI. It just happens that the one people are usually interested in overriding is gainPriority.

For one example, look at TournamentPlayer, which changes the discardPriority to avoid discarding Provinces when it has a Tournament.
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #94 on: September 26, 2011, 06:28:18 pm »
0

So, I think I've got it.

Found another bug in the PutOnDeck() I wrote, obviously it did not put it on the deck but under it or wherever. Found the transferCardToTop(), but don't like that it doesn't say something. However, here's my putOnDeckPriority

Code: [Select]
putOnDeckPriority: (state, my) ->
    # 1) If no actions left, put back best Action
    #    Take card from hand which are actions, sort them by ActionPriority
    #
     
    # 2) If not enough actions left, put back best Terminal you can't play
    #    Take cards from hand which are Actions and Terminals, sort them by ActionPriority
    #    Then, ignore as many terminals as you can play this turn, return the others
    #
     
    # 3) Put back as much money as you can
    #    First get a pessimistic estimate of the avaiable money this turn
    #    then find take the cost in coins of the highest priority card you can afford
    #    then put the treasures which are not needed in 'putBack' for discardPriority, most valuable first, Potion = 2.5 Coins
    #
      # Don't put last Potion back if Alchemists are in play
      #

    # 4) Put back the worst card (take priority for discard)
    #

There is a lot sorting and estimating hardcoded in the function now, maybe one wants to subroutine them for reuse.
AND the whole mess will only work when you want to put back exactly 1 card, and also if you only have one buy. Have to think again how to handle GhostShip...
Logged

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #95 on: September 27, 2011, 08:37:48 pm »
0

So, fixed some of the bugs I placed yesterday, as well as coded Haven. And found a bug with Potions, they where counted twice.
Logged

michaeljb

  • Saboteur
  • *****
  • Offline Offline
  • Posts: 1422
  • Shuffle iT Username: michaeljb
  • Respect: +2113
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #96 on: September 27, 2011, 11:16:41 pm »
0

I have Pirate Ship all done, except for pirateShipPriority. I have a really basic version of it done, but I think Geronimoo's method is pretty good--I'm just not quite sure how to see if playing for coins will enable the player to buy a card higher on the gainPriority list, rather than just seeing what state.current.coins will be with the Ship's value.
Logged
🚂 Give 18xx games a chance 🚂

rspeer

  • Witch
  • *****
  • Offline Offline
  • Posts: 469
  • Respect: +877
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #97 on: September 28, 2011, 12:25:47 am »
0

So, fixed some of the bugs I placed yesterday, as well as coded Haven. And found a bug with Potions, they where counted twice.

It's up. And after I pointed out your copying bug, I found three more of my own, at which point I finally wrote a much simpler cloneDominionObject function that works on States and PlayerStates.

It's so much easier to say what not to copy than to list every single object that needs a new copy made of it.
Logged

rspeer

  • Witch
  • *****
  • Offline Offline
  • Posts: 469
  • Respect: +877
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #98 on: September 28, 2011, 12:36:45 am »
0

I have Pirate Ship all done, except for pirateShipPriority. I have a really basic version of it done, but I think Geronimoo's method is pretty good--I'm just not quite sure how to see if playing for coins will enable the player to buy a card higher on the gainPriority list, rather than just seeing what state.current.coins will be with the Ship's value.

This is what the hypothetical-situation code can be used for.

You'll want to do something almost like pessimisticCardsGained, an AI method that thinks ahead to the buy phase, assuming it won't draw any more money, and lists the cards it will gain then.

Code: [Select]
  pessimisticCardsGained: (state) ->
    newState = this.pessimisticBuyPhase(state)
    newState.doPlay()
    return newState.current.gainedThisTurn

But you'll want to get the pessimisticBuyPhase twice, and see what happens when you give it more money the second time. So, if I may write totally untested code to accomplish this on the forum, I think it would be something like this:

Code: [Select]
  effectOfMoneyChange: (state, moneyChange) ->
    state1 = this.pessimisticBuyPhase(state)
    state2 = state1.copy()
    state1.doPlay()
    gains1 = state1.current.gainedThisTurn
    state2.current.coins += moneyChange
    state2.doPlay()
    gains2 = state2.current.gainedThisTurn
    return (gains1.toString() != gains2.toString())

This could even take a negative money change for evaluating Remodel, Salvager, etc.

Maybe it should just compare the card costs instead of the actual cards, so that it doesn't break with SillyAI.
Logged

michaeljb

  • Saboteur
  • *****
  • Offline Offline
  • Posts: 1422
  • Shuffle iT Username: michaeljb
  • Respect: +2113
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #99 on: September 28, 2011, 12:40:59 am »
0

Thief and Pirate Ship both are done now. Both will trash the opponent's most expensive treasure, using trashOppTreasureValue for the decision (right now it just uses the cost), and Thief will gain the treasure if the bot wants to gain it.

pirateShipPriority is pretty lame right now, but I don't how to best write the heuristic for when to use it. Right now it will use the coins if there are 5 or more, and using them will result in state.current.coins >= 8, otherwise it attacks. I'm not sure how to see if it will be able to afford a card in gainPriority with a higher spot than Pirate Ship (like Geronimoo's).

So the basic functionality of Pirate Ship is done, but the AI part needs work. I'm beginning to think the best way to write a particular bot with these complex decision cards is probably going to involve manually overwriting the relevant card Priority functions and the actionPriority function.
Logged
🚂 Give 18xx games a chance 🚂
Pages: 1 2 3 [4] 5 6 ... 13  All
 

Page created in 0.25 seconds with 21 queries.