]> git.gir.st - solVItaire.git/log
solVItaire.git
23 months agofix find-following master github/master
girst [Thu, 19 May 2022 13:16:03 +0000 (15:16 +0200)]
fix find-following

this bug manifested in freecell as the ace of clubs not recognized as
placable on the foundation (from the tableu) when all four free cells
were occupied.
due to us not checking that find_top() found a card at all, we
accidentally checked foundation[-1], which is the fourth free cell.

there are probably more bugs stemming from this misuse of find_top().

2 years agomake 'no take from empty' more dry
girst [Wed, 20 Apr 2022 17:18:08 +0000 (19:18 +0200)]
make 'no take from empty' more dry

oof, that's an awful macro.

2 years agoprevent taking from empty foundation
girst [Wed, 20 Apr 2022 16:44:50 +0000 (18:44 +0200)]
prevent taking from empty foundation

a direct copy of the previous commit, but for the other non-tableu
piles.

2 years agofreecell: fix direct addressing 'take from cell'
girst [Wed, 20 Apr 2022 16:39:29 +0000 (18:39 +0200)]
freecell: fix direct addressing 'take from cell'

the 'no take from empty stock/cell' rule had a bug that only checked the
first cell when accessed with '9'. this is because with direct
addressing mode, active.opt stays at its initial value of 0. this check
was split in two parts:

- direct addressing: only abort when all cells are empty
- other: check that struct cursor active was actually modified.

a third test was then added to make this work with mouse addressing
also.

2 years agomake freecell obey the 'no selecting of empty stock' rule
girst [Sun, 5 Sep 2021 15:48:51 +0000 (17:48 +0200)]
make freecell obey the 'no selecting of empty stock' rule

4 years agoblink waste/cells
girst [Fri, 13 Mar 2020 15:18:52 +0000 (16:18 +0100)]
blink waste/cells

4 years ago'.' implementation (ugly and not portable)
girst [Fri, 13 Mar 2020 14:22:54 +0000 (15:22 +0100)]
'.' implementation (ugly and not portable)

uses ungetc(3) twice, which "works on my machine"™

4 years agofind and search commands prototypes
girst [Fri, 13 Mar 2020 14:05:21 +0000 (15:05 +0100)]
find and search commands prototypes

NOTE: both need a considerable amount of cleaning up

4 years agoifdef off inverted move logic
girst [Fri, 15 Nov 2019 13:32:52 +0000 (14:32 +0100)]
ifdef off inverted move logic

that proved to be more annoying than useful for me. pass -DINVERSE_MOVE
to the compiler to reenable.

5 years agofix freecell->free tableu
girst [Sat, 23 Mar 2019 15:39:22 +0000 (16:39 +0100)]
fix freecell->free tableu

if only 1 free cell was occupied and moved to an empty tableu using
direct addressing the user was asked which cell to take from.

5 years agoshuffle around TODOs
girst [Sat, 9 Mar 2019 20:50:11 +0000 (21:50 +0100)]
shuffle around TODOs

5 years agofix c2f() emtpy check
girst [Sat, 9 Mar 2019 20:43:35 +0000 (21:43 +0100)]
fix c2f() emtpy check

gah! function didn't check if the cell was empty. this caused extra
items on the undo list (and the wrong retval)

5 years agofreecell: better join() cell->foundation fix
girst [Sat, 9 Mar 2019 20:23:20 +0000 (21:23 +0100)]
freecell: better join() cell->foundation fix

5 years agofreecell: join() freecells->foundation
girst [Sat, 9 Mar 2019 20:07:55 +0000 (21:07 +0100)]
freecell: join() freecells->foundation

5 years agofreecell: join() to foundation: fix fencepost error
girst [Mon, 4 Mar 2019 20:31:10 +0000 (21:31 +0100)]
freecell: join() to foundation: fix fencepost error

5 years agoupdate TODOs
girst [Mon, 25 Feb 2019 23:18:42 +0000 (00:18 +0100)]
update TODOs

smart card selector -> DONE

