]> git.gir.st - solVItaire.git/blob - README.md
automagic conserve space
[solVItaire.git] / README.md
1 # solVIItaire
2
3 play klondike and spider solitaire in your unicode terminal.
4
5 ## TODO
6
7 ### P1
8 ### P2
9 * TODO: suggest moves (`h` => hint)
10 * TODO: 'join to here' command (should take longest chain available)
11 * TODO: escape sequences (for real cursor keys)
12 * TODO: inverted moves (if A->B doesn't work, try B->A)
13 * TODO: cleanup: in `x2y()` functions there is a lot of replication and noise
14 when calculating legal moves, top cards, etc.
15 ### P3
16 * TODO: screen size > stack height => rendering issues!
17 * TODO: differential drawing mode (at least for highlighting cards)
18 ### P4
19 * TODO: mouse mode (problems: finding position with `extreme_overlap`)
20 * TODO: scores, variants: draw 3, max. n overturns
21 * TODO: expose deal() seed for restarting the game
22 * TODO: vt220 mode (problems: charset, slow baudrate and no differential drawing mode)
23 * TODO: ed(1) mode (solEDaire): playable on a line printer; ascii/ibm only?
24
25 ### DONE
26 * DONE: use `#ifdef`s to differentiate games (sol, spider, ed-sol, ed-spider)
27 * DONE: keyboard alias: twice same key == waste/pile -> foundation
28 * DONE: spider keyboard: `<from><to>` stacks; 1-9,0=tableu, return=draw
29 * DONE: spider: easy/medium difficulty: only deal 1/2 suits instead of 4 -> deal()
30 * DONE: patience: allow taking from 0(foundation)
31 * DONE: highlight `from` pile, so users can see at what input stage they are
32 * DONE: make piles 0-indexed in klondike as well
33 * HOLD: duplicate card ♠A found in tableu: added check at start to monitor this
34 Cannot reproduce, removed check
35 * HOLD: bugs in spider's t2t()
36 * once segfaulted on large column
37 * sometimes doesn't work (ERR when it should be OK)
38 Cannot reproduce
39 * DONE: some input functions are in `x2y()` -- move them to `get_cmd()` (req.
40 for mouse, hjkl modes)
41 * DONE: sigint, sigcont handler! atexit() to avoid inconsistent term state
42 * DONE: hjkl keyboard mode
43 * DONE: more vim mode keys (first/last tableu)
44 * DONE: online (key-)help `?`, `-h`, `-v` (NOTE: implemented -h, rest deemed
45 not usedul)
46 * DONE: extreme overlapping: if we are printing a sequence or multiple face down
47 cards, only print `.overlap` lines of the ends, and `1` line for the
48 middle cards
49 * DONE: in direct addressing 'up to' dialog: make return/space select the lowest/highest option
50 * DONE: undo:
51 - insert append_undo() in x2y() functions
52 - to encode stack position we need to overload `f.u.n` as index.
53 (similar for foundation: overload `f.u.n` as foundation id)
54 - w2f(): have to encode both stock index and foundation id
55 don't want to add a struct field for this one case;
56 for the time being (i.e. forever) I'm ORing waste index and
57 (foundation id<<16). ugly but works :/
58 - turning over cards: this needs to be encoded, because the card might
59 be consecutive and there's no way to tell what its previous state was.
60 * indicate that a card was turned (can be at most 1) by negating u.n
61 pros: no wasted space (it's just a boolean value), negation pattern
62 already used for closed cards
63 cons: dirty C hack, less obvious than in other places, no need to
64 conserve memory this tightly
65
66 ## Notes
67
68 - terminology:
69 ```
70 {stock}[waste] [4*foundation]
71
72 [] {} {} {} {} {} {}
73 [] (tableu piles) {} {}
74 [] {} {} {} {}
75 [] {} {} {}
76 [] {} {}
77 [] {}
78 []
79 ```
80 - data structures:
81 - enum for each card (e.g. `SPADES_ACE`, `HEARTS_10`)
82 - each pile is an array holding (13 open cards + up to 6 closed)
83 [0] is the "northmost"/bottom-most card; unoccupied are NULL/NO_CARD
84 - a single card is represented in the 'cards' enum; if it is closed, it is negated.
85 - the foundation are 4 arrays of size 13
86 - the stock pile is an array holding n cards and an index to the one to display
87 when removing, decrement stack size and move all cards above index 1 over
88 - previous states array: where to move which cards to get back to the state before
89 - undo:
90 double-linked list (follow `.prev` to undo, `.next` to redo)
91 "N cards were moved from X to Y" (do Y->X to undo)
92 allows jumping forwards in time as well (by repeating X->Y)
93 warn: when appending state, must check if `.next` was non-NULL and free rest of chain if so.
94 - multiple card sizes: schemes.h will store cards like below. if we want to draw a card
95 that has one or more other cards below it, we only draw the first `.overlap` lines,
96 otherwise if it is the last one, we draw the whole one.
97 this will give a look like in `~/solitaire-tests`
98 ```
99 .grid=7, /*vertical alignment*/
100 .overlap=2,
101 .cards = [
102 ["╭───╮",
103 "│♠ X│",
104 "│ ♠ │",
105 "╰───╯",
106 NULL],
107 ]
108 /*or:*/
109 .grid=2,
110 .overlap=1,
111 .cards = [
112 [ "🃖 ", NULL ],
113 ]
114 ```
115 "open": face up card
116 "closed": face down card
Imprint / Impressum