[rfk-dev] [esr at thyrsus.com: robotfindskitten is TEH AWSUMM!!!]

Peter A. H. Peterson pedro at tastytronic.net
Thu Oct 25 15:01:22 PDT 2012


robotfindsraymond!

I addressed some of the website issues already, and indicated that I
thought we should not tamper with the hallowed "Book of Found
Kittens", but all issues are of course up for debate. 

----- Forwarded message from "Eric S. Raymond" <esr at thyrsus.com> -----

Date: Thu, 25 Oct 2012 03:51:15 -0400
From: "Eric S. Raymond" <esr at thyrsus.com>
To: rfk-dev at robotfindskitten.org, pedro at tastytronic.net
Subject: robotfindskitten is TEH AWSUMM!!!
Reply-To: esr at thyrsus.com

Some fix and cleanup patches for the POSIX implementation are
enclosed (0001...0008).  The last patch (0009) adds a few new
NKIs for the 21st century.

CVS - Ugh.  If you'd like your project history migrated to git, I
wrote a good tool for that and will cheerfully do it.

A few fixes for the robotfindskitten website:

Home page:

"everyone found great fulfillment in the simulatedly being robot".
Article is unnecessary.  Should read "in simulatedly".

"avaliable" -> "available"

Lists page:

Some right-side frame characters are out of place.

Devteam page:

Some right-side frame characters are out of place.

I aspire to the hallowed status of devteam member.  

Afterword:

"exorcized" -> "exorcised". The z form is marked even in American usage.
-- 
		<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>

>From 7866ac31bd16016040137c24e94ccbc5e3d49c0c Mon Sep 17 00:00:00 2001
From: "Eric S. Raymond" <esr at thyrsus.com>
Date: Wed, 24 Oct 2012 22:25:10 -0400
Subject: [PATCH 1/9] Remove obsolete comments.

---
 src/messages.h |    7 -------
 1 file changed, 7 deletions(-)

diff --git a/src/messages.h b/src/messages.h
index 389ec3f..5f5ed46 100644
--- a/src/messages.h
+++ b/src/messages.h
@@ -1,10 +1,3 @@
-/*Be sure to change MESSAGES when you change the array, or bad things
-  will happen.*/
-
-/*Also, take note that robotfindskitten.c and configure.in 
-  currently have the version number hardcoded into them, and they 
-  should reflect MESSAGES. */
-
 /* Watch out for fenceposts.*/
 #define MESSAGES (sizeof messages / sizeof (char*))
 
-- 
1.7.9.5


>From 0506940c338d89646389aee96e4aebc9c02e63d5 Mon Sep 17 00:00:00 2001
From: "Eric S. Raymond" <esr at thyrsus.com>
Date: Thu, 25 Oct 2012 02:16:00 -0400
Subject: [PATCH 2/9] Magic-number reduction, and fix a compiler warning.

---
 src/robotfindskitten.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/robotfindskitten.c b/src/robotfindskitten.c
index 46907a1..f9865b2 100644
--- a/src/robotfindskitten.c
+++ b/src/robotfindskitten.c
@@ -78,13 +78,14 @@ static char* ver = VERSION;
 #define NETHACK_dr 'n'
 #define NETHACK_DR 'N'
 
-/*EMACS keycodes - Subtracting 64 makes it a control command*/
-#define EMACS_NEXT ('N' - 64)
-#define EMACS_PREVIOUS ('P' - 64)
-#define EMACS_BACKWARD ('B' - 64)
-#define EMACS_FORWARD ('F' - 64)
+/*EMACS keycodes */
+#define CTRL(key)	((key) & 0x1f)
+#define EMACS_NEXT CTRL('N')
+#define EMACS_PREVIOUS CTRL('P')
+#define EMACS_BACKWARD CTRL('B')
+#define EMACS_FORWARD CTRL('F')
+#define KEY_REDRAW CTRL('L')
 
-#define KEY_REDRAW ('L' - 64)
 /*Screen dimensions.*/
 #define X_MIN 0
 #define X_MAX (COLS - 1)