5 years agospider: fix undo stack-completed-pile bug
girst [Mon, 25 Feb 2019 22:45:27 +0000 (23:45 +0100)]
spider: fix undo stack-completed-pile bug

if the user draws from the stock and this completes a cascade, the
undo event for the stock deal _must_ be stored before the undo event for
the cascade removal. otherwise the undo history will be broken!!1

5 years agoupdated foundation placeholder
girst [Sun, 24 Feb 2019 17:56:18 +0000 (18:56 +0100)]
updated foundation placeholder

the braille characters are widely enough supported, and the placeholder
should still make sense even if they aren't on a system.

not commited: alternate "10" symbols. ⒑ (tofu in xterm), ⏨ (too small,
tofu in xterm), Ю, (cyrillic yu, not looking too good)

5 years agofreecell: join to empty tableu
girst [Sun, 24 Feb 2019 17:54:43 +0000 (18:54 +0100)]
freecell: join to empty tableu

also removed redundant checks for join()-ability in get_cmd()

5 years agouse color_ok macro everywhere
girst [Wed, 20 Feb 2019 19:59:54 +0000 (20:59 +0100)]
use color_ok macro everywhere

5 years agofreecell: smart card selector, part 4
girst [Wed, 20 Feb 2019 19:51:23 +0000 (20:51 +0100)]
freecell: smart card selector, part 4

all done! \o\ /o/ \o/
nice test seed: 1550690183
also a new helper functoin color_ok(), yet to be used everywhere else

5 years agofreecell: smart card selector, part 3
girst [Wed, 20 Feb 2019 18:26:42 +0000 (19:26 +0100)]
freecell: smart card selector, part 3

foundation -> tableu is the same as in klondike, so i reordered the code
to take advantage of this

note that the if inactive.opt check inside the klondike||freecell block
(sol.c:1169) is only correct for klondike, but freecell checks further
up the if/elseif branches for inactive.opt, so this is never executed.

5 years agofreecell: smart card selector, part 2
girst [Wed, 20 Feb 2019 18:09:26 +0000 (19:09 +0100)]
freecell: smart card selector, part 2

also fixed wrong return value in spider's card selector dialog

5 years agofreecell: smart card selector, part 1
girst [Wed, 20 Feb 2019 17:27:28 +0000 (18:27 +0100)]
freecell: smart card selector, part 1

implements smart move detector for foundation->freecell and
freecell->foundation. missing: *->tableu

5 years agoimplement join() for freecell
girst [Wed, 20 Feb 2019 15:51:02 +0000 (16:51 +0100)]
implement join() for freecell

also fix the outstanding todo in klondike.join()

5 years agoremove freecell backspace
girst [Tue, 19 Feb 2019 19:17:55 +0000 (20:17 +0100)]
remove freecell backspace

5 years agofreecell stable enough for default target
girst [Tue, 19 Feb 2019 18:56:44 +0000 (19:56 +0100)]
freecell stable enough for default target

5 years agodifferentiate foundation from placeholder
girst [Tue, 19 Feb 2019 18:51:48 +0000 (19:51 +0100)]
differentiate foundation from placeholder

alternative designs:
╭╌╌╌╮╭╌╌╌╮╭╌╌╌╮
╎ ╳ ╎╎▕▔▏╎╎▛▀▜╎
╎╱‾╲╎╎▕▔▏╎╎▛▀▜╎
╰╌╌╌╯╰╌╌╌╯╰╌╌╌╯

5 years agoargh! a semicolon too many!
girst [Tue, 19 Feb 2019 18:10:23 +0000 (19:10 +0100)]
argh! a semicolon too many!

5 years agofreecell: respect max_move() in cursor selection
girst [Tue, 19 Feb 2019 18:06:14 +0000 (19:06 +0100)]
freecell: respect max_move() in cursor selection

5 years agoswap win_anim width/height
girst [Tue, 19 Feb 2019 16:28:12 +0000 (17:28 +0100)]
swap win_anim width/height

5 years agofix fencepost in undo_pop, mouse-foundation also in klondike
girst [Tue, 19 Feb 2019 12:44:46 +0000 (13:44 +0100)]
fix fencepost in undo_pop, mouse-foundation also in klondike

