Dominion Strategy Forum

Please login or register.

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

Author Topic: Interest in a Dominion replay system?  (Read 7406 times)

0 Members and 1 Guest are viewing this topic.

Titandrake

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2210
  • Respect: +2856
    • View Profile
Interest in a Dominion replay system?
« on: December 23, 2014, 02:49:26 am »
+12

So I'm on break right now, and there's a Dominion-related project that I've wanted which doesn't exist yet.

Basically, when I was writing an article (I think it was Leveraging Information), I realized that the log prettifier is really helpful in comparing decks between turns, but not for seeing choices made in the middle of the turn. With a little work, you can figure out what order people played actions in, but without keeping track yourself, it's hard to, say, find out what actions a player didn't play because it would cause a reshuffle. For engine games, this is especially bad - there's no way I'm going to go through a page worth of text to figure out exactly how much buying power the player had that turn, even though that's one of the most important things to know. In short, right now it's easy to understand the macro strategy of what cards people buy and when, and it's much harder to understand the micro strategy of how people actually play their decks.

However, in game log, we have a record of every action made. Therefore, from that log, we should be able to rebuild the game state at any point, even in the middle of the game, and then you can learn whatever you want to learn. I remember mentioning this to AI one time, and he said he tried to get something similar working in Goko, but he couldn't.

If people think this is worth the time, I can start looking into it, but I'd probably need help. My Javascript is like a solid 1/10, and there's a lot of parts. In terms of design, I'm seeing the following:

- From a log, correctly reconstruct the exact hand, board, and supply state for each player. The existing log viewer code may do parts of this, but I think you'd need to write your own parser.
-- I'm envisioning a slider that you can move back and forth to apply/unapply actions. The game state constructor must be able to both apply and unapply a line of log text to handle this. Alternatively, whenever a client moves the slider, start from the beginning, and apply each line until you reach where the client stopped. Actually, the way that gives best performance is probably going to be saving the state after every line in an array of game states on initialization, then choosing the proper game state from this array on client-move. (DP FTW)
- Reconstruct the Goko interface, or at least a decent enough interface to display all this information. Given that AI had issues doing this within Goko, this most likely will need to be written from scratch, meaning an Iso-looking bare-bones interface is most likely. Frontend people can help here.
-- At a given game state, list what cards are in each players deck. Ideally, display what cards are in discard, in draw, in play, and in hand, all separately, since deck tracking is important to explain things like Wishing Well decisions. Figuring out how to lay this all out is tough.
-- This interface is going to need the ability to switch between player perspectives. Well, maybe not, there might be enough space to have full information displayed. This is up for debate.
-- Same issue as the backend code - rebuilding all DOM elements for each game state is easier to code, but worse performance. Updating the elements dynamically is better performance but trickier to write.
- Get general networking going, so that people can actually use this.

This feels like a lot of parts to me, but it probably isn't actually that bad. It certainly feels like less pieces than the extension itself, and there's no dealing with Goko's code since this is presumably made from scratch.

If people are interested in helping out with this (or have comments in general), let me know. If people think this wouldn't actually be that useful to have, also let me know.
Logged
I have a blog! It's called Sorta Insightful. Check it out?

Burning Skull

  • Saboteur
  • *****
  • Offline Offline
  • Posts: 1150
  • Shuffle iT Username: Burning Skull
  • See you in the Outpost
  • Respect: +1843
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #1 on: December 23, 2014, 07:58:11 am »
+1

That seems to be a very nice idea indeed.

There are a lot of issues here though.
You can't get almost any useful information based on logs solely. You need to program some ingame mechanics for that. For example:
You want to know one of the players buying power at some point, so imagine he played Salvager on Province, it gives him eight dollars, but what if he played a couple of Highways before that, or he played a Quarry with his Black Market?
If you want to display the variety of choices in every point of the game you'll want to program the behavior of every card that offers said choices.
Even knowing information about what's left in players deck, and what's in discard is more than just simple addition and subtraction.

So, the whole thing seems pretty ambitious to me (still possible, of course). Basically you need to implement the whole Dominion-playing engine to do that stuff.
The basic thing you can do (and I think it still going to be quite useful) is a visualiser of player's hands and piles (including trash pile). That you can do by only parsing logs.

