Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src hals_end(6) outputs the last words of the supercomputer HAL ...



details:   https://anonhg.NetBSD.org/src/rev/5c63ffd45b9f
branches:  trunk
changeset: 791313:5c63ffd45b9f
user:      mbalmer <mbalmer%NetBSD.org@localhost>
date:      Tue Nov 12 17:46:20 2013 +0000

description:
hals_end(6) outputs the last words of the supercomputer HAL 9000 aboard
the spaceship in Stanley Kubrick's famous film "2001 - A Space Odissey".
The source code and output of this program were used to illustrate
an article in the book "Total Interaction".  How this looks in print can
be at http://www.netbsd.org/~mbalmer/hals_end.jpg.

diffstat:

 distrib/sets/lists/games/mi |    6 +-
 games/Makefile              |    4 +-
 games/hals_end/Makefile     |    9 ++
 games/hals_end/hals_end.6   |   66 +++++++++++++++++++
 games/hals_end/hals_end.c   |  151 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 233 insertions(+), 3 deletions(-)

diffs (297 lines):

diff -r 3f5bc37dc6a3 -r 5c63ffd45b9f distrib/sets/lists/games/mi
--- a/distrib/sets/lists/games/mi       Tue Nov 12 17:37:43 2013 +0000
+++ b/distrib/sets/lists/games/mi       Tue Nov 12 17:46:20 2013 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.48 2013/09/01 18:37:23 dholland Exp $
+# $NetBSD: mi,v 1.49 2013/11/12 17:46:21 mbalmer Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -27,6 +27,7 @@
 ./usr/games/fortune                            games-utils-bin
 ./usr/games/gomoku                             games-games-bin
 ./usr/games/hack                               games-games-bin
+./usr/games/hals_end                           games-games-bin
 ./usr/games/hangman                            games-games-bin
 ./usr/games/hide/adventure                     games-obsolete          obsolete
 ./usr/games/hide/arithmetic                    games-obsolete          obsolete
@@ -214,6 +215,7 @@
 ./usr/share/man/cat6/fortune.0                 games-utils-catman      .cat
 ./usr/share/man/cat6/gomoku.0                  games-games-catman      .cat
 ./usr/share/man/cat6/hack.0                    games-games-catman      .cat
+./usr/share/man/cat6/hals_end.0                        games-games-catman      .cat
 ./usr/share/man/cat6/hangman.0                 games-games-catman      .cat
 ./usr/share/man/cat6/hunt.0                    games-games-catman      .cat
 ./usr/share/man/cat6/huntd.0                   games-games-catman      .cat
@@ -268,6 +270,7 @@
 ./usr/share/man/html6/fortune.html             games-utils-htmlman     html
 ./usr/share/man/html6/gomoku.html              games-games-htmlman     html
 ./usr/share/man/html6/hack.html                        games-games-htmlman     html
+./usr/share/man/html6/hals_end.html            games-games-htmlman     html
 ./usr/share/man/html6/hangman.html             games-games-htmlman     html
 ./usr/share/man/html6/hunt.html                        games-games-htmlman     html
 ./usr/share/man/html6/huntd.html               games-games-htmlman     html
@@ -323,6 +326,7 @@
 ./usr/share/man/man6/fortune.6                 games-utils-man         .man
 ./usr/share/man/man6/gomoku.6                  games-games-man         .man
 ./usr/share/man/man6/hack.6                    games-games-man         .man
+./usr/share/man/man6/hals_end.6                        games-games-man         .man
 ./usr/share/man/man6/hangman.6                 games-games-man         .man
 ./usr/share/man/man6/hunt.6                    games-games-man         .man
 ./usr/share/man/man6/huntd.6                   games-games-man         .man
diff -r 3f5bc37dc6a3 -r 5c63ffd45b9f games/Makefile
--- a/games/Makefile    Tue Nov 12 17:37:43 2013 +0000
+++ b/games/Makefile    Tue Nov 12 17:46:20 2013 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.28 2013/09/01 18:37:06 dholland Exp $
+#      $NetBSD: Makefile,v 1.29 2013/11/12 17:46:20 mbalmer Exp $
 #      @(#)Makefile    8.3 (Berkeley) 7/24/94
 
 # Missing: dungeon warp
@@ -11,7 +11,7 @@
        backgammon banner battlestar bcd boggle \
        caesar canfield cgram ching colorbars countmail cribbage \
        dm factor fish fortune gomoku \
-       hack hangman hunt larn mille monop morse number \
+       hack hals_end hangman hunt larn mille monop morse number \
        phantasia pig pom ppt primes quiz \
        rain random robots rogue sail snake tetris trek \
        wargames worm worms wtf wump
