In another thread (http://forum.dominionstrategy.com/index.php?topic=17704.msg726125#msg726125), some people were discussing a theoretical way to define an engine by imagining an infinitely large deck. Equivalently, we could imagine a deck where we draw cards with replacement--meaning that every time we draw a card, we shuffle a copy of that card into our deck.
I am a condensed matter physicist. This problem interested me because the transition between big money and an engine is similar to physical phase transitions, such as that between water and ice.
I'd be interested in writing an article that is accessible to a broad audience, but this is not that article. First I need to figure out what's going on. And I know there's a lot of math expertise around f.ds, so maybe you can help.
The Laboratory engine
Suppose we have a deck with just Coppers and Laboratories. Let's say the fraction of labs is D (for "draw") and the fraction of coppers is 1-D. It's fairly easy to figure out the expected value of a turn.
Let x be the average value of a card. The average value of a turn is simply 5*x.
x = 1-D + D*2*x
x = 1+D/(1-2D)
(https://atrivialknot.files.wordpress.com/2017/11/lab-engine.png)
I drew this with a mouse so it's not to scale.
As you can see, the average value of a turn diverges as D approaches 1/2. That's the phase transition. When D is greater than 1/2, your deck has a nonzero probability of drawing forever. Let's use "reliability" to refer to the probability that you draw forever. I don't have an explicit expression for the reliability, but I know that the larger D is, the larger the reliability is.
When D is at the critical value of 1/2, this is a special case. The reliability is zero, but the average value of a turn still diverges as you increase the size of your deck. mad4math proved (http://forum.dominionstrategy.com/index.php?topic=17704.msg733155#msg733155) that the average value of a turn is grows as sqrt(N), where N is the size of your deck.
When D is somewhat below 1/2, we might say that this is "practically an engine". In practice we only need to draw finite decks, and we even get to draw 5 cards for free at the start of turn. So yeah, depending on the size of your deck, the phase transition actually occurs earlier than these calculations suggest.
The Village/Smithy engine
Next we consider a more complicated case, a Village/Smithy engine. Let's say that the fraction of villages is A (for "action") and the fraction of smithies is D (for "draw"), and the fraction of coppers is 1-A-D. I don't know the best way to calculate the average value of a hand, but here I give it my best shot.
Let x be the average value of a card, not including dead draw.
x = 1-A-D + Ax + min(A,D)*3*x
x = (1-A-D)/(1-A-3*min(A,D))
The engine phase transition occurs when the denominator is zero.
I am not sure how to add the value of dead draw, but it should be p*3*(1-A-D), where p is the probability of having at least one extra smithy in hand, with only one action remaining and no villages. I believe this is most important when D > A and (1-A-D) is large. Anyway, here's the phase diagram:
(https://atrivialknot.files.wordpress.com/2017/11/classic-engine.png)
It's triangle-shaped because we have the inequality A+D < 1. I didn't have the space to draw it, but there should still be a "practically an engine" region.
I was also thinking there might be a more elegant choice of variables. Let V be the number of villages per copper, and S be the number of smithies per copper. In this case, x = 1/(1+S-3min(S,V)). I'm not sure if this is more or less intuitive, but here's the phase diagram:
(https://atrivialknot.files.wordpress.com/2017/11/classic-engine-21.png)
Hmm... I wonder if you could get rid of the "practically an engine" region if you just define V and S to be the number of villages/smithies per copper past the first five coppers.
Questions
-I know the calculations aren't perfect, so can you think of any better way?
-How can I estimate the value of terminal draw?
-Is there any way to estimate reliability?
-If I wanted to make this broadly accessible, which parts are particularly confusing or need explanation?
-Any other thoughts?
Some plots (I am terrible at making plots, so the fill area alternates between BM and engine, but hopefully the point comes across anyway). Note that now I agree with the final conclusion of trivialknot on the Village-Smithy engine!
Also useful to note is that, if A,B is a transition point, then any point with A'>=A and B'>=B is an engine. In particular, the TR-Smithy engine has a single "true", transition point, so you need to use that to distinguish between BM and engine elsewhere.
(https://i.imgur.com/db1zY1g.png)(https://i.imgur.com/8dQp7Pu.png)(https://i.imgur.com/FXauZrK.png)
EDIT: now with correct links to the images. I will let the proof of these plots as an exercice to the reader ;)
Eh, S/V are probably more intuitive, but the calculations I do are easier with A/D, so I plotted that.
EDIT: this is kinda fun, here are some more plots with sifting (with other plots for reference):
(https://i.imgur.com/bPuBvrO.png)(https://i.imgur.com/6mK7Mjp.png)
(https://i.imgur.com/0JmT7L2.png)(https://i.imgur.com/myook0p.png)
(https://i.imgur.com/cB2mrOI.png)(https://i.imgur.com/d1It9lH.png)
Was trying to do Herald - Smithy, but third degree equations appear and that's the point where it isn't fun anymore :p
Grey regions are points where the engine goes infinite, but is forced to discard payload cards to keep going. Some unintuitive results! Will add some more comments / plots later if I am bored enough.
EDIT: added Herald, making the simplification that it's a card that draws 1+(A+D) cards and gives 1+(A+D) actions. Since the extra card drawn by Herald is always an action, this is actually a nerf, but otherwise the problem was intractable with my approach. To the right of the dotted line, we have too many terminals. Note that the transition line for high number of heralds is not a straight line, it's slightly concave.
Man I've been nerd sniped hard. I think I should be able to write some code that can draw these diagrams automatically for reasonably simple cards, just need to think about it some more.