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