|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T r
Length: 1547 (0x60b)
Types: TextFile
Names: »riddle.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Riddle/riddle.c«
/*_ riddle.c Tue Apr 1 1986 Written by: Walter Bright */
#include <stdio.h>
#include <signal.h>
main()
{ extern long time();
static char *msg[] = { "ha ","hah ","ho ","hee " };
int i,cntrlC();
printf("Welcome to riddle, an AI demonstration program.\n");
printf("riddle will attempt to solve one line riddles.\n");
printf("\nInitializing...\n");
delay(2);
srand(time((long *) NULL));
printf("Tell me a riddle (one line): ");
while (1)
{
fflush(stdout);
getline();
signal(SIGINT,cntrlC);
delay(rand() % 3 + 1);
printf("Hmmmmm.....\n");
delay(rand() % 10 + 3);
printf("Gee, that's a tough one.\n");
delay(rand() % 10 + 4);
signal(SIGINT,SIG_DFL);
printf("I give up. What's the answer? ");
fflush(stdout);
getline();
printf("hah ");
i = rand() % 15 + 5;
while (i--)
{ printf(msg[rand() % (sizeof(msg)/sizeof(msg[0]))]);
fflush(stdout);
delay(1);
}
printf("\nThat was a good one (sniff).\n");
printf("Tell me another one: ");
}
}
getline()
{ char buffer[100];
fgets(buffer,sizeof(buffer),stdin);
}
delay(secs)
{
#ifdef DLC
long starttime;
time(&starttime);
while (time((long *) NULL) <= starttime + secs)
;
#else
sleep(secs);
#endif
}
cntrlC()
{ static char *msg[] =
{ "Hang on a sec, I've almost got it.",
"I said just a sec.",
"Give me a chance, will ya? The machine's a little slow today.",
"Buzz off, I'm artificially thinking.",
"Yer mother wears army boots",
"Row well, and live",
""
};
static int i = 0;
printf("%s\n",msg[i]);
if (i < 5) i++;
}