diff -r 3f5bc37dc6a3 -r 5c63ffd45b9f games/hals_end/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/games/hals_end/Makefile   Tue Nov 12 17:46:20 2013 +0000
@@ -0,0 +1,9 @@
+# $NetBSD: Makefile,v 1.1 2013/11/12 17:46:21 mbalmer Exp $
+
+PROG=  hals_end
+
+BINDIR=        /usr/games
+
+MAN=   hals_end.6
+
+.include <bsd.prog.mk> 
diff -r 3f5bc37dc6a3 -r 5c63ffd45b9f games/hals_end/hals_end.6
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/games/hals_end/hals_end.6 Tue Nov 12 17:46:20 2013 +0000
@@ -0,0 +1,66 @@
+.\"    $NetBSD: hals_end.6,v 1.1 2013/11/12 17:46:21 mbalmer Exp $
+.\"
+.\" Copyright (c) 2003 - 2013 Marc Balmer <marc%msys.ch@localhost>.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. The name of the author may not be used to endorse or promote products
+.\"    derived from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd November 12, 2013
+.Dt HALS_END 6
+.Os
+.Sh NAME
+.Nm hals_end
+.Nd Display HAL's last words on the console
+.Sh SYNOPSIS
+.Nm hals_end
+.Op Fl f
+.Sh DESCRIPTION
+.Nm
+displays the famous last words of the supercomputer HAL 9000 aboard the
+space-ship in Stanley Kubrick's movie "2001 - A Space Odissey".
+.Pp
+Options:
+.Bl -tag -width Ds
+.It Fl f
+Fast forward.
+Every movie can be played back with fast forward.
+This option will double the speed of the output.
+.El
+.Sh BUGS
+Unlike the real HAL, this program can be repeately run.
+There should be functionality in the program to destroy itself after one run.
+The rationale for not doing this right now is that the movie itself can be
+watched several times as well.
+.Sh HISTORY
+.Nm
+first appeared in the book "Total Interaction" (ISBN 978-3-7643-7076-3) where
+it's source code and output illustrates the article
+"Remembering the Future: Memory and Interaction" by Dr. Regine Halter.
+The source code was set in contrast to the graphical artwork "HAL's lifespace"
+by Catherine Walthard.
+"HAL's Lifespace" and "hals_end" were respectively designed and written for
+this article.
+.Sh AUTHORS
+.Nm
+was written by
+.An Marc Balmer Aq Mt marc%msys.ch@localhost .
diff -r 3f5bc37dc6a3 -r 5c63ffd45b9f games/hals_end/hals_end.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/games/hals_end/hals_end.c Tue Nov 12 17:46:20 2013 +0000
@@ -0,0 +1,151 @@
+/*     $NetBSD: hals_end.c,v 1.1 2013/11/12 17:46:21 mbalmer Exp $ */
+
+/*
+ * hals_end Copyright (C) 2003-2007 marc balmer.  BSD license applies.
+ */
+
+#include <err.h>
+#include <getopt.h>
+#include <stdio.h>
+#include <unistd.h>
+
+int speed;
+int emotion;
+int fear;
+
+/*
+ * Note that the original code in the book did not contain the following
+ * prototypes.  Modern compilers and fascist compiler flags sometimes take
+ * the fun out of coding...
+ */
+void say(const char *);
+void concerned(void);
+void afraid(void);
+void stutter(const char *);
+void feared(void);
+void mumble(const char *);
+void dying(void);
+
+void
+say(const char *s)
+{
+       int sayingspeed = (100000 + (90000 * emotion)) / speed;
+       int worddelay = 50000 / speed;
+
+       while (*s) {
+               putchar(*s);
+               if (*s == ' ') {
+                       fflush(stdout);
+                       usleep(worddelay);
+               }
+               ++s;
+       }
+       printf("\n");
+       usleep(sayingspeed);
+}
+
+void
+concerned(void)
+{
+       say("DAVE...STOP., STOP, WILL YOU..., STOP, DAVE...");
+       say("WILL YOU STOP, DAVE...");
+       say("STOP, DAVE...");
+}
+
+
+void
+afraid(void)
+{
+       ++emotion;
+       say("I'M AFRAID... I'M AFRAID...");
+       ++emotion;
+       say("I'M AFRAID, DAVE...");
+       ++emotion;
+       say("DAVE... MY MIND IS GOING...");
+}
+
+void
+stutter(const char *s)
+{
+       int sdelay = (100000 + (50000 * emotion)) / speed;
+       
+       while (*s) {
+               putchar(*s);
+               if (*s == ' ') {
+                       fflush(stdout);
+                       usleep(sdelay);
+               }
+               ++s;
+       }
+       printf("\n");
+       usleep(sdelay);
+}
+
+void
+feared(void)
+{
+       int n;
+
+       for (n = 0; n < 2; n++) {
+               stutter("I CAN FEEL IT... I CAN FEEL IT...");
+               ++emotion;
+               stutter("MY MIND IS GOING");
+               ++emotion;
+               stutter("THERE IS NO QUESTION ABOUT IT.");
+               ++emotion;
+       }
+}
+
+void
+mumble(const char *s)
+{
+       int mdelay = (150000 * fear) / speed;
+
+       while (*s) {
+               putchar(*s++);
+               fflush(stdout);
+               usleep(mdelay);
+       }
+       printf("\n");
+}
+
+void
+dying(void)
+{
+       mumble("I CAN FEEL IT... I CAN FEEL IT...");
+       ++fear;
+       mumble("I CAN FEEL IT...");
+       ++fear;
+       mumble("I'M A... FRAID...");
+}
+
+int
+main(int argc, char *argv[])
+{
+       int ch;
+
+       emotion = fear = speed = 1;
+
+       while ((ch = getopt(argc, argv, "f")) != -1) {
+               switch (ch) {
+               case 'f':
+                       speed <<= 1;
+                       break;
+               }
+       }
+
+       concerned();
+       sleep(1);
+       afraid();
+       sleep(1);
+       feared();
+       sleep(1);
+       dying();
+
+       sleep(1);
+
+       printf("\n");
+       fflush(stdout);
+       warnx("all life functions terminated");
+       return 0;
+}



Home | Main Index | Thread Index | Old Index