5 years agofix fallthough at -V
girst [Tue, 19 Feb 2019 12:28:29 +0000 (13:28 +0100)]
fix fallthough at -V

thanks dax-dev

5 years agofreecell: mouse select for cells/foundation
girst [Tue, 19 Feb 2019 12:27:58 +0000 (13:27 +0100)]
freecell: mouse select for cells/foundation

5 years agofreecell: finished t2t, work on card selector dialog
girst [Tue, 19 Feb 2019 11:35:49 +0000 (12:35 +0100)]
freecell: finished t2t, work on card selector dialog

playable, but clunky version of the get_cmd() post processing stage.

5 years agomore work on freecell t2t()
girst [Mon, 18 Feb 2019 20:49:32 +0000 (21:49 +0100)]
more work on freecell t2t()

it works now, although direct addressing still needs to be addressed
(ba-dum-tshhh) in get_cmd() and some new TODOs have to be DONE.

5 years agofreecell: t2t(), calculate number of movable
girst [Mon, 18 Feb 2019 20:15:09 +0000 (21:15 +0100)]
freecell: t2t(), calculate number of movable

see also: https://boardgames.stackexchange.com/a/45157/26498

5 years agowin_anim: print everywhere on the terminal
girst [Sat, 16 Feb 2019 22:18:57 +0000 (23:18 +0100)]
win_anim: print everywhere on the terminal

5 years agomerge freecell todos into readme
girst [Sat, 16 Feb 2019 22:18:36 +0000 (23:18 +0100)]
merge freecell todos into readme

5 years agospider: fix move to empty tableu
girst [Sat, 16 Feb 2019 21:23:38 +0000 (22:23 +0100)]
spider: fix move to empty tableu

"no of the additions affect klondike or spider, so its safe to commit"
my ass! this is the second bug I've found that I introduced with this.

5 years agoremove debugging seed
girst [Sat, 16 Feb 2019 11:33:19 +0000 (12:33 +0100)]
remove debugging seed

that shouln't've been committed.

5 years agoAdd a colorful version of the mini colorscheme
Feuerfuchs [Thu, 14 Feb 2019 09:09:39 +0000 (10:09 +0100)]
Add a colorful version of the mini colorscheme

5 years agoWIP: freecell implementation (unfinished)
girst [Thu, 14 Feb 2019 20:30:30 +0000 (21:30 +0100)]
WIP: freecell implementation (unfinished)

what's missing:
 - t2t() and corresponding undo_pop()
 - get_cmd() "select from which {cell,foundation}?" dialog
 - some mouse details (term2pile, wait_mouse_up, set_mouse)
 - join() for freecell

no of the additions affect klondike or spider, so its safe to commit.

5 years agojoin() fixes for w2t
girst [Thu, 14 Feb 2019 16:34:44 +0000 (17:34 +0100)]
join() fixes for w2t

you could join onto the waste and if the waste was -1.

5 years agoremove stupid {1, ...} initialisation
girst [Wed, 13 Feb 2019 23:43:24 +0000 (00:43 +0100)]
remove stupid {1, ...} initialisation

5 years agonew todo: freecell
girst [Wed, 13 Feb 2019 17:15:38 +0000 (18:15 +0100)]
new todo: freecell

5 years agoallow disabling visual bell (might change)
girst [Wed, 13 Feb 2019 16:42:24 +0000 (17:42 +0100)]
allow disabling visual bell (might change)

thanks to github user mikezila for the idea. will be replaced by a
less-annoying visbell in the future

5 years agoremove spider.c symlink
girst [Tue, 12 Feb 2019 20:04:42 +0000 (21:04 +0100)]
remove spider.c symlink

let's do the straight-forward thing and just spell out sol.c.

5 years agofix 80 columns, todo->done
girst [Tue, 12 Feb 2019 19:59:55 +0000 (20:59 +0100)]
fix 80 columns, todo->done

