Monday, August 17, 2015

Remiss

I have been remiss in blogging. I'd rather read other blogs than contribute my own I guess. Plus no one seems to be reading, so it's more like cloud storage of thoughts than communication. My subjects are pretty boring. Star Trek, Chess, math. If anyone does wish to correspond: youngjeffreyalan gmail com, and you know the punctuation...

Thursday, June 4, 2015

King's Gambit Theory with Stockfish

Following on from the earlier post on "fighting with Stockfish", I have some theory results in the King's Gambit.

Reminder of the project: a repertoire-for-black tree after 1.e4 e5 2.f4 exf4, up to three-deep for White based on Stockfish evaluations (top three, cutoff anything more than 0.5 worse than top result), one-deep for Black (my repertoire selection), moves 3 through 9.

That means 7 plies with up to 3 selections each, 3^7 = 2187 upper bound on number of potential lines (actually final positions) I need to look at. Big project, not done yet, but I do have some preliminary results.

The top line (main line, best for White) that I have evaluates at -0.25 and is 3.Nf3 d6 4.Bc4 h6 5.h4 Be7 6.d4 Nf6 7.Nc3 Nh5 8.Ne2 Nc6 9.Bxf4 Bg4.

The bottom line (worst for White) that I have, so far, is the very "rightmost" line in the tree as defined above, evaluating at -1.16, 3.Qf3 Nc6 4.Nc3 Nd4 5.Qd3 Qh4+ 6.Kd1 Ne6 7.Qf3 Bc5 8.Nge2 Nf6 9.d4 Nxd4 (10.Qxf4 Qxf4 11.Nxf4).

That's a lot of positions, in a narrower range of evaluations (under 1.0) than I would have expected. One metaphor I have for thinking about main lines (best play for both sides) is as walking the crest of a mountain ridge. Turns out that the top of the ridge is a lot flatter than I pictured -- there are a lot of lines theoretically drawn with best play.

Let's see how some theoretical lines stack up in this range. The seeming conventional-theory main line of the Fischer defense, 3.Nf3 d6 4.d4 g5 5.h4 g4 6.Ng1, comes in at -0.70, barely making the tree criteria (5.Qd3 and 5.h3 score better), with continuation 6...f5(!) 7.Bxf4 fxe4 8.Nc3 d5 9.Qd2 Ne7. (Fischer's own conclusion that 6...Bh6 gives White "no compensation" is maybe not so accurate in view of 6...Bh6 7.Nc3 Nc6 8.Qd3 with Nge2 coming, giving White control of f4 (and f5, f3, e4 and d5) and preparing O-O-O. Evaluation -0.27.)

How about the supposed recent recommendation (John Shaw's book; I don't have it) to play against the Fischer defense in "Quaade style"? This also doesn't make the tree criteria. Near as I can determine, the recommendation is 3.Nf3 d6 4.d4 g5 5.Nc3, to which Stockfish gives -0.70 with a nice counter 5...g4 6.Bxf4 gxf3 7.Qxf3 Nc6 8.O-O-O Qh4(!). In addition to Bg4, Black is also threatening Qxf4 and/or a Bh6 pin. And 8.Bb5 Qh4+ is only slightly better for White.

If Shaw meant 3.Nf3 d6 4.d4 g5 5.g3, that seems equally bad: 5...g4 6.Nh4 f3 7.Nc3 Bg7 8.Be3 Nc6 9.Qd2 Bd7, -0.70. Again, the "tree moves" after 3.Nf3 d6 4.d4 g5 are 5.Qd3, 5.h3, and 5.h4.

Caveat: none of these numerical evaluations is definitive. One discouraging result of this experiment so far is how fickle/unreliable the evaluations can be because of the horizon effect. My original main line preference after 3.Nf3 d6 4.Bc4 h6 was 5.d4 g5 6.h4 g4 7.Ng1 f3 8.gxf3 Be7 9.c3 Bxh4+ with only a -0.17 evaluation. It turns out that there is a Black error in this line that Stockfish didn't see. After 5.d4 g5 6.h4 Black should play 6...Bg7 instead. Stockfish thought that the liquidation 7.hxg5 hxg5 8.Rxh8 Bxh8 was good for White (-0.02) when it is actually better for Black, when examined at more depth: 9.Qd3 Nc6 (-1.07). The apparent king attack with 10.e5 is fully repelled via 10...Bg7 11.Qh7 Kf8 12.Qh5 Nh6, essentially tying up the queen with only two pieces.