Anyway, if you are going to do that in any quality that would be very interesting, and I also may contributre at some point if I have time and can command my ass to raise from the sofa.

P.S. Imagine you implement all this stuff. The whole thing, that shows current state in the game and really understands it. That thing could be abused pretty badly: you can feed the logs to it during your games, and it can help you with optimal choices. At least, with all the work done, that add-on won't be very difficult to implement.
« Last Edit: December 23, 2014, 08:01:16 am by Burning Skull »
Logged

Titandrake

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2210
  • Respect: +2856
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #2 on: December 24, 2014, 04:45:07 am »
0

Hm, I suppose that goes back to the Iso extension from waaaay back. The one that tracked you how many copies of a card each player had. People could probably do that now with the current log prettifier, but I'd think you need a bit of elbow grease to deal with only getting partial information from your opponent (the parser probably assumes the full information from the log)

I feel like the log parsing is to have a big initial cost to get something that works at all, then a lot of annoying edge cases, like Prince/Masq/Amb/Black Market.
Logged
I have a blog! It's called Sorta Insightful. Check it out?

qmech

  • Torturer
  • *****
  • Offline Offline
  • Posts: 1918
  • Shuffle iT Username: qmech
  • What year is it?
  • Respect: +2320
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #3 on: December 24, 2014, 05:07:19 am »
0

Yes, I've wanted this for ages.  Do it!
Logged

Joseph2302

  • Jester
  • *****
  • Offline Offline
  • Posts: 858
  • Shuffle iT Username: Joseph2302
  • "Better to be lucky than good"
  • Respect: +576
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #4 on: December 24, 2014, 05:12:24 am »
+1

Sounds like a great idea, however isn't there already some Goko-caused log problem that make the VP counter difficult?

Like plays Counterfeit, plays Copper, plays Copper, which could mean you Counterfeit a copper, or that you play counterfeit, counterfeit nothing, and then play 2 coppers.

Problems like this might make it super-difficult.
Logged
Mafia Stats: (correct as of 2017)
Town: 22 games, 8 wins
Scum: 5 games, 3 wins

Burning Skull

  • Saboteur
  • *****
  • Offline Offline
  • Posts: 1150
  • Shuffle iT Username: Burning Skull
  • See you in the Outpost
  • Respect: +1843
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #5 on: December 24, 2014, 06:49:49 am »
0

Like plays Counterfeit, plays Copper, plays Copper, which could mean you Counterfeit a copper, or that you play counterfeit, counterfeit nothing, and then play 2 coppers.

I don't see any problems here, since it's always written explicitly in the log if something was trashed.

Ozle

  • Cartographer
  • *****
  • Offline Offline
  • Posts: 3625
  • Sorry, this text is personal.
  • Respect: +3360
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #6 on: December 24, 2014, 07:45:57 am »
+2

Nah, im good thanks
Logged
Try the Ozle Google Map Challenge!
http://forum.dominionstrategy.com/index.php?topic=7466.0

Sullying players Enjoyment of Innovation since 2013 Apparently!

Drab Emordnilap

  • Torturer
  • *****
  • Offline Offline
  • Posts: 1832
  • Shuffle iT Username: Drab Emordnilap
  • Luther Bell Hendricks V
  • Respect: +1887
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #7 on: December 24, 2014, 08:23:50 am »
0

Do the logs differentiate between "Bazaar, then King's Court Bazaar" and "Bazaar, King's Court nothing, Bazaar Bazaar Bazaar"?
Logged

Joseph2302

  • Jester
  • *****
  • Offline Offline
  • Posts: 858
  • Shuffle iT Username: Joseph2302
  • "Better to be lucky than good"
  • Respect: +576
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #8 on: December 24, 2014, 09:29:04 am »
0

Do the logs differentiate between "Bazaar, then King's Court Bazaar" and "Bazaar, King's Court nothing, Bazaar Bazaar Bazaar"?

Don't think so, that was the point I was trying to make (but made badly).
Logged
Mafia Stats: (correct as of 2017)
Town: 22 games, 8 wins
Scum: 5 games, 3 wins

Titandrake

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2210
  • Respect: +2856
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #9 on: December 25, 2014, 05:25:04 am »
+1