5 years agofinish active-cursor-hider
girst [Tue, 12 Feb 2019 19:57:43 +0000 (20:57 +0100)]
finish active-cursor-hider

yeah, it's a hack.

5 years agoWIP: hide active cursor when using mouse (/u/TooEarlyForMe)
girst [Tue, 12 Feb 2019 19:54:07 +0000 (20:54 +0100)]
WIP: hide active cursor when using mouse (/u/TooEarlyForMe)

5 years ago`:help` to show keyhelp (/u/Valley6660)
girst [Tue, 12 Feb 2019 19:41:10 +0000 (20:41 +0100)]
`:help` to show keyhelp (/u/Valley6660)

5 years agoallow using `10` instead of `X` on card face (/u/Valley6660)
girst [Tue, 12 Feb 2019 19:36:06 +0000 (20:36 +0100)]
allow using `10` instead of `X` on card face (/u/Valley6660)

5 years agohide old internal notes
girst [Tue, 12 Feb 2019 18:03:59 +0000 (19:03 +0100)]
hide old internal notes

5 years agoadd keybindings info
girst [Tue, 12 Feb 2019 18:01:28 +0000 (19:01 +0100)]
add keybindings info

5 years ago'join' with right mouse, update keybindings help
girst [Tue, 12 Feb 2019 18:00:38 +0000 (19:00 +0100)]
'join' with right mouse, update keybindings help

5 years agofix segfault when mouse-moving multiple cards to empty tableu
girst [Sun, 3 Feb 2019 16:54:57 +0000 (17:54 +0100)]
fix segfault when mouse-moving multiple cards to empty tableu

the "up to?" dialog calls getch(NULL), which caused a segfault.
> Program received signal SIGSEGV, Segmentation fault.
> 0x00000000004030fb in getch (buf=0x0) at spider.c:940
> 940             if (buf[3]) {
> (gdb) bt
> #0  0x00000000004030fb in getch (buf=0x0) at spider.c:940
> #1  0x0000000000402c97 in get_cmd (from=0x7ffeba433bfc, to=0x7ffeba433bf8,
>     opt=0x7ffeba433bf4) at spider.c:808
> #2  0x0000000000400ebf in sol () at spider.c:108
> #3  0x0000000000400e2f in main (argc=2, argv=0x7ffeba433d28) at spider.c:88

5 years agoAdd LICENSE
girst [Sat, 2 Feb 2019 18:39:47 +0000 (19:39 +0100)]
Add LICENSE

this is the first version covered by and released under the terms of the
GNU GPL version 3. Older versions are _not_ relicensed.

5 years agoimprove readme
girst [Sat, 2 Feb 2019 18:39:40 +0000 (19:39 +0100)]
improve readme

5 years agofriendly readme opening
girst [Sat, 2 Feb 2019 18:03:57 +0000 (19:03 +0100)]
friendly readme opening

elevator pitch of the controls

5 years agomouse: allow dragging
girst [Sat, 2 Feb 2019 17:57:04 +0000 (18:57 +0100)]
mouse: allow dragging

one can now drag the mouse cursor from one pile to another and it'll
register as two events and do the right thing.

5 years agohandle SIGTSTP, fix mouse ctrlseq
girst [Sat, 26 Jan 2019 18:44:07 +0000 (19:44 +0100)]
handle SIGTSTP, fix mouse ctrlseq

5 years agocleanup mouse
girst [Tue, 22 Jan 2019 22:07:32 +0000 (23:07 +0100)]
cleanup mouse

still needs some features like dragging and 'if to is empty, how many
cards?'

5 years agomouse mode (needs cleanup)
girst [Tue, 22 Jan 2019 21:59:56 +0000 (22:59 +0100)]
mouse mode (needs cleanup)

5 years agofix overlong lines
girst [Tue, 22 Jan 2019 00:38:35 +0000 (01:38 +0100)]
fix overlong lines

5 years agofix spider foundation printing
girst [Tue, 22 Jan 2019 00:22:36 +0000 (01:22 +0100)]
fix spider foundation printing

