Dominion Strategy Forum

Please login or register.

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

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

0 Members and 1 Guest are viewing this topic.

Davio

  • 2012 Dutch Champion
  • *
  • Offline Offline
  • Posts: 4787
  • Respect: +3412
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #100 on: September 28, 2011, 03:13:33 am »
0

How does Pirate Ship work with Reactions?

On Isotropic Reaction cards are revealed after the attack card is played and before a choice is made.
This is key for Pirate Ship, because if you can't steal, you want the $$$ obviously.
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 #101 on: September 28, 2011, 03:17:25 am »
0

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

So when I get this right, this could also be used in my PutOnDeckPriority to find out how much money the bot would like to spend, saving me a ton of "for  in  where ( and and and and)" and handeling multiple buys.

The only question is if that is really what one wants, because with 2 buys and $11 he would buy Province/Silver instead of Province, putting Gold back, which would be the better move in endgame. But probably thats also a situation that the gainPriority must account for when playing with multiple buys anyway, so maybe we can just shift the problem to that point. Negative point for this is that gainPriority is probably the function most often change by users, so we maybe don't want such unexpected side-effects.

PS: @array: So just if it where C. Think I can rememer that.
Logged

rspeer

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

Thief, Haven, and Pirate Ship are in. But this putOnDeckPriority code is really confusing and hard to read. Can I ask nicely for some line breaks and intermediate variables?

Object identities are confusing! There was some new bug with copied AIs that I still can't figure out, and it would show up every time someone played a Bureaucrat; the hypothetical opponent being asked to discard wasn't in the game somehow.

It bothers me, but I'm going to have to have AIs hypothesize about how their opponents play hypothetical situations using the actual opponent AIs for now. (That's kind of cheating, and it doesn't work if in some future time the opponent is a human...)
Logged

DStu

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

Thief, Haven, and Pirate Ship are in. But this putOnDeckPriority code is really confusing and hard to read. Can I ask nicely for some line breaks and intermediate variables?
Think I will rewrite it (maybe this evening) with the hypothetical ai mentioned.

Can also split it up a bit, in the beginning I thought I could not afford intermediate variables because they would mess with the list I return, but maybe I also don't really understand the language yet. The way it is done now definitely allows for more variables.

The other thing that I think is not nice to read is the sorting of the treasures. So either I introduce a subfunction there, or maybe just sort them my price. Is perhaps not the worst idea.

Linebreaks I can do anywhere I want by just ending the line with a  \   ?

Edit: I realize that anyway I need to think more about the Priority of putting back Quarry, Talisman, Royal Seal, maybe Stash and some fancy treasures I might have forgotten.
« Last Edit: September 28, 2011, 05:55:23 am by DStu »
Logged

Davio

  • 2012 Dutch Champion
  • *
  • Offline Offline
  • Posts: 4787
  • Respect: +3412
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #104 on: September 28, 2011, 06:32:50 am »
0

Harem is a fancy treasure, especially for Thief.
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 #105 on: September 28, 2011, 09:27:06 am »
0

So I think I will reevaluate the putting back of treasures
Code: [Select]
# A) Look what you would gain if you just put back as if you discard (that is the fallback if everything we try now fails)

# B) For each unique treasure, test if the gain changes if we just put this treasure back

# C) Extraconditions like Potions for Alchemist, Royal Seal which have effects other than gaining

# D) Put the "best" treasure back that does not change the gain or was excluded in C).
This should also be able to handle Quarry, Talisman, HoP.