Alright, started it at https://github.com/alexirpan/goko-replay-system/tree/parser on the parser branch. Right now it's not working for enough cases - doesn't handle trashing, doesn't know when a discard is from the hand or from somewhere else, etc. Code is in the gokoparse.py file in gdt/logparse

I think if you gave it a log for a Village-Smithy engine, it would correctly track what cards where in each player's hand throughout the game, and nothing else.

This is forked off of the goko-dominion-tools repo. I may have been modifiying the wrong file - it seems like gokoparse.py is meant for the server - it takes in log text, processes it into a database-friendly object, then puts it into a database. The deck tracking code is in web/static/logprettifier.html, it's in-line javascript that does its own parsing.

I'm leaning towards porting the deck tracking from JS into Python, but I'm biased since I know Python a lot better, and using JS would let this all be client side.
Logged
I have a blog! It's called Sorta Insightful. Check it out?

liopoil

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2587
  • Respect: +2479
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #10 on: December 25, 2014, 09:19:23 am »
0

/interest
Logged

Titandrake

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2210
  • Respect: +2856
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #11 on: December 26, 2014, 06:07:54 am »
0

Do the logs differentiate between "Bazaar, then King's Court Bazaar" and "Bazaar, King's Court nothing, Bazaar Bazaar Bazaar"?

Don't think so, that was the point I was trying to make (but made badly).

Haven't tried these yet since I don't have any sets on Goko, and I can't use Throne Room to test it because Throne Room is mandatory. However, I don't think it does.

More importantly, the log doesn't show a difference between if you use Hermit to trash from the discard pile or from the hand. Current plan is to assume the more likely scenario, meaning TR/KC are always on an action and Hermit is on a card in the discard if possible. The conditions in which these fail are hopefully pretty rare, it might not be 100% accurate but whatever.

I've verified the current version of the code works in a Lab-Militia game for tracking cards in hand. Unfortunately even Base has some special cases (Mine has to gain to hand, for example)
Logged
I have a blog! It's called Sorta Insightful. Check it out?

Titandrake

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2210
  • Respect: +2856
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #12 on: January 04, 2015, 12:18:18 am »
0

Alright, here's a question.

I'm trying to get a purely Base-set version working as a proof of concept, except Throne Room (and later on its cousin King's Court) are tricky to deal with.

This breaks down a bit when TR chains get in the mix. Goko logs make no distinction between the different plays of a Throne Roomed action, so

TR - TR - Smithy - Village

becomes

plays TR
plays TR
plays Smithy
plays Smithy
plays TR
plays Village
plays Village

and I need to be able to tell that only the first Smithy, Village, and first two TR plays require moving the card out of the hand into play. I'm trying to decide on the cleanest/least awful way to deal with this.

My original plan was to see if the next 2/3 plays were the same card, and ignore all but the first one. The problem is that this breaks down for the nested TR case as described above. This is worse with KC because that's optional, so for rare cases it also needs to be able to tell when a card is no longer getting played multiple times. I somehow need to be able to tell that the 3rd "plays TR" is ignorable when it comes so far after the 2nd "plays TR".

I'm sure it's not actually too awful to deal with, but I'm too lazy to figure out the proper way to do it when it only affects 2 cards and there are other things to complete that fix many more than 2 cards.
Logged
I have a blog! It's called Sorta Insightful. Check it out?

blueblimp

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2849
  • Respect: +1559
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #13 on: January 04, 2015, 03:52:55 am »
0

Is it even possible to tell whether

plays King's Court
plays Smithy
plays Smithy
plays Smithy

means playing KC-Smithy or means playing KC on nothing and then three Smithies?
Logged

Titandrake

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2210
  • Respect: +2856
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #14 on: January 04, 2015, 09:11:35 pm »
+1

No, but I'm going to assume that case is rare enough to not matter.
Logged
I have a blog! It's called Sorta Insightful. Check it out?

Davio

  • 2012 Dutch Champion
  • *
  • Offline Offline
  • Posts: 4787
  • Respect: +3413
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #15 on: January 05, 2015, 05:29:05 am »
+1

Maybe there could be an extension which is able to record the exact order of play to be used in a replayer?
Logged