So, in-depth theory still wins out over (shallow) computer evaluations. I still think this is a valuable experiment however.

On a practical note, I just had opportunity to use this experiment's data in an ICC tournament game when my opponent played the experiment's current main line, see above, only exiting the data at 8.Nd5 (data says 8.Ne2, 8.Qd3, 8.O-O). Unfortunately I did not find the winning plan after that -- Ng3 followed by c6 Nxe7 Qxe7. Still, very interesting.

Thursday, May 7, 2015

Star Trek TOS Patterns

As a long-time and repeat watcher of the Original Series episodes, I have noticed many a pattern of repeated ideas or themes. Let me see if I can enumerate some off the top of my head.

After watching the second (and series-winning) pilot, Where No Man Has Gone Before, the theme of Supermen and Gods just clobbered me over the head. Gary Mitchell (and Dr. Elizabeth Dehner) in that one of course. Then there is Khan Noonien Singh in Space Seed, Apollo in Who Mourns for Adonais, and Sargon's race in Tomorrow is Yesterday. I'm not talking about mere dictators nor special powers. Those are other themes. But Roddenberry obviously had a thing about men approaching godhood and/or the equivalent, gods being merely mortal. Notice that in each instance, the superman/god must be brought down by the end of the episode. Time to scan the episodes again and see if I missed any additional instances of this theme... I find no other direct instances. A weaker related theme does appear however: being (falsely) worshiped as a god. Apollo, in the past, is an instance of this. But there are several episodes depicting ongoing worship, the most representative episode being The Apple in which Vaal is worshipped. Of course in all instances the erroneous worship must be corrected somehow. The other instances I find are: The Paradise Syndrome in which Kirk is worshipped as the god Kirok, For the World is Hollow and I Have Touched the Sky in which The Oracle is worshipped, Bread and Circuses in which the slaves worship the sun/son (note: this is a special case), and And the Children Shall Lead in which Gorgan is worshipped by the children. The criterion "as a god" gets more tenuous however, which leads to a further list of episodes where there is a weaker version of the same dynamic, i.e. reverence rather than worship -- of Cochrane by The Companion in Metamorphosis, of the Holy Words in The Omega Glory, of The Book in A Piece of the Action, and maybe even of Gill in Patterns of Force, although I think we've crossed the line into "mere dictators" there. On an opposite tack, there are a couple of episodes where a feared entity is referenced as devilish -- the Horta in Devil in the Dark of course, but also the Doomsday Machine which Decker at one point describes as "straight out of Hell". And finally there are the mere references to the Bible or to gods which one might find in any series -- Whom Gods Destroy, The Way to Eden, Requiem for Methuselah, even the "delusions of godhood" reference in The Trouble With Tribbles and the "laws of God and men" in The Ultimate Computer.

Before moving on to dictators and special powers, I want to cover the even more dominant theme of Insanity. I don't know if Roddenberry had some special connection to or interest in mental health, or whether it was just a convenient route to increased drama. But there are a full two episodes set in mental asylums, and many additional characters depicted as literally insane. The episodes are of course Dagger of the Mind and Whom Gods Destroy. The individual characters are: Lenore Karidian in The Conscience of the King, Ben Finney in Court MartialLazarus in The Alternative Factor, Matt Decker in The Doomsday Machine, Richard Daystrom in The Ultimate Computer, Larry Marvick in Is There in Truth No Beauty?, Dr. Sevrin in The Way to Eden, and Janet Lester in Turnabout Intruder. There are several additional examples of temporary insanity: everyone in The Naked Time, McCoy in City, Spock in All Our Yesterdays. And if we relax to the milder mental abberations of obsession and the like: Kirk in Obsession and in A Private Little War.

Dictators

Special Powers

Tuesday, April 14, 2015

Fighting with Stockfish (a chess engine) in the King's Gambit

I have been studying responses as Black to the King's Gambit for years, so I should have a good handle on any positions that arise, right? But I keep getting thrown when opponents vary move orders. So obviously I am focusing too much on moves and not enough on positions.

Case in point is a recent game that went 1.e4 e5 2.f4 exf4 3.Nf3 d6 4.Bc4 h6 5.O-O. The book move order is 5.d4 g5 6.O-O Bg7. So I had to stop and think about "what weakness 5.O-O has that 5.d4 does not".