@@ -562,7 +563,7 @@ int main(int argc, char *argv[])
       num_bogus = atoi(argv[1]);
       if (num_bogus < 0 || num_bogus > MESSAGES)
 	{
-	  printf("Run-time parameter must be between 0 and %d.\n",MESSAGES);
+	  printf("Run-time parameter must be between 0 and %zd.\n",MESSAGES);
 	  exit(0);
 	}
     }
-- 
1.7.9.5


>From b0f8eaa5fb77d14d88bf67df8548ae3fbd025c43 Mon Sep 17 00:00:00 2001
From: "Eric S. Raymond" <esr at thyrsus.com>
Date: Thu, 25 Oct 2012 02:20:22 -0400
Subject: [PATCH 3/9] Remove unused macros.

---
 src/robotfindskitten.c |   10 ----------
 1 file changed, 10 deletions(-)

diff --git a/src/robotfindskitten.c b/src/robotfindskitten.c
index f9865b2..7e4ce4c 100644
--- a/src/robotfindskitten.c
+++ b/src/robotfindskitten.c
@@ -48,16 +48,6 @@ static char* ver = VERSION;
 #define ROBOT 0
 #define KITTEN 1
 
-/*Keycode constants*/
-#define DOWN_KEY 2
-#define UP_KEY 3
-#define LEFT_KEY 4
-#define RIGHT_KEY 5
-#define UP_LEFT_KEY 6
-#define UP_RIGHT_KEY 83
-#define DOWN_LEFT_KEY 104
-#define DOWN_RIGHT_KEY 82
-
 #define KEY_ESC 27
 
 /*Nethack keycodes*/
-- 
1.7.9.5


>From f91407cda70a26a4d15b03a414bfaacf266c5735 Mon Sep 17 00:00:00 2001
From: "Eric S. Raymond" <esr at thyrsus.com>
Date: Thu, 25 Oct 2012 02:30:14 -0400
Subject: [PATCH 4/9] Use ANSI booleans for code cleanliness.

---
 src/robotfindskitten.c |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/robotfindskitten.c b/src/robotfindskitten.c
index 7e4ce4c..1a45845 100644
--- a/src/robotfindskitten.c
+++ b/src/robotfindskitten.c
@@ -24,6 +24,8 @@ static char* ver = VERSION;
  *
  */
 
+#include <stdbool.h>
+
 #if HAVE_NCURSES_H
 #include <ncurses.h>
 #else
@@ -87,7 +89,7 @@ static char* ver = VERSION;
 #define randy() rand() % (Y_MAX-Y_MIN+1)+Y_MIN /*I'm feeling randy()!*/
 #define randchar() rand() % (126-'!'+1)+'!';
 #define randcolor() rand() % 6 + 1
-#define randbold() (rand() % 2 ? TRUE:FALSE)
+#define randbold() (rand() % 2 ? true:false)
 
 /*Row constants for the animation*/
 #define ADV_ROW 1
@@ -123,7 +125,7 @@ void play_game();
 void process_input(int);
 
 /*Helper functions*/
-int validchar(char);
+bool validchar(char);
 
 void play_animation(int);
 
@@ -303,16 +305,16 @@ RETSIGTYPE finish(int sig)
  *
  *****************************************************************************/
 
-int validchar(char a)
+bool validchar(char a)
 {
   switch(a)
     {
     case '#':
     case ' ':   
     case 127:
-      return 0;
+      return false;
     }
-  return 1;
+  return true;
 }
 
 void play_animation(int input)
@@ -392,7 +394,7 @@ void initialize_arrays()
   empty.x = -1;
   empty.y = -1;
   empty.color = 0;
-  empty.bold = FALSE;
+  empty.bold = false;
   empty.character = ' ';
   
   for (counter = 0; counter <= X_MAX; counter++)
