FreeCell stubs

The problem: the constraints clash with the stub generator.

Constraints

I want the input to be an actual valid fc-solve input.

Foundations: C-A
Freecells: - - - -
: QS TS TH 8C 7S 3H 6D
: KH KS JC 9C AH JH 5D
: JD JS 5C 3C KC 2D QH
: 8H AD 4D 5H 4H 5S 
: QD 8D 9S 2H 7D 9D
: TD 4S QC 6H 2S 6S
: 8S 2C TC 9H 4C 3D
: KD 7C 7H 6C 3S AS

Card format is a standard {rank}{suit} two-character pair, no issue there.

Cascades are ordered per line left-to-right, top to bottom within one. The leading colon is optional.

Freecells are in a prefixed line of their own in card format, extended to understand a dash as an empty cell.

Foundations are in a prefixed line of their own in a different format: one entry per non-empty foundation, {highest rank}{dash}{suit}

Stubgen

See also Stub Syntax

The stub generator used by CG is quite underdocumented; all there is is a limited “how to” guide. No formal spec we could use to confidently prove out some constructs as unrealizable.

Clash

The prefixed fields are hard to realize.

In a perfect world… maybe later. In a good world, the headers could be ignored, as we can provide that information through other means (namely, position). Cells pose no problem at all.

Now foundations and cascades, on the other hand, are variable-lengthed. With the current system, they can either be read as a whole line with no splitting, or as a line of a known quantity of same-typed items.

So the core of the issue is: are the words on the line of the same type?

There are two levels of answering.

  1. From a stub generation point of view, they are. They’re “words”.
  2. From a semantic point of view, they aren’t. There’s a “label” and “cards”.

Analysis

Success for: bash, C, C++, Dart, Groovy, Haskell, Lua, ObjC, Pascal, Perl, PHP, Python 3, Ruby, Rust, Swift, VB.NET.

Fails because fc+1 becomes fc_1 in: C# D, Go, , Java, JavaScript, Kotlin, Scala, TypeScript.

Fails for understandable (Clojure) to weird (F# and Ocaml) reasons.

Current workaround

Perform the +1 server-side. This solves it for most, at the cost of a ridiculous identifier.

Remaining failures are Go (language design choices), F# (IndexOutOfRangeException, not sure why) Clojure and Ocaml (Timeout, not sure why).

#freecell #contrib