My thinking went: 1) f4 is not attacked so g5 can be postponed, and 2) I got attracted to c6 because 2a) it supports a later d5 blunting the bishop, and 2b) it opens up a nice Qb6+ possibility.

Stockfish says no, that 5.g5 is best, with 5.Nc6 a close 2nd, and with 5.c6 being 5th after even Nd7 and a6! To be fair to myself, none of these moves is horrible, and all score as a Black maintaining the edge. So what is Stockfish saying, that 5.O-O g5 6.d4 transposes with 5.d4 g5 6.O-O? Not at all; Stockfish seems to be saying, counter to theory, that 5.d4 as well as 5.O-O are inferior for White!

This needs to be investigated. Let's see what Stockfish thinks White should be doing after 1.e4 e5 2.f4 exf4 3.Nf3 d6 4.Bc4 h6. Both 5.h4 and 5.b3 show up. Interesting. Both interfere with Black's fianchetto plan on g7. Actually 5.h4 is also theory, but I thought 5...Be7 and 6...Nf6 refuted it. Let's see what Stockfish thinks.

Black manages to keep the extra pawn but a less-than-one-pawn advantage with the liquidation line 5.h4 Be7 6.d4 Nf6 7.Nc3 Nh5 8.Ne2 Bg4. Basically Black will get h4 (with check) while White will get f4.

But there is a larger question here. What is the full range of "playable" move orders (for White)? I've started an experimental compilation of such "playable" lines, with some strict criteria to keep it tractable. This should produce a comprehensive opening book of sorts, which should be interesting to compare with "known"/published theory. The criteria I'm starting with: 1) only variations by White, on moves 3 through 9 (after 1.e4 e5 2.f4 exf4), i.e. only a single Black response selected (by me) to each White variation; 2) at most 3 White variations at each move, taken from the top of Stockfish's evaluations regardless of "existing theory"; 3) with an additional restriction that any White moves that evaluate more than 0.5 worse than the top move are cut.

The reason for "1)" is that I'm only interested in this as a "repertoire for Black" (and to reduce combinatorial explosion). The reason for "2)" is of course to limit combinatorial explosion, while stlll allowing some minimal required variation for interest. The reason for "3)" is to further restrict explosion by assuming "bad" moves (and their exploitation) would be more easily found over the board, so not needed in "book". That last assumption is pretty tenuous, especially for players at my level. Nevertheless. It makes for good puzzles/challenges as to why move X got excluded.

Caveat: Of course the Stockfish evaluations are going to vary, possibly greatly, depending on 1) how deep I let Stockfish go, 2) how much hashtable is used (memory of previous evaluations), and 3) how manual probing changes the population of the hash tables, 4) etc. The purpose of the project is just to produce one experimental benchmark, of reasonable quality but in a reasonable amount of time. For possible critique and/or refinement later. I am of course assuming that Stockfish gives "reasonable" evaluations even in the opening; I think that is valid at this stage of engine power. I expect that a project like this will identify at least as many valid lines that have never been considered "theory", as lines that theory has already validly refuted.

I hope to give examples in a following post.

Monday, March 9, 2015

Star Trek TOS Goodness, 21 The Return of the Archons

Another cold open (as in Tomorrow is Yesterday), except this time we can recognize Sulu, albeit dressed in "period" clothing, and some quick references to "the captain". Clearly we have a "landing party in trouble" type of situation. One thing I didn't appreciate before is how much the exposition of the whole planetary "culture" fell on Takei's shoulders exclusively -- "of the body", "Landru", anger alternating with placidity, babbling, "Archons", "paradise, paradise, paradise...". Great job by George setting all that "strange new world" mystique up for the rest of the episode!


"The Archons" turns out to be a complete MacGuffin of course, "Archon" being the name of a ship that "disappeared" here "100 years ago". And yet they use it as the episode title, gaah! It would be like the film "Casablanca" being titled instead "Obtaining the Letters of Transit".

Kirk, Spock, and McCoy beam us all down with a second landing party to investigate. (Who the heck is flying the ship? Must be Scotty alone.) And we're introduced to some more mysterious terms -- "Festival", "will of Landru". Interesting depiction of a culture "in extremes", usually highly placid, but getting twelve hours of extreme "spring break" on a scheduled basis. Of course, it's a metaphor for our own industrial "modern life".

