From 66d80410dbd86d41e47af979a4e2ec02d4842728 Mon Sep 17 00:00:00 2001 From: jkh Date: Thu, 15 Aug 1996 20:15:18 +0000 Subject: 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 :). --- lib/libncurses/TESTS/hanoi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib') 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(); -- cgit v1.1