From e1d00062da5d397e521729a88999b9ca787c5c2f Mon Sep 17 00:00:00 2001 From: girst Date: Thu, 29 Nov 2018 13:25:33 +0100 Subject: [PATCH] update undo data structure (comments only) --- README.md | 3 +-- sol.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c86ef11..91267a6 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,7 @@ play klondike and spider solitaire in your unicode terminal. ### P2 * TODO: undo: - insert append_undo() in x2y() functions - - to encode stack position we need to overload f.u.f. can't do negative - (-0), so +128 it is. + - to encode stack position we need to overload `f.u.n` as index. * TODO: sigint, sigcont handler! atexit() to avoid inconsistent term state * TODO: cleanup: in `x2y()` functions there is a lot of replication and noise when calculating legal moves, top cards, etc. diff --git a/sol.c b/sol.c index f0a5170..90feb1d 100644 --- a/sol.c +++ b/sol.c @@ -37,10 +37,9 @@ struct playfield { card_t f[NUM_DECKS*NUM_SUITS][PILE_SIZE]; /* foundation */ card_t t[NUM_PILES][PILE_SIZE]; /* tableu piles */ struct undo { - /* NOTE: .f & .t are overloaded; 64+n=foundation; 128+n=stock */ int f; /* pile cards were taken from */ int t; /* pile cards were moved to */ - int n; /* number of cards moved */ + int n; /* number of cards moved (if tableu; else index of stock/foundation) */ struct undo* prev; struct undo* next; }* u; -- 2.39.3