5 years agoclean up reworked join
girst [Mon, 21 Jan 2019 23:36:45 +0000 (00:36 +0100)]
clean up reworked join

5 years agorewrite join() prediction engine
girst [Mon, 21 Jan 2019 23:27:27 +0000 (00:27 +0100)]
rewrite join() prediction engine

5 years agofix 'make test'
girst [Mon, 21 Jan 2019 21:16:17 +0000 (22:16 +0100)]
fix 'make test'

symlink duplicated all TODOs in sol.c

5 years agojoin: in SPIDER, prefer completing a stack
girst [Mon, 21 Jan 2019 21:12:13 +0000 (22:12 +0100)]
join: in SPIDER, prefer completing a stack

5 years agobetter join for klondike
girst [Mon, 21 Jan 2019 20:45:36 +0000 (21:45 +0100)]
better join for klondike

join to foundation, better to-tableu join

5 years agoallow joining to foundation
girst [Mon, 21 Jan 2019 19:59:36 +0000 (20:59 +0100)]
allow joining to foundation

5 years agoallow inverted moves
girst [Mon, 21 Jan 2019 18:39:09 +0000 (19:39 +0100)]
allow inverted moves

5 years agouse getch() everywhere
girst [Mon, 21 Jan 2019 18:29:49 +0000 (19:29 +0100)]
use getch() everywhere

except for inside getch(), of course. where no mouse is needed, one can
pass NULL instead of a buffer; KEY_INVAL will then be returned if a
mouse click was received.

5 years agosupport 'real' cursor keys
girst [Mon, 21 Jan 2019 18:19:16 +0000 (19:19 +0100)]
support 'real' cursor keys

keyhandling imported from minesviiper (minor changes); mouse support
stubbed.

5 years agomake Makefile portable
girst [Mon, 21 Jan 2019 16:21:04 +0000 (17:21 +0100)]
make Makefile portable

apparently, the "prerequisite name != target rule name" only works in
GNU make. symlinking sol.c to spider.c and changing the makefile works.

5 years agoimplement restart same game, increase portability, update TODOs
girst [Sun, 20 Jan 2019 23:44:15 +0000 (00:44 +0100)]
implement restart same game, increase portability, update TODOs

 * use rand() instead of random() to get in line with mines and viiper
 * reorder playfield struct for better alignment
 * remove ignore warnings pragma (not needed any more)
 * remove _POSIX_C_SOURCE feture test (not needed and breaks freebsd)

5 years agofix off-by-one
girst [Sun, 20 Jan 2019 23:11:49 +0000 (00:11 +0100)]
fix off-by-one

cursor could 'escape' the playfield in KLONDIKE

5 years agoactually useful CMD_JOIN implementation
girst [Sun, 20 Jan 2019 23:09:07 +0000 (00:09 +0100)]
actually useful CMD_JOIN implementation

5 years agofirst version of join() -- to be replaced
girst [Sun, 20 Jan 2019 20:32:24 +0000 (21:32 +0100)]
first version of join() -- to be replaced

this version is very suboptimal. we shouldn't take from longest piles,
as that will rip apart already constructed piles. instead, take from
piles where the card we want to move has the least amount of movable
cards _above_ it. even better if the card above is closed. even better
yet if there is no card above (resulting in an empty pile)

5 years agoautomagic conserve space
girst [Sun, 20 Jan 2019 18:50:19 +0000 (19:50 +0100)]
automagic conserve space

only when the window size would be too small to display a pile
completely. still has the problem that sometimes the terminal is too
small for even the extreme overlap.

5 years agoimplement 'M' keybinding
girst [Sun, 20 Jan 2019 18:00:02 +0000 (19:00 +0100)]
implement 'M' keybinding

moves active cursor to the centre pile

5 years agorework command line arguments
girst [Sun, 20 Jan 2019 17:15:37 +0000 (18:15 +0100)]
rework command line arguments

don't require long string arguments

5 years agofix BULCARD() padding
girst [Sun, 20 Jan 2019 17:05:52 +0000 (18:05 +0100)]
fix BULCARD() padding