@@ -418,9 +420,9 @@ void initialize_ncurses()
 {
   signal(SIGINT, finish);
   initscr();      /* initialize the curses library */
-  keypad(stdscr, TRUE);  /* enable keyboard mapping */
+  keypad(stdscr, true);  /* enable keyboard mapping */
   nonl();         /* tell curses not to do NL->CR/NL on output */
-  intrflush(stdscr, FALSE);
+  intrflush(stdscr, false);
   noecho();         /* don't echo characters */
   cbreak();         /* don't wait for enter before accepting input */
   
@@ -448,7 +450,7 @@ void initialize_robot()
 
   robot.character = '#';
   robot.color = 0;
-  robot.bold = FALSE;
+  robot.bold = false;
   screen[robot.x][robot.y] = ROBOT;
 }
 
-- 
1.7.9.5


>From 9834d1185e1cf2526350784fe9a52aac85956a7e Mon Sep 17 00:00:00 2001
From: "Eric S. Raymond" <esr at thyrsus.com>
Date: Thu, 25 Oct 2012 02:38:05 -0400
Subject: [PATCH 5/9] Code cleanup.  RETSIGTYPE is *long* obsolete.

---
 configure.in           |    5 -----
 src/robotfindskitten.c |    2 +-
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/configure.in b/configure.in
index 345a1fa..8801be7 100644
--- a/configure.in
+++ b/configure.in
@@ -18,9 +18,4 @@ AC_CHECK_HEADERS(ncurses.h,,
 	[AC_CHECK_HEADERS(curses.h,, 
 		AC_MSG_ERROR(Could not find ncurses headers!))])
 
-dnl Checks for typedefs, structures, and compiler characteristics.
-
-dnl Checks for library functions.
-AC_TYPE_SIGNAL
-
 AC_OUTPUT(Makefile src/Makefile doc/Makefile)
diff --git a/src/robotfindskitten.c b/src/robotfindskitten.c
index 1a45845..d4f359c 100644
--- a/src/robotfindskitten.c
+++ b/src/robotfindskitten.c
@@ -292,7 +292,7 @@ void process_input(int input)
 }
 
 /*finish is called upon signal or progam exit*/
