summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1996-08-15 20:15:18 +0000
committerjkh <jkh@FreeBSD.org>1996-08-15 20:15:18 +0000
commit66d80410dbd86d41e47af979a4e2ec02d4842728 (patch)
tree2d3b596511f7f99c54b3f96290403f49438e87e6 /lib
parent6c8326977df550a2a016b180753415ee446ee145 (diff)
downloadFreeBSD-src-66d80410dbd86d41e47af979a4e2ec02d4842728.zip
FreeBSD-src-66d80410dbd86d41e47af979a4e2ec02d4842728.tar.gz
Add something so that you can solve the puzzle automatically by pressing
`a' (I'm using this code as a test for something else, and just happened to add this in the process :).
Diffstat (limited to 'lib')
-rw-r--r--lib/libncurses/TESTS/hanoi.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/libncurses/TESTS/hanoi.c b/lib/libncurses/TESTS/hanoi.c
index bf44cc4..8a482d5 100644
--- a/lib/libncurses/TESTS/hanoi.c
+++ b/lib/libncurses/TESTS/hanoi.c
@@ -51,13 +51,14 @@ int TileColour[] = {
};
int NMoves = 0;
+static unsigned char AutoFlag;
+
void InitTiles(), DisplayTiles(), MakeMove(), AutoMove(), Usage();
int
main(int argc, char **argv)
{
int NTiles, FromCol, ToCol;
-unsigned char AutoFlag = 0;
switch(argc) {
case 1:
@@ -117,6 +118,10 @@ unsigned char AutoFlag = 0;
for(;;) {
if(GetMove(&FromCol, &ToCol))
break;
+ if (AutoFlag) {
+ AutoMove(0, 2, NTiles);
+ break;
+ }
if(InvalidMove(FromCol, ToCol)) {
mvaddstr(STATUSLINE, 0, "Invalid Move !!");
refresh();
@@ -209,6 +214,10 @@ GetMove(int *From, int *To)
refresh();
if((*From = getch()) == 'q')
return TRUE;
+ else if (*From == 'a') {
+ AutoFlag = TRUE;
+ return FALSE;
+ }
*From -= ('0'+1);
addstr(" to ");
clrtoeol();
OpenPOWER on IntegriCloud