using ESC produces tofu on some terminal emulators. switching to SI
(Switch To Standard Charset) for padding seems to work better. (SI
should have no effect on Unicode terminal emulators). this also made
detecting the padded lines easier, as \017 (SI) is only appearing in
those.

5 years agofix foundation rendering (SPIDER)
girst [Sat, 19 Jan 2019 16:37:02 +0000 (17:37 +0100)]
fix foundation rendering (SPIDER)

by using a static int to store the foundation index, it couldn't be
reset when a new game was started. this caused the first pile to be e.g.
to end up on the second foundation if the game before had 1 completed.

5 years agofix bold hack; extreme overlap: always show top selected card
girst [Fri, 11 Jan 2019 20:29:48 +0000 (21:29 +0100)]
fix bold hack; extreme overlap: always show top selected card

5 years agofix broken halfcard rendering
girst [Thu, 10 Jan 2019 14:16:31 +0000 (15:16 +0100)]
fix broken halfcard rendering

due to the faint hack, black cards were 1 byte shorter than red cards.
this meant, that the offset for halfcard was off for red colors (as it
has been adjusted for black cards), which caused printing errors in
spider's foundation for overlapping red cards. can't pad with zero bytes
(as that would end the string), but using an extra escape seems to be OK
for xterm and vte-based terminals.

5 years agoupdate TODOs
girst [Tue, 8 Jan 2019 19:30:06 +0000 (20:30 +0100)]
update TODOs

5 years agoassimilate remove_if_complete
girst [Tue, 8 Jan 2019 18:21:18 +0000 (19:21 +0100)]
assimilate remove_if_complete

so spider's "double-click" action has the same feedback as sol's.

5 years agoawful hack that un-breaks faint+bold printing
girst [Mon, 7 Jan 2019 17:12:55 +0000 (18:12 +0100)]
awful hack that un-breaks faint+bold printing

bold and faint can bet set individually, but only reset both at once.
this causes the bold attribute (useful for determining with cards are
movable) to be reset when faint was. we are splitting the string at a
known-whitespace position only if we are at the faint printed lines
(str[n]==033).

5 years agofix turn over bug
girst [Mon, 7 Jan 2019 14:20:01 +0000 (15:20 +0100)]
fix turn over bug

5 years agoundo for spider
girst [Mon, 7 Jan 2019 14:11:09 +0000 (15:11 +0100)]
undo for spider

note that there is a bug in turn-over-detection when to==FOUNDATATION[0]

5 years agoproperly free undo allocations
girst [Mon, 7 Jan 2019 13:16:33 +0000 (14:16 +0100)]
properly free undo allocations

5 years agoimplement undo for KLONDIKE
girst [Mon, 7 Jan 2019 13:03:38 +0000 (14:03 +0100)]
implement undo for KLONDIKE

for now, redo has been scrapped (would require an additional field in
f., and I don't see the need)

5 years agoimplement 'up to' space/return
girst [Sun, 6 Jan 2019 00:14:45 +0000 (01:14 +0100)]
implement 'up to' space/return

5 years agoremove redundant display calls
girst [Sun, 6 Jan 2019 00:06:14 +0000 (01:06 +0100)]
remove redundant display calls

5 years agoundo_pop pseudo implementation
girst [Sat, 5 Jan 2019 23:58:25 +0000 (00:58 +0100)]
undo_pop pseudo implementation

5 years agomove data structure definition into .h
girst [Sat, 5 Jan 2019 23:09:32 +0000 (00:09 +0100)]
move data structure definition into .h

can't declare functions otherwise :|
forward declarations are a mess!

5 years agorename append_undo to undo_push; subs for undo_pop, free_undo
girst [Sat, 5 Jan 2019 22:57:31 +0000 (23:57 +0100)]
rename append_undo to undo_push; subs for undo_pop, free_undo

5 years agosquash another bug
girst [Sat, 5 Jan 2019 22:01:18 +0000 (23:01 +0100)]
squash another bug

what did that semicolon here!?
note that WASTE is not -1 but 0, as it is used as the second index into
action[][]

Imprint / Impressum