BSG: Cagprezimal Adama
Mage Knight: Arythea

Titandrake

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2210
  • Respect: +2856
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #16 on: January 06, 2015, 05:07:47 am »
0

That may be easier, although you lose the ability to analyze past logs.

It also means you need a server that can handle however many games get played with the extension, since storing the exact cards played from the extension is basically like storing another copy of the log. Then again, the Isotropish leaderboard does something similar, since it grabs + processes every pro-mode game played to update rankings. Anyone know what the load is for that?

Tentatively, a thing that tracks the cards in each player's hands is working for all cards in Base + Intrigue + Seaside, but it's very untested and I would not be surprised if I'm missing some edge cases.

Edit: Did some more busywork for edge cases. Many on-play effects are working, but not all. Out of my test suite of ~260 of my own games, it raises an exception on half of them.
« Last Edit: January 07, 2015, 04:43:26 am by Titandrake »
Logged
I have a blog! It's called Sorta Insightful. Check it out?

Titandrake

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2210
  • Respect: +2856
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #17 on: January 07, 2015, 05:37:11 am »
+1

Ugggghhhhh.

For some unfathomable reason, Goko isn't logging everything. When you play JoaT, the log doesn't tell you what cards you drew. At all. Go on, check your own logs. If you discarded the top card, or had fewer than 4 cards, it's impossible to have an accurate hand until you see what cards someone plays later. This may happen in game as well, but I don't have Cornucopia to test it.

There have been some oddities, like how Scout lists what cards you draw and Apothecary doesn't despite having very similar effects, but this is just silly. Hopefully it's just Jack that acts like this.

(Vault doesn't log card drawn from the "discard 2, draw 1" opponent benefit)

An extension that records game state while you're playing the game would fix this, but it would also mean this only works for people with the extension, and you also only get 1 player's perspective...
« Last Edit: January 08, 2015, 01:41:59 am by Titandrake »
Logged
I have a blog! It's called Sorta Insightful. Check it out?

sudgy

  • Cartographer
  • *****
  • Offline Offline
  • Posts: 3431
  • Shuffle iT Username: sudgy
  • It's pronounced "SOO-jee"
  • Respect: +2707
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #18 on: January 07, 2015, 12:29:36 pm »
0

You could maybe try getting it on Salvager in some way.  That would make more games playable.
Logged
If you're wondering what my avatar is, watch this.

Check out my logic puzzle blog!

   Quote from: sudgy on June 31, 2011, 11:47:46 pm

Titandrake

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2210
  • Respect: +2856
    • View Profile
Re: Interest in a Dominion replay system?
« Reply #19 on: January 15, 2015, 06:32:27 am »
+4

Good news and bad news.

Bad news is that for now, I'm skipping all the copiers - meaning Throne Room, King's Court, Procession, and Counterfeit. I'm still convinced there's a nice way to do it, but there are still lots of weird scenarios that don't fit in well with my spaghetti code.

The good news is that if none of those cards get played, it should be working. For now, it tracks cards in hand accurately, and cards in play kind-of-accurately. (It assumes that when you play a card, it stays out until cleanup, then goes away. That's it.)

There's no deck tracking because that's an entire new can of worms I'm not in the mood to deal with right now.

Now, I'm almost certain there's a bug somewhere, because oh my goodness is the code awful and disorganized. My super simple test setup does a fail if it tries to remove a card from the hand that isn't there, but has no checks on whether there are extra cards in hand or not.

And this is where you people come in. Deploying and waiting for people to find bugs seems a lot easier than me trying to find weird cases myself. Unfortunately, it's still a bit off from that point.

First off, there actually needs to be a frontend for this. If anyone has a simple HTML/CSS/JS webpage from a past Dominion project that can be adapted to display game state, let me know. From there, the following non-trivial steps need to happen:

- turn my random parsing code into an actual server for requests (most likely going to be done with Flask)
- actually get frontend + backend to talk with one another
- host online so people can point out the 85 bugs in it, but this way I can actually get sample logs

Hopefully this can get out there before the new expansion renders it super broken.
Logged
I have a blog! It's called Sorta Insightful. Check it out?
Pages: [1]
 

Page created in 0.049 seconds with 20 queries.