-RETSIGTYPE finish(int sig)
+void finish(int sig)
 {
     endwin();
     printf("%c%c%c",27,'(','B'); /* Restore normal character set */
-- 
1.7.9.5


>From 6c6925124ad0e4b415d2b3d0c2ee27bfe2de45c0 Mon Sep 17 00:00:00 2001
From: "Eric S. Raymond" <esr at thyrsus.com>
Date: Thu, 25 Oct 2012 02:47:46 -0400
Subject: [PATCH 6/9] Remove an unused terminal-type dependency

---
 src/robotfindskitten.c |    6 ------
 1 file changed, 6 deletions(-)

diff --git a/src/robotfindskitten.c b/src/robotfindskitten.c
index d4f359c..320c596 100644
--- a/src/robotfindskitten.c
+++ b/src/robotfindskitten.c
@@ -295,7 +295,6 @@ void process_input(int input)
 void finish(int sig)
 {
     endwin();
-    printf("%c%c%c",27,'(','B'); /* Restore normal character set */
     exit(0);
 }
 
@@ -563,11 +562,6 @@ int main(int argc, char *argv[])
   /*Initialize the random number generator*/
   srand(time(0));
 
-  /* Set up the screen to use the IBM character set. ncurses still won't
-   cooperate with characters before '!', so we take care of that in the
-   randchar() macro. */
-   printf("%c%c%c",27,'(','U');
-
   initialize_ncurses();  
 
   initialize_arrays();
-- 
1.7.9.5


>From 2f09b21feb7c7243d8d76f101a8e2ba0f3f8f7c9 Mon Sep 17 00:00:00 2001
From: "Eric S. Raymond" <esr at thyrsus.com>
Date: Thu, 25 Oct 2012 02:58:25 -0400
Subject: [PATCH 8/9] More ANSIfication cleanup - use void in prototypes.

---
 src/robotfindskitten.c |   30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/robotfindskitten.c b/src/robotfindskitten.c
index 320c596..8f3868b 100644
--- a/src/robotfindskitten.c
+++ b/src/robotfindskitten.c
@@ -111,17 +111,17 @@ typedef struct
  */
 
 /*Initialization and setup functions*/
-void initialize_ncurses();
-void initialize_arrays();
-void initialize_robot();
-void initialize_kitten();
-void initialize_bogus();
-void initialize_screen();
-void instructions();
+void initialize_ncurses(void);
+void initialize_arrays(void);
+void initialize_robot(void);
+void initialize_kitten(void);
+void initialize_bogus(void);
+void initialize_screen(void);
+void instructions(void);
 static void finish(int sig);
 
 /*Game functions*/
-void play_game();
+void play_game(void);
 void process_input(int);
 
 /*Helper functions*/
@@ -355,7 +355,7 @@ void play_animation(int input)
  *
  *****************************************************************************/
 
-void instructions()
+void instructions(void)
 {
   char dummy;
 
@@ -376,7 +376,7 @@ void instructions()
   clear();
 }
 
-void initialize_arrays()
+void initialize_arrays(void)
 {
   int counter, counter2;
   screen_object empty;
@@ -415,7 +415,7 @@ void initialize_arrays()
 
 /*initialize_ncurses sets up ncurses for action. Much of this code 
  stolen from Raymond and Ben-Halim, "Writing Programs with NCURSES"*/
-void initialize_ncurses()
+void initialize_ncurses(void)
 {
   signal(SIGINT, finish);
   initscr();      /* initialize the curses library */
@@ -441,7 +441,7 @@ void initialize_ncurses()
 }
 
 /*initialize_robot initializes robot.*/
-void initialize_robot()
+void initialize_robot(void)
 {
   /*Assign a position to the player.*/
   robot.x = randx();
@@ -454,7 +454,7 @@ void initialize_robot()
 }
 
 /*initialize kitten, well, initializes kitten.*/
-void initialize_kitten()
+void initialize_kitten(void)
 {
   /*Assign the kitten a unique position.*/
   do
@@ -474,7 +474,7 @@ void initialize_kitten()
 }
 
 /*initialize_bogus initializes all non-kitten objects to be used in this run.*/
-void initialize_bogus()
+void initialize_bogus(void)
 {
   int counter, index;
   for (counter = 0; counter < num_bogus; counter++)
@@ -509,7 +509,7 @@ void initialize_bogus()
 }
 
 /*initialize_screen paints the screen.*/
-void initialize_screen()
+void initialize_screen(void)
 {
   int counter;
 
-- 
1.7.9.5


>From 257ccc6c79520bcd938a50cf65611e8d5cae8d23 Mon Sep 17 00:00:00 2001
From: "Eric S. Raymond" <esr at thyrsus.com>
Date: Thu, 25 Oct 2012 03:17:08 -0400
Subject: [PATCH 9/9] Objects for the new century.

---
 src/messages.h |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/messages.h b/src/messages.h
index 874b5ae..07c5926 100644
--- a/src/messages.h
+++ b/src/messages.h
@@ -410,5 +410,15 @@ static char* messages[] =
   "The intermission from a 1930s silent movie.",
   "It's an inverted billiard ball!",
   "The spectre of Sherlock Holmes wills you onwards.",
+  "A baby's arm, holding an apple.",
+  "An erroneous proof of the Goldbach Conjecture",
+  "Five pounds of flax.",
+  "The Luggage. Yes, that one.",
+  "A Bergenholm drive.",
+  "A left-handed smoke shifter.",
+  "A camera obscura.",
+  "A rhyton.  Right on!",
+  "A pigeon with a TCP/IP packet duct-taped to its leg."
+  "Blod.",
 
 };
-- 
1.7.9.5



----- End forwarded message -----

-- 
Peter A. H. Peterson
Graduate Student Researcher
Laboratory for Advanced Systems Research
University of California, Los Angeles


More information about the rfk-dev mailing list