Now we just have to evaluate what "best" means, first idea would just be by price. What I don't like there
Code: [Select]
Harem > HoP, Royal Seal
Harem, Royal Seal, Stash > Quarry, Talisman, Potion
Diadem < all
Harem should be more or less rated like silver, perhaps an epsilon higher to defend against attacks. But that's only a small chance in the turn just before the reshuffle, which can more or less be ignored. But when you bought HoP, a reasonable AI should want to gain something with it in the end, so it should be more valuable than silver and thus as Harem.
Same should be true for Royal Seal, Stash vs. Quarry, Talisman, Potion while here maybe in the endgame it is shifted again in Royal Seals favour.
Second idea would be a new function treasurePriority2(state) (which exists, but for other means), which has just a defaultList (without much thought and probably forgotten something)
Code: [Select]
Bank>Platinum>Gold>HoP>Quarry>Talisman>Potion>Diadem>Royal Seal>Stash>Harem>Silver>Copper
and which of course could be costumized then if someone wants something more fancy.  Most of the inequalities are not so important anyway, you seldomly want to play say Talisman and Potion in the same strat.
Royal Seal then also needs some extra considerration if we want to put it back at all , but that is a different point similar to "do not put back Potions when Alchemists are in play".

Edit: Contraband I forgot. And Hoard. Hoard should work with this, Contraband is difficult anyway.
« Last Edit: September 28, 2011, 09:29:39 am by DStu »
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 #106 on: September 28, 2011, 01:11:20 pm »
0

How does Pirate Ship work with Reactions?

On Isotropic Reaction cards are revealed after the attack card is played and before a choice is made.
This is key for Pirate Ship, because if you can't steal, you want the $$$ obviously.

Hadn't thought of that. Right now it probably just makes the same choice either way.

For 2p it would be a simple enough task, but I'm wondering about how best to do it for multiplayer--if all but one are protected, do I still want to attack? Should I consider the opponent's deck's treasure density and calculate the chance of a successful attack?

I think this code would cause the player to choose coins if any opponent reveals Moat (or has a Lighthouse), so it would should be fine for 2p but probably not best for multiplayer.

Code: [Select]
pirateShipPriority: (state, my) -> [
  'coins' if opp.moatProtected for opp in players[1...]
  .
  .
  .
]

Of course, a check for Secret Chamber should probably be made as well, but it seems like that would have to be a bit more complicated...
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 #107 on: September 28, 2011, 02:10:23 pm »
0

Found a bug with the output, and don't really now how to resolve it:

When going into hypothetical scenarios, the log-functions of GameState test for the depth of the hypotheticalliness and only outputs if we are in "the real world". But there also is a log-function of Playerstate, which is called by the basic drawCards, discardFromDeck etc. functions of playerstate, and which does not test on "real world". And I think it can't, because the player state does not know if the depth.

Tried to introduce @depth also in class PlayerState, but didn't succeed.
Logged

rspeer

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

The hack I was doing to resolve this was to have state.hypothetical simply replace the log functions of its PlayerStates with no-ops when it created them.

It's possible that introducing cloneDominionObject broke this somehow.
Logged

DStu

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

Is it possible that there are more things messed up with the copying? While testing my new code for putBackPriority, it seems like the hypothetical versions of the AIs lose some cards when discarding. I have the following:

Bot:
Code: [Select]
gainPriority: (state, my) -> [
    "Potion" if my.countInDeck("Potion") < 2
    "Alchemist" if my.countInDeck("Alchemist") < 4
    "Village" if my.countInDeck("Village") < 3
    "Courtyard" if my.countInDeck("Courtyard") < 3
    "Silver"
We play a Courtyard and think about what to put back, the hand contains 6 Coppers, 2 Potions and some Estates:
Code: [Select]
for card in treasures
        [hypState, hypMy] = state.hypothetical(my.ai)
        hypMy.doDiscard(card)
        nowGained = hypMy.ai.pessimisticCardsGained(hypState)
When putting back Copper, it says it would gain a Village. Which sounds reasonable.
When putting back Potion, it says it would gain a Potion(!), Which sounds not reasonable at all, since we've already got 2 Potions. So it seems like the doDiscard somehow loses the Potion, at least in the hypothetical world.

Or I'm using the hypothetical( ) wrong.

Edit: Furthermore I get something like: I have a hypothetical hand of Estates and 3 Coppers (shown by state.log("#{hypMy.hand}"), and it says it would buy a Quarry with it.

Edit2: Complete code is on Github in case you need it.
« Last Edit: September 28, 2011, 06:05:34 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 #110 on: September 28, 2011, 09:08:43 pm »
0

I think the theme of today is "cloneDominionObject screwed up everything".

I backed it out; the big, huge functions that explicitly copy States and PlayerStates are back instead. I wish I had test cases.
Logged

DStu

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

I think the theme of today is "cloneDominionObject screwed up everything".

I backed it out; the big, huge functions that explicitly copy States and PlayerStates are back instead. I wish I had test cases.

Actually found out that the problems with hypothetical discarding didn't come from the copying, but was in the code of pessimisticBuyPhase. You just deleted the draw and the discard there to be pessimistic, so that the deck was not correct anymore when the ai enters the hypothetical buy phase.
Made a backup of them and restore them just before entering the buyphase.
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 #112 on: October 01, 2011, 12:04:56 am »
0

This isn't really anything important, but I was thinking of a couple more ways cards.coffee could be divided--right now it's organized into basic cards, vanilla cards, duration cards, trash for improvement, and all the rest. I was thinking it would also be nice to have separate categories for the Victory and Treasure cards, and maybe Attacks as well. It'd be an easy enough thing for me to do on my own, but if there's some reason this would be a bad idea I wouldn't do it.
Logged
🚂 Give 18xx games a chance 🚂

Davio

  • 2012 Dutch Champion
  • *
  • Offline Offline
  • Posts: 4787
  • Respect: +3412
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #113 on: October 03, 2011, 10:55:26 am »
0

It's not that it's a bad idea, it's just that there are 100+ cards and no one cares enough to remodel the file.
Logged

BSG: Cagprezimal Adama
Mage Knight: Arythea

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 #114 on: October 06, 2011, 11:23:00 pm »
0

...no one cares enough to remodel the file.

Evidently I do :P I have trashed it and replaced it with a file costing $2 more. Or something. At least, I changed it so Treasures and Attacks were separated and given their own categories and prototypes.

Fairgrounds is back in (or there for the first time?), I fixed few other minor things (Trade Route wasn't trashing a card, Bureaucrat not gaining a Silver), and implemented Loan, Talisman, and Fortune Teller.

I also added a dig function. Looks like Golem and Scrying Pool are the only cards left to code that would use it, but there are a few more cards that are done which could be rewritten to incorporate it: Adventurer, Farming Village, and Hunting Party.
« Last Edit: October 06, 2011, 11:32:38 pm by michaeljb »
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 #115 on: October 10, 2011, 12:30:53 am »
0

Cool. By the way, sorry that I'm not very active on this project around now: I have a huge project that I have to release this week.
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 #116 on: October 10, 2011, 05:57:23 pm »
0

Totally understandable. I've been having fun contributing but I should probably be focusing more on schoolwork :P (college senior, math major)
Logged
🚂 Give 18xx games a chance 🚂

ivadla

  • Pawn
  • **
  • Offline Offline
  • Posts: 1
  • Respect: 0
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #117 on: October 12, 2011, 06:02:53 pm »
0

Is it just me or is dominiate very slow compared to Geronimoo's simulator? On my computer dominiate takes 195 seconds to simulate 1000 games between BigMoney and BigSmithy. Geronimoo's simulator only needs 1.6 seconds and jdominion 20 seconds.
I ran this on an old 1.5 Ghz Pentium-M with Firefox 7 and Java 1.6.0.26

Is it possible to optimize Dominiate? Or does it run faster with node.js or another js-engine?
With the current speed it seems very difficult to really optimize strategies.
Logged

rrenaud

  • Administrator
  • *****
  • Offline Offline
  • Posts: 991
  • Uncivilized Barbarian of Statistics
  • Respect: +1197
    • View Profile
    • CouncilRoom
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #118 on: October 12, 2011, 06:16:43 pm »
0

Chrome seems to be about 3x faster than firefox when I count in my head.

Firefox takes about 30 seconds for 100 games, chrome about 10.
Logged

danshep

  • Navigator
  • ****
  • Offline Offline
  • Posts: 70
  • Respect: +15
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #119 on: October 12, 2011, 06:35:33 pm »
0

I keep meaning to dive into the code and try this myself, but have you tried making a null logging device so that when playing games in bulk it doesn't add all that extra DOM manipulation that the game logs require?
Logged

rspeer

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

That makes a lot of sense, and there are probably also still things that can be optimized.

Running the Chrome profiler identifies three major hotspots, when running on simple strategies (Chapel/Mountebank vs. Bank/Wharf)
  • (program) -- 33.4%
  • BasicAI.chooseByPriorityAndValue -- 24.8% total, 15.5% in the function itself
  • state.doBuyPhase -- 16.7% total, 5.9% in the function itself

I'm curious about the implications of (program) being so high -- that's the browser's JS environment itself. Maybe the only way to improve that is to keep updating Chrome, or maybe it's an indirect effect of something actually caused by this code (perhaps all the DOM updates we're doing? A no-logging mode is a good idea.)

But then chooseByPriorityAndValue is also a clear thing to improve. This calls some code that makes actual difficult decisions, but it's interesting that it spends so much time in that function itself when it's mostly just looking up values and comparing numbers. Are we calling it too many times? Are we calling it with too many options that we should be pruning?

I intend to get back to this code soon, maybe later tonight, and I'll take a shot at optimization.
Logged

rspeer

  • Witch
  • *****
  • Offline Offline
  • Posts: 469
  • Respect: +877
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #121 on: October 15, 2011, 04:04:54 am »
0

All right, Fast Mode is in. In Fast Mode, there are many fewer DOM updates, you don't get any gameplay logs, and it returns control to the browser much less often.

It runs about twice as fast as before in Chrome (apparently DOM updates are pretty damn fast in Chrome, which is why it hadn't bothered me much), and in Firefox it runs considerably faster, about as fast as Chrome does in slow mode now.

It's possible that we should default to a mode that has some of the features of fast mode, except you get at least one gameplay log.

I was going to implement some new cards, but now I've changed my plans; I'm going to go on Isotropic and buy as many Crossroads as I possibly can.
Logged

rspeer

  • Witch
  • *****
  • Offline Offline
  • Posts: 469
  • Respect: +877
    • View Profile
Re: Dominiate: a Dominion simulator that runs on the Web
« Reply #122 on: October 17, 2011, 05:15:43 am »
0

I've started implementing some Hinterlands cards, and also fixing bugs. Mandarin, Nomad Camp, Crossroads, and Border Village are in.

It's no test suite, but I made a command-line tester to play SillyAI against itself for 1000 games. It's now run several times without crashing. I think the Watchtower bug (currently the only actual bug on the GitHub queue) might have even been fixed by some other change.
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 #123 on: October 19, 2011, 01:54:40 pm »
0

I've coded Golem, Farmland, Silk Road, and Tunnel. I still need to implement Tunnel's reaction, and then I'll request a pull. I'll probably do Pearl Diver too, to finish off the "easy" card list.
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 #124 on: November 03, 2011, 08:40:48 am »
0

When I want to use the webinterface (say http://rspeer.github.com/dominiate/play.html#DoubleJack/DoubleMilitia), I get an error message:
Code: [Select]
can't convert undefined to object
on Firefox 7.0.1
and
Code: [Select]
Array.prototype.indexOf called on null or undefined
on Chrome/Chromium 15.0.874.106

The game log stops at
Code: [Select]
(DoubleMilitia shuffles.)
DoubleMilitia draws 5 cards: [Copper, Copper, Copper, Copper, Copper].
(DoubleJack shuffles.)
DoubleJack draws 5 cards: [Estate, Copper, Estate, Copper, Copper].
Tableau: [Jack of All Trades, Militia, Vault, Ambassador, Noble Brigand, Bureaucrat, Sea Hag, Philosopher's Stone, Wharf, Trading Post, Potion]

== DoubleMilitia's turn 1 ==
Logged
Pages: 1 ... 3 4 [5] 6 7 ... 13  All
 

Page created in 0.051 seconds with 21 queries.