Speaking of extreme contrasts, another one is how the Lawgivers publicly execute Tamar on a hearsay accusation of "mocking" and then proceed to state that "Landru is gentle". Oh, really?

Long story short, the whole society is controlled by telepathy, and has been for 6000 years, for their own "good". It's a reductio ad absurdum of "benevolent dictatorship". The reductionism going even so far as having the real Landru having programmed his entire "life essence" into a computer somehow before his death. For all the "complete control" the computer exerts, there is nonetheless an underground movement as well. There's always an underground (Bread and Circuses, Patterns of Force). Go figure.

As usual, it is rather short work for Kirk and Spock to figure all this out, and for Kirk to convince the "life essence" part of Landru that the "computer" part has mucked up his intentions royally -- lord knows there are enough contradictions to draw from -- thus blowing up the whole enterprise.

I am having trouble finding any overall "goodness" in this episode now. The culture is just way too one-dimensional -- no explanation of, say, their economy nor their industry, nothing -- and yet there was all that time to talk about Archons, Archons, Archons. It was 100 years ago; they're all dead one way or another.

One thing that does stick with me for some reason is the penultimate twist (before the "Landru is a computer" reveal), that Marplon is the third member of the Tamar/Reger underground cell, and that Kirk and Spock have thus not been "absorbed" after all. I love twists, and the actor playing Marplon really sells this one. The absorption chamber is also really cool and well laid out. And finally, Spock's/Nimoy's eye-roll after having to fake the peaceful demeanor to his Lawgiver escorts is a priceless topper.


Two additional complaints. Once again we have a jarring pronunciation discrepancy that ruins the realism. Marplon pronounces "Reger" with a hard "g", while everywhere else in the episode it is soft, as "rager". And at the beginning, all it takes for Sulu to be "absorbed" is a single use of the Lawgiver's "stick". Why do they need a whole absorption chamber?? Oh well.

Finally, a few "commonalities". The street-level sets look almost identical to those in City on the Edge of Forever, while the dungeon sets look identical to those in Catspaw. And once again we have a paradise/utopia episode, like This Side of Paradise, Shore Leave, The Paradise Syndrome, and even A Taste of Armageddon.

Overall, a good science fiction premise with good twists, but with a bad emphasis on a MacGuffin.

Tuesday, January 13, 2015

Cochrane Gambit is Safe

John Cochrane, economist, lawyer, or chess player?

Wait, there is an active Chicago academic economist named John Cochrane:
http://faculty.chicagobooth.edu/john.cochrane

And of course who can forget this guy:
http://en.wikipedia.org/wiki/Johnnie_Cochran

But we're talking about the 19th-century Scottish chess player:
http://en.wikipedia.org/wiki/John_Cochrane_%28chess_player%29

Who invented the Cochrane Gambit (for White) of the Petroff Defense (for Black) with this game.


The name Cochrane.

Cochrane is an interesting surname. Turns out it has three different Scottish/Irish origins:
http://en.wikipedia.org/wiki/Cochrane_%28surname%29

Another Cochrane in popular culture is Zefram, fictional inventor of Star Trek's "warp drive".

A new Cochrane Gambit line, for White.

1 e4 e5 2 Nf3 Nf6 3 Nxe5 d6 4 Nxf7 Kxf7 5 d4

Now Black has options, with a burden to demonstrate White's gambit unsound. Stockfish seems to have demonstrated that my previous conjectured refutation, 5...Qe8 6 Nc3 d5 7 e5 c5, still leaves White with enough for a draw by repetition. The right plan for White is to ignore d4 and go after the king with 8 Be2, breaking the pin on e5.

(For reference, the previous line went 8 Bc5+ Nc6 here, not good enough for White). Now pretty much forced is 8...cxd4 9 exf6 dxc3. White has traded away the strong center for "a bone in Black's throat" on f6.

10 O-O now breaks the pin on e2, and with 11 Re1 coming next, there are enough threats against Black's king and queen to compensate for the knight-for-pawn material deficit.

A sample short perpetual (Black has no better) is 10...Qc6 11 Re1 g6 12 Bf3 Be6 13 Rxe6 Kxe6 14 Bg4+ (Kf7 15 Bf3 Ke6 ...):