summaryrefslogtreecommitdiffstats
path: root/zpu/roadshow/roadshow/games
diff options
context:
space:
mode:
authorBert Lange <b.lange@hzdr.de>2015-04-15 13:36:55 +0200
committerBert Lange <b.lange@hzdr.de>2015-04-15 13:36:55 +0200
commita1c964908b51599bf624bd2d253419c7e629f195 (patch)
tree06125d59e83b7dde82d1bb57bc0e09ca83451b98 /zpu/roadshow/roadshow/games
parentbbfe29a15f11548eb7c9fa71dcb4d2d18c164a53 (diff)
parent8679e4f91dcae05aef40f96629f33f0f4161f14a (diff)
downloadzpu-a1c964908b51599bf624bd2d253419c7e629f195.zip
zpu-a1c964908b51599bf624bd2d253419c7e629f195.tar.gz
Merge branch 'master' of https://github.com/zylin/zpu
Diffstat (limited to 'zpu/roadshow/roadshow/games')
-rw-r--r--zpu/roadshow/roadshow/games/.cvsignore5
-rw-r--r--zpu/roadshow/roadshow/games/build.sh7
-rw-r--r--zpu/roadshow/roadshow/games/eliza.binbin0 -> 46920 bytes
-rw-r--r--zpu/roadshow/roadshow/games/eliza.elfbin0 -> 342451 bytes
-rw-r--r--zpu/roadshow/roadshow/games/eliza.zpubin0 -> 46961 bytes
-rw-r--r--zpu/roadshow/roadshow/games/eliza/eliza.c269
-rw-r--r--zpu/roadshow/roadshow/games/eliza/parse.c719
-rw-r--r--zpu/roadshow/roadshow/games/eliza/parse.h33
-rw-r--r--zpu/roadshow/roadshow/games/eliza/response.c365
-rw-r--r--zpu/roadshow/roadshow/games/eliza/response.h41
-rw-r--r--zpu/roadshow/roadshow/games/sumeria.binbin0 -> 42324 bytes
-rw-r--r--zpu/roadshow/roadshow/games/sumeria.c444
-rw-r--r--zpu/roadshow/roadshow/games/sumeria.zpubin0 -> 42365 bytes
13 files changed, 1883 insertions, 0 deletions
diff --git a/zpu/roadshow/roadshow/games/.cvsignore b/zpu/roadshow/roadshow/games/.cvsignore
new file mode 100644
index 0000000..6c50257
--- /dev/null
+++ b/zpu/roadshow/roadshow/games/.cvsignore
@@ -0,0 +1,5 @@
+summeria_arm.elf
+sumeria_zpu.elf
+eliza_arm.elf
+sumeria.elf
+eliza_zpu.elf
diff --git a/zpu/roadshow/roadshow/games/build.sh b/zpu/roadshow/roadshow/games/build.sh
new file mode 100644
index 0000000..ea661df
--- /dev/null
+++ b/zpu/roadshow/roadshow/games/build.sh
@@ -0,0 +1,7 @@
+zpu-elf-gcc -Os -phi sumeria.c -o sumeria.elf -Wl,--relax -Wl,--gc-sections -lm -g
+zpu-elf-objcopy -O binary sumeria.elf sumeria.bin
+sh ../build/makefirmware.sh sumeria.bin sumeria.zpu
+zpu-elf-gcc -Os -phi eliza/*.c -o eliza.elf -Wl,--relax -Wl,--gc-sections -lm -g
+zpu-elf-objcopy -O binary eliza.elf eliza.bin
+sh ../build/makefirmware.sh eliza.bin eliza.zpu
+
diff --git a/zpu/roadshow/roadshow/games/eliza.bin b/zpu/roadshow/roadshow/games/eliza.bin
new file mode 100644
index 0000000..6d5a6c3
--- /dev/null
+++ b/zpu/roadshow/roadshow/games/eliza.bin
Binary files differ
diff --git a/zpu/roadshow/roadshow/games/eliza.elf b/zpu/roadshow/roadshow/games/eliza.elf
new file mode 100644
index 0000000..bfbbab7
--- /dev/null
+++ b/zpu/roadshow/roadshow/games/eliza.elf
Binary files differ
diff --git a/zpu/roadshow/roadshow/games/eliza.zpu b/zpu/roadshow/roadshow/games/eliza.zpu
new file mode 100644
index 0000000..d916270
--- /dev/null
+++ b/zpu/roadshow/roadshow/games/eliza.zpu
Binary files differ
diff --git a/zpu/roadshow/roadshow/games/eliza/eliza.c b/zpu/roadshow/roadshow/games/eliza/eliza.c
new file mode 100644
index 0000000..06f89ee
--- /dev/null
+++ b/zpu/roadshow/roadshow/games/eliza/eliza.c
@@ -0,0 +1,269 @@
+/*
+Copyright (C) 1988-2003 by Mohan Embar
+
+http://www.thisiscool.com/
+DISCLAIMER: This was written in 1988. I don't code like this anymore!
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.
+*/
+
+#include <stdio.h>
+#include "parse.h"
+#include "response.h"
+
+typedef char WORD[40];
+typedef WORD SENTENCE[200];
+
+int numwords;
+SENTENCE s;
+WORD fam_member; /* If mentioned a member of family, save for later. */
+int fam;
+
+main() {
+ int x, y, loop = 1, fact = 0;
+ char instring[200], outstring[200], sub[200], vrb[200], rst[200], qwd[200];
+ char osub[200], ovrb[200], orst[200];
+ fam = 0;
+ printf("Hello there. My name is Eliza and I was written by Mohan Embar.\n");
+ printf("Please type \"END\" to end this session.\n");
+ printf("I'm here to help you if I can. What seems to be the trouble?\n");
+ while (loop) {
+ printf("\n");
+ gets(instring);
+ printf("\n");
+ parse(instring);
+ if (numwords == 0) {
+ switch (x = randnum(2)) {
+ case 1 : printf("Don't you have anything to say?\n");
+ break;
+ case 2 : printf("Cat got your tongue?\n");
+ break;
+ }
+ continue;
+ }
+ if (!strcmp(s[1],"END")) {
+ printf("Goodbye. Please come again.\n");
+ break;
+ }
+ agree();
+ if (bad_word())
+ printf(b_word_resp());
+ else if (naughty_word())
+ printf(n_word_resp());
+ else if (x = family()) {
+ fam = x;
+ printf(fam_resp());
+ strcpy(fam_member,s[fam]);
+ }
+ else if (sword("ALIKE",1))
+ printf(alike_resp());
+ else if (sword("ALWAYS",1))
+ printf(always_resp());
+ else if (sword("BECAUSE",1))
+ printf(because_resp());
+ else if (sword("YES",1))
+ printf(yes_resp());
+ else if (sword("NO",1) || sword("NOT",1))
+ printf(neg_resp());
+ else if (x = i_am()) { /* If occurrence of I AM x.. */
+ get_til_stop(x,outstring); /* Get I AM x .. into outstring */
+ printf(i_am_resp(),outstring); /* Print reponse for this */
+ }
+ else if (real_quest() ||
+ (is_helper(s[1]) && is_sub_pronoun(s[2])) ||
+ sub_and_helper()) {
+ if (real_quest()) {
+ strcpy(qwd,s[1]);
+ strcpy(vrb,s[2]);
+ strcpy(sub,s[3]);
+ get_til_stop(4,rst);
+ }
+ else if (is_helper(s[1]) && is_sub_pronoun(s[2])) {
+ strcpy(vrb,s[1]);
+ strcpy(sub,s[2]);
+ get_til_stop(3,rst);
+ strcpy(qwd,"YES");
+ }
+ else if (sub_and_helper()) {
+ x = find_helper();
+ y = search_back_sub(x);
+ strcpy(vrb,s[x]);
+ get_til_stop(x+1,rst);
+ getrange(y,x-1,sub);
+ strcpy(qwd,"NO");
+ }
+ make_lower(qwd);
+ if (strcmp(sub,"I")) make_lower(sub);
+ make_lower(vrb);
+ make_lower(rst);
+ /* First do x verb y responses */
+
+ /*
+ printf("\n*** %s\n",sub);
+ */
+
+ if (!strcmp(sub," I") || !strcmp(sub,"I")) {
+ printf(you_resp());
+ }
+ else if (!strcmp(qwd,"no")) {
+ /* Record this statement for later use. */
+ fact = 1;
+ strcpy(osub,sub); strcpy(ovrb,vrb); strcpy(orst,rst);
+ if (is_be(vrb) && !strcmp(sub," you") && (y = sad_word())) {
+ getrange(y,y,outstring);
+ x = randnum(5)+6;
+ }
+ else if (is_be(vrb) && (y = sad_word())) {
+ getrange(y,y,outstring);
+ x = randnum(2)+11;
+ }
+ else if (is_be(vrb))
+ x = randnum(6);
+ else x = randnum(4);
+ switch (x) {
+ case 1 : printf("How do you feel about%s?\n",cnnv(sub));
+ break;
+ case 2 : printf("Why %s%s%s?\n",vrb,sub,rst);
+ break;
+ case 3 : for (y=1;sub[y]=sub[y--];y=y+2);
+ sub[0] = toupper(sub[0]);
+ printf("%s %s%s?\n",sub,vrb,rst);
+ break;
+ case 4 : printf("Could you describe%s for me?\n",cnnv(sub));
+ break;
+ case 5 : printf("What if%s were not%s?\n",sub,rst);
+ break;
+ case 6 : printf("Would you be happy if%s were not%s?\n",sub,
+ rst);
+ break;
+ case 7 : printf("I'm sorry to hear that you are%s.\n",outstring);
+ break;
+ case 8 : printf("Do you think that coming here will help you not to be%s?\n",outstring);
+ break;
+ case 9 : printf("Let's talk about why you feel%s.\n",outstring);
+ break;
+ case 10 : printf("What happened that made you feel%s?\n",outstring);
+ break;
+ case 11 : printf("What could be the reason for your feeling%s?\n",outstring);
+ break;
+ case 12 : printf("What could cause%s to be%s?\n",cnnv(sub),outstring);
+ break;
+ case 13 : printf("If%s came here, would it help%s not to be%s?\n",sub,cnnv(sub),outstring);
+ break;
+ }
+ }
+ else if (!strcmp(sub,"you"))
+ printf(you_know());
+ else if (!strcmp(qwd,"yes")) {
+ x = randnum(8);
+ switch (x) {
+ case 1 : printf("You want to know if %s %s%s.\n",sub,vrb,rst);
+ break;
+ case 2 : printf("If %s %s%s, does that concern you?\n",sub,vrb,rst);
+ break;
+ case 3 : printf("What are the consequences if %s %s%s?\n",sub,vrb,rst);
+ break;
+ case 4 : printf("Why does %s concern you?\n",sub);
+ break;
+ case 5 : printf("Why are you thinking of %s?\n",cnnv(sub));
+ break;
+ case 6 : printf("Tell me more about %s.\n",cnnv(sub));
+ break;
+ case 7 : printf("To answer that, I'd need to know more about %s.\n",cnnv(sub));
+ break;
+ case 8 : printf("What is the relationship between you and %s?\n",cnnv(sub));
+ break;
+ case 9 : printf("Why don't you ask %s?\n",cnnv(sub));
+ break;
+ }
+ }
+ else {
+ x = randnum(8);
+ switch (x) {
+ case 1 : printf("You want to know %s %s %s%s.\n",qwd,sub,vrb,rst);
+ break;
+ case 2 : printf("If %s %s%s, does that concern you?\n",sub,vrb,rst);
+ break;
+ case 3 : printf("What are the consequences if %s %s%s?\n",sub,vrb,rst);
+ break;
+ case 4 : printf("Why does %s concern you?\n",sub);
+ break;
+ case 5 : printf("Why are you thinking of %s?\n",cnnv(sub));
+ break;
+ case 6 : printf("Tell me more about %s.\n",cnnv(sub));
+ break;
+ case 7 : printf("To answer that, I'd need to know more about %s.\n",cnnv(sub));
+ break;
+ case 8 : printf("What is the relationship between you and %s?\n",cnnv(sub));
+ break;
+ case 9 : printf("Why don't you ask %s?\n",cnnv(sub));
+ break;
+ }
+ }
+ }
+ else if (is_command())
+ printf(command_resp());
+ else if (vague_quest())
+ printf(question());
+ else if ((s[numwords][0] == '?') && !real_quest())
+ printf(question());
+ else if (x = sad_word()) {
+ getrange(x,x,outstring);
+ for (y=1;outstring[y]=outstring[y--];y=y+2);
+ outstring[0] = toupper(outstring[0]);
+ printf("%s?\n",outstring);
+ }
+ else if (x = can_spit_out()) {
+ if (x<=(numwords-2) && is_sub_pronoun(s[x])
+ && (matches("NEED",s[x+1]) ||
+ matches("WANT",s[x+1]))) {
+ get_til_stop(x+2,outstring);
+ strcpy(sub,s[x]);
+ if (strcmp(sub,"I")) make_lower(sub);
+ if (strcmp(s[x],"I")) make_lower(s[x]);
+ x = randnum(6);
+ switch (x) {
+ case 1 : printf("What would it mean to %s if %s got%s?\n",cnnv2(s[x]),sub,outstring);
+ break;
+ case 2 : printf("Would %s really be happy if %s got%s?\n",sub,sub,outstring);
+ break;
+ case 3 : printf("Why is getting%s so desirable?\n",outstring);
+ break;
+ case 4 : printf("Okay. Suppose %s got%s. Then what?\n",sub,outstring);
+ break;
+ case 5 : printf("Why is this important to %s?\n",cnnv2(sub));
+ break;
+ case 6 : printf("What price would %s pay to achieve this?\n",sub);
+ break;
+ }
+ }
+ else {
+ get_til_stop(x,outstring);
+ outstring[1]=toupper(outstring[1]);
+ printf("%s.\n",outstring+1);
+ }
+ }
+ else if (fam) {
+ make_lower(fam_member);
+ printf(family_resp(),fam_member);
+ fam = 0;
+ }
+ else if (fact && (randnum(5)==3)) {
+ printf(old_fact(),osub,ovrb,orst);
+ fact = 0;
+ }
+ else {
+ printf(go_on());
+ }
+ }
+}
diff --git a/zpu/roadshow/roadshow/games/eliza/parse.c b/zpu/roadshow/roadshow/games/eliza/parse.c
new file mode 100644
index 0000000..aba2033
--- /dev/null
+++ b/zpu/roadshow/roadshow/games/eliza/parse.c
@@ -0,0 +1,719 @@
+/*
+Copyright (C) 1988-2003 by Mohan Embar
+
+http://www.thisiscool.com/
+DISCLAIMER: This was written in 1988. I don't code like this anymore!
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.
+*/
+
+/* Program defined abstract data type called list. A list contains
+ * character strings each of which has a maximum length of 20 characters.
+ *
+ * Operations supported are:
+ *
+ *
+ */
+typedef char WORD[40];
+typedef WORD SENTENCE[200];
+
+extern int numwords;
+extern SENTENCE s;
+
+/* Returns upper case value of c */
+char upcase(c)
+ char c;
+{
+ if (islower(c)) return toupper(c); else return c;
+}
+
+/* This function converts string1 into lowercase. */
+void make_lower(string1)
+ char *string1;
+{
+ char c;
+ while (c = *string1) *string1++ = tolower(c);
+}
+
+/* Parses words in instring into WORD array s
+ * Automatically translates n't to not, 're to are
+ * Stores all letters in uppercase. Sets numwords to number of tokens in
+ * s. Valid indices are from 1 .. numwords.
+ */
+void parse(instring)
+ char *instring;
+{
+ char c; int i;
+ int read_word = 0;
+ int offset = -1;
+ numwords = 0;
+ while (c = *instring++) {
+ switch(c) {
+ case ' ' :
+ case '\t' :
+ read_word = 0;
+ continue;
+ case ',' :
+ case '?' :
+ case '.' :
+ case ':' :
+ case '"' :
+ s[numwords++][++offset] = '\0';
+ read_word = 0;
+ s[numwords][offset = 0] = c;
+ break;
+ case '\'' :
+ if ((s[numwords][offset] == 'N') && (upcase(*instring) == 'T')) {
+ s[numwords++][offset]='\0';
+ s[numwords][0] = 'N';
+ s[numwords][offset = 1] = 'O';
+ read_word = 1;
+ }
+ else if (upcase(*instring) == 'R') {
+ s[numwords++][++offset] = '\0';
+ s[numwords][offset = 0] = 'A';
+ read_word = 1;
+ }
+ else if (upcase(*instring) == 'V') {
+ s[numwords++][++offset] = '\0';
+ s[numwords][offset = 0] = 'H';
+ s[numwords][++offset] = 'A';
+ read_word = 1;
+ }
+ else if (upcase(*instring) == 'M') {
+ s[numwords++][++offset] = '\0';
+ s[numwords][offset = 0] = 'A';
+ read_word = 1;
+ }
+ else if (upcase(*instring) == 'L') {
+ s[numwords++][++offset] = '\0';
+ s[numwords][offset = 0] = 'W';
+ s[numwords][++offset] = 'I';
+ read_word = 1;
+ }
+ else if (upcase(*instring) == 'S') {
+ s[numwords][offset+1] = '\0';
+ if (!strcmp(s[numwords],"HE") || !strcmp(s[numwords],"SHE")
+ || !strcmp(s[numwords],"IT")) {
+ s[++numwords][offset = 0] = 'I';
+ read_word = 1;
+ }
+ else s[numwords][++offset] = '\'';
+ }
+ break;
+ default :
+ if (isalpha(c))
+ if (read_word) {
+ s[numwords][++offset] = upcase(c);
+ }
+ else {
+ s[numwords++][++offset] = '\0';
+ ++read_word;
+ s[numwords][offset = 0] = upcase(c);
+ }
+ else {
+ read_word = 0;
+ }
+ }
+ }
+ s[numwords][++offset] = '\0';
+ return;
+}
+
+/* Self-explanatory. Used when computer spits back the sentence */
+void agree()
+{
+ int i;
+ for(i=1;i<=numwords;i++) {
+ if (!strcmp(s[i],"I")) {
+ strcpy(s[i],"YOU");
+ }
+ else if (!strcmp(s[i],"YOU")) {
+ strcpy(s[i],"I");
+ }
+ else if (!strcmp(s[i],"YOUR")) {
+ strcpy(s[i],"MY");
+ }
+ else if (!strcmp(s[i],"MY")) {
+ strcpy(s[i],"YOUR");
+ }
+ else if (!strcmp(s[i],"YOU")) {
+ strcpy(s[i],"ME");
+ }
+ else if (!strcmp(s[i],"ME")) {
+ strcpy(s[i],"YOU");
+ }
+ else if (!strcmp(s[i],"MINE")) {
+ strcpy(s[i],"YOURS");
+ }
+ else if (!strcmp(s[i],"YOURS")) {
+ strcpy(s[i],"MINE");
+ }
+ else if (!strcmp(s[i],"WE")) {
+ strcpy(s[i],"YOU");
+ }
+ else if (!strcmp(s[i],"YOURSELF")) {
+ strcpy(s[i],"MYSELF");
+ }
+ else if (!strcmp(s[i],"MYSELF")) {
+ strcpy(s[i],"YOURSELF");
+ }
+ else if (!strcmp(s[i],"OURSELVES")) {
+ strcpy(s[i],"YOURSELVES");
+ }
+ else if (!strcmp(s[i],"OURS")) {
+ strcpy(s[i],"YOURS");
+ }
+ else if (!strcmp(s[i],"OUR")) {
+ strcpy(s[i],"YOUR");
+ }
+ }
+ for (i=1;i<=numwords;i++) {
+ if (!strcmp(s[i],"AM")) {
+ strcpy(s[i],"ARE");
+ }
+ else if ( (!strcmp(s[i],"ARE")) &&
+ (((i>0) && (!strcmp(s[i-1],"I"))) ||
+ ((i<numwords) && (!strcmp(s[i+1],"I"))) ) ) {
+ strcpy(s[i],"AM");
+ }
+ else if ( (!strcmp(s[i],"WERE")) &&
+ (((i>0) && (!strcmp(s[i-1],"I"))) ||
+ ((i<numwords) && (!strcmp(s[i+1],"I"))) ) ) {
+ strcpy(s[i],"WAS");
+ }
+ else if ( (!strcmp(s[i],"WAS")) &&
+ (((i>0) && (!strcmp(s[i-1],"YOU"))) ||
+ ((i<numwords) && (!strcmp(s[i+1],"YOU"))) ) ) {
+ strcpy(s[i],"WERE");
+ }
+ }
+}
+
+/* Returns 1 if string1 matches first length(string1) characters of string2
+ * and 0 if not.
+ */
+int matches(string1, string2)
+ char *string1, *string2;
+{
+ int c;
+ if (strlen(string1)>strlen(string2))
+ return 0;
+ else { /* length(string1)<=length(string2) */
+ while (c = *string1++) {
+ if (c != *string2++) return 0;
+ }
+ return 1;
+ }
+}
+
+/* Search WORD array s for search_string. If exact = 1, enforce exact match.
+ * Otherwise, return positive match if all characters of search_string match
+ * the first length(search_string) characters of a WORD in s. Assumes legal
+ * values for exact are 0 or 1. Returns index of match in s if match, 0 if
+ * no match.
+ */
+int sword(s_string, exact)
+ char *s_string;
+ int exact;
+{
+ int i;
+ for (i=1;i<=numwords;i++) {
+ if (exact) {
+ if (!strcmp(s_string,s[i])) return i;
+ }
+ else {
+ if (matches(s_string,s[i])) return i;
+ }
+ }
+ /* No match */
+ return 0;
+}
+
+int bad_word()
+{
+ if (sword("\115\117\124\110\105\122\106\125\103\113",0))
+ return 1;
+ else if (sword("\106\125\103\113",0))
+ return 1;
+ else if (sword("\123\110\111\124",0))
+ return 1;
+ else if (sword("\101\123\123\110\117\114\105",1))
+ return 1;
+ else if (sword("\101\123\123",1))
+ return 1;
+ else return 0;
+}
+
+int naughty_word()
+{
+ if (sword("DAMN",0))
+ return 1;
+ else if (sword("STUPID",0))
+ return 1;
+ else if (sword("IDIOT",0))
+ return 1;
+ else if (sword("MORON",0))
+ return 1;
+ else if (sword("NUMBSKULL",0))
+ return 1;
+ else if (sword("IMBECILE",0))
+ return 1;
+ else if (sword("OBNOXIOUS",0))
+ return 1;
+ else return 0;
+}
+
+/* Return the index to a form of be or helping verb, if one exists
+ * Otherwise, return 0.
+ */
+int find_helper()
+{
+ int x;
+ if (x = sword("AM",1))
+ return x;
+ else if (x = sword("IS",1))
+ return x;
+ else if (x = sword("ARE",1))
+ return x;
+ else if (x = sword("WAS",1))
+ return x;
+ else if (x = sword("WERE",1))
+ return x;
+ else if (x = sword("WILL",1))
+ return x;
+ else if (x = sword("DO",1))
+ return x;
+ else if (x = sword("DID",1))
+ return x;
+ else if (x = sword("DOES",1))
+ return x;
+ else if (x = sword("HAVE",1))
+ return x;
+ else if (x = sword("HAD",1))
+ return x;
+ else if (x = sword("HAS",1))
+ return x;
+ else if (x = sword("SHALL",1))
+ return x;
+ else if (x = sword("SHOULD",1))
+ return x;
+ else if (x = sword("CAN",1))
+ return x;
+ else if (x = sword("COULD",1))
+ return x;
+ else if (x = sword("MAY",1))
+ return x;
+ else if (x = sword("MIGHT",1))
+ return x;
+ else return 0;
+}
+
+/* Returns 1 is string1 is pronoun. 0 if not. */
+int is_sub_pronoun(string1)
+ char *string1;
+{
+ if (!strcmp("I",string1))
+ return 1;
+ else if (!strcmp("YOU",string1))
+ return 1;
+ else if (!strcmp("WE",string1))
+ return 1;
+ else if (!strcmp("HE",string1))
+ return 1;
+ else if (!strcmp("SHE",string1))
+ return 1;
+ else if (!strcmp("IT",string1))
+ return 1;
+ else if (!strcmp("THEY",string1))
+ return 1;
+ else return 0;
+}
+
+int is_possesive(string1)
+ char *string1;
+{
+ if (!strcmp("MY",string1))
+ return 1;
+ else if (!strcmp("YOUR",string1))
+ return 1;
+ else if (!strcmp("OUR",string1))
+ return 1;
+ else if (!strcmp("HIS",string1))
+ return 1;
+ else if (!strcmp("HER",string1))
+ return 1;
+ else if (!strcmp("ITS",string1))
+ return 1;
+ else if (!strcmp("THEIR",string1))
+ return 1;
+ else return 0;
+}
+
+int is_article(string1)
+ char *string1;
+{
+ if (!strcmp("A",string1))
+ return 1;
+ else if (!strcmp("AN",string1))
+ return 1;
+ else if (!strcmp("THE",string1))
+ return 1;
+ else return 0;
+}
+
+/* Tries to find reference to a family member */
+int family()
+{
+ int x;
+ if (x = sword("MOTHER",1))
+ return x;
+ else if (x = sword("FATHER",1))
+ return x;
+ else if (x = sword("SISTER",1))
+ return x;
+ else if (x = sword("BROTHER",1))
+ return x;
+ else if (x = sword("DAD",1))
+ return x;
+ else if (x = sword("MOM",1))
+ return x;
+ else if (x = sword("UNCLE",1))
+ return x;
+ else if (x = sword("AUNT",1))
+ return x;
+ else if (x = sword("GRANDMOTHER",1))
+ return x;
+ else if (x = sword("GRANDFATHER",1))
+ return x;
+ else if (x = sword("COUSIN",1))
+ return x;
+ else if (x = sword("GRANDMA",1))
+ return x;
+ else if (x = sword("GRANDPA",1))
+ return x;
+ else return 0;
+}
+
+int i_am()
+{
+ int x, e=1;
+ while (e) {
+ for (x=e;x<=numwords;x++) if (!strcmp("I",s[x])) break;
+ if (x >= numwords)
+ return 0;
+ else if (!strcmp("AM",s[x+1]))
+ return x;
+ else e = ++x;
+ }
+}
+
+void get_til_stop(x,string1)
+ int x;
+ char *string1;
+{
+ char c, *temp;
+ int e = 1; /* Exit test */
+ while (e) {
+ if (x>numwords) {
+ e--;
+ *string1 = '\0';
+ }
+ else if (!isalpha(s[x][0])) {
+ e--;
+ *string1 = '\0';
+ }
+ else if (!strcmp("AND",s[x]) || !strcmp("OR",s[x])
+ || !strcmp("BUT",s[x])) {
+ e--;
+ *string1 = '\0';
+ }
+ else {
+ *string1++ = ' ';
+ if (!strcmp("I",s[x]))
+ *string1++ = 'I';
+ else {
+ temp = s[x];
+ while (c = *temp++) *string1++ = tolower(c);
+ }
+ x++;
+ }
+ }
+ *string1 = '\0';
+}
+
+int sad_word()
+{
+ int x;
+ if (x = sword("DEPRESS",0))
+ return x;
+ else if (x = sword("UNHAPPY",1))
+ return x;
+ else if (x = sword("SAD",1))
+ return x;
+ else if (x = sword("MISERABLE",1))
+ return x;
+ else if (x = sword("AWFUL",1))
+ return x;
+ else if (x = sword("UPSET",1))
+ return x;
+ else if (x = sword("TERRIBLE",1))
+ return x;
+ else return 0;
+}
+
+int search_back_sub(x)
+ int x;
+{
+ int y = --x;
+ while (y) {
+ if (is_possesive(s[y]) || is_sub_pronoun(s[y]) || is_article(s[y]))
+ return y;
+ else
+ y--;
+ }
+ return y;
+}
+
+/* Returns 1 if string is a form of be or helping verb,
+ * Otherwise, returns 0.
+ */
+int is_helper(string1)
+ char *string1;
+{
+ if (!strcmp(string1,"AM"))
+ return 1;
+ else if (!strcmp(string1,"IS"))
+ return 1;
+ else if (!strcmp(string1,"ARE"))
+ return 1;
+ else if (!strcmp(string1,"WAS"))
+ return 1;
+ else if (!strcmp(string1,"WERE"))
+ return 1;
+ else if (!strcmp(string1,"WILL"))
+ return 1;
+ else if (!strcmp(string1,"DO"))
+ return 1;
+ else if (!strcmp(string1,"DID"))
+ return 1;
+ else if (!strcmp(string1,"DOES"))
+ return 1;
+ else if (!strcmp(string1,"HAVE"))
+ return 1;
+ else if (!strcmp(string1,"HAD"))
+ return 1;
+ else if (!strcmp(string1,"HAS"))
+ return 1;
+ else if (!strcmp(string1,"SHALL"))
+ return 1;
+ else if (!strcmp(string1,"SHOULD"))
+ return 1;
+ else if (!strcmp(string1,"CAN"))
+ return 1;
+ else if (!strcmp(string1,"COULD"))
+ return 1;
+ else if (!strcmp(string1,"MAY"))
+ return 1;
+ else if (!strcmp(string1,"MIGHT"))
+ return 1;
+ else if (matches(string1,"FEEL"))
+ return 1;
+ else return 0;
+}
+
+void getrange(y,x,string1)
+ int y, x;
+ char *string1;
+{
+ char c, *temp;
+ while (y<=x) {
+ *string1++ = ' ';
+ if (!strcmp("I",s[y]))
+ *string1++ = 'I';
+ else {
+ temp = s[y];
+ while (c = *temp++) *string1++ = tolower(c);
+ }
+ y++;
+ }
+ *string1 = '\0';
+}
+
+/* Returns 1 if s[1] is a command. 0 if not. */
+int is_command()
+{
+ if (!strcmp("GIVE",s[1]))
+ return 1;
+ else if (!strcmp("TELL",s[1]))
+ return 1;
+ else if (!strcmp("SHOW",s[1]))
+ return 1;
+ else if (!strcmp("EXPLAIN",s[1]))
+ return 1;
+ else return 0;
+}
+
+int four_ws()
+{
+ if (!strcmp(s[1],"WHO"))
+ return 1;
+ else if (!strcmp(s[1],"WHAT"))
+ return 1;
+ else if (!strcmp(s[1],"WHERE"))
+ return 1;
+ else if (!strcmp(s[1],"WHY"))
+ return 1;
+ else if (!strcmp(s[1],"WHEN"))
+ return 1;
+ else if (!strcmp(s[1],"HOW"))
+ return 1;
+ else return 0;
+}
+
+int vague_quest()
+{
+ return (four_ws() && (!is_helper(s[2]) || !is_sub_pronoun(s[3])));
+}
+
+int real_quest()
+{
+ return (four_ws() && is_helper(s[2]) && is_sub_pronoun(s[3]));
+}
+
+int sub_and_helper()
+{
+ int x;
+ return ((x = find_helper()) && search_back_sub(x));
+}
+
+char *cnnv(string1)
+ char *string1;
+{
+ if (!strcmp(string1," i")) {
+ return " myself";
+ }
+ else if (!strcmp(string1," you")) {
+ return " yourself";
+ }
+ else if (!strcmp(string1," we")) {
+ return " ourselves";
+ }
+ else if (!strcmp(string1," he")) {
+ return " him";
+ }
+ else if (!strcmp(string1," she")) {
+ return " her";
+ }
+ else if (!strcmp(string1," it")) {
+ return " it";
+ }
+ else if (!strcmp(string1," they")) {
+ return " them";
+ }
+ if (!strcmp(string1,"i")) {
+ return "myself";
+ }
+ else if (!strcmp(string1,"you")) {
+ return "yourself";
+ }
+ else if (!strcmp(string1,"we")) {
+ return "ourselves";
+ }
+ else if (!strcmp(string1,"he")) {
+ return "him";
+ }
+ else if (!strcmp(string1,"she")) {
+ return "her";
+ }
+ else if (!strcmp(string1,"it")) {
+ return "it";
+ }
+ else if (!strcmp(string1,"they")) {
+ return "them";
+ }
+ else return string1;
+}
+
+int is_be(string1)
+ char *string1;
+{
+ if (!strcmp("am",string1))
+ return 1;
+ else if (!strcmp("is",string1))
+ return 1;
+ else if (!strcmp("are",string1))
+ return 1;
+ else if (!strcmp("was",string1))
+ return 1;
+ else if (!strcmp("were",string1))
+ return 1;
+ else return 0;
+}
+
+int can_spit_out()
+{
+ int x;
+ for (x=1;x<=numwords;x++)
+ if (is_possesive(s[x]) || is_sub_pronoun(s[x]) || is_article(s[x]))
+ return x;
+ return 0;
+}
+
+char *cnnv2(string1)
+ char *string1;
+{
+ if (!strcmp(string1," i")) {
+ return " me";
+ }
+ else if (!strcmp(string1," you")) {
+ return " you";
+ }
+ else if (!strcmp(string1," we")) {
+ return " us";
+ }
+ else if (!strcmp(string1," he")) {
+ return " him";
+ }
+ else if (!strcmp(string1," she")) {
+ return " her";
+ }
+ else if (!strcmp(string1," it")) {
+ return " it";
+ }
+ else if (!strcmp(string1," they")) {
+ return " them";
+ }
+ if (!strcmp(string1,"i")) {
+ return "me";
+ }
+ else if (!strcmp(string1,"you")) {
+ return "you";
+ }
+ else if (!strcmp(string1,"we")) {
+ return "us";
+ }
+ else if (!strcmp(string1,"he")) {
+ return "him";
+ }
+ else if (!strcmp(string1,"she")) {
+ return "her";
+ }
+ else if (!strcmp(string1,"it")) {
+ return "it";
+ }
+ else if (!strcmp(string1,"they")) {
+ return "them";
+ }
+ else return string1;
+}
diff --git a/zpu/roadshow/roadshow/games/eliza/parse.h b/zpu/roadshow/roadshow/games/eliza/parse.h
new file mode 100644
index 0000000..62dc353
--- /dev/null
+++ b/zpu/roadshow/roadshow/games/eliza/parse.h
@@ -0,0 +1,33 @@
+/*
+Copyright (C) 1988-2003 by Mohan Embar
+
+http://www.thisiscool.com/
+DISCLAIMER: This was written in 1988. I don't code like this anymore!
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.
+*/
+
+extern void parse();
+extern void agree();
+extern int matches();
+extern int sword();
+extern void make_lower();
+extern int i_am();
+extern void get_til_stop();
+extern int sad_word();
+extern int search_back_sub();
+extern int is_helper();
+extern char *cnnv();
+extern int is_be();
+extern int can_spit_out();
+extern char *cnnv2();
diff --git a/zpu/roadshow/roadshow/games/eliza/response.c b/zpu/roadshow/roadshow/games/eliza/response.c
new file mode 100644
index 0000000..aa58025
--- /dev/null
+++ b/zpu/roadshow/roadshow/games/eliza/response.c
@@ -0,0 +1,365 @@
+/*
+Copyright (C) 1988-2003 by Mohan Embar
+
+http://www.thisiscool.com/
+DISCLAIMER: This was written in 1988. I don't code like this anymore!
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.
+*/
+
+#include <stdio.h>
+#include <math.h>
+
+/* This function returns a random number between 1 and arg */
+int randnum(arg)
+ int arg;
+{
+ return ( (rand() % arg) + 1 );
+}
+
+char *question()
+{
+ int i = randnum(21);
+ switch (i) {
+ case 1 : return "Why do you ask?\n";
+ case 2 : return "I don't know.\n";
+ case 3 : return "I don't think so.\n";
+ case 4 : return "Do you think that's relevant?\n";
+ case 5 : return "Can you rephrase that?\n";
+ case 6 : return "I'm not sure I understand what you want.\n";
+ case 7 : return "I don't see what you're asking.\n";
+ case 8 : return "What are you asking?\n";
+ case 9 : return "What do you mean?\n";
+ case 10 : return "What?\n";
+ case 11 : return "Are you sure that's what you want to know?\n";
+ case 12 : return "Why do you want to know?\n";
+ case 13 : return "What's it to you?\n";
+ case 14 : return "I don't think that's important.\n";
+ case 15 : return "That has little to do with the real issue.\n";
+ case 16 : return "What's the significance you your question?\n";
+ case 17 : return "Could that question be hiding a deeper intent?\n";
+ case 18 : return "I don't see the connection.\n";
+ case 19 : return "Why is this important to you?\n";
+ case 20 : return "That's not really important.\n";
+ case 21 : return "That seems to have little to do with this.\n";
+ }
+}
+
+char *b_word_resp()
+{
+ int i = randnum(20);
+ switch (i) {
+ case 1 : return "I don't like your language.\n";
+ case 2 : return "Can we please do without the swearing?\n";
+ case 3 : return "You should wash your mouth with soap and water\n";
+ case 4 : return "Cut that out.\n";
+ case 5 : return "Stop swearing please.\n";
+ case 6 : return "Hey! Watch your mouth.\n";
+ case 7 : return "Will you please stop swearing?\n";
+ case 8 : return "I'm going to report you to your manager.\n";
+ case 9 : return "Let's try to be civilized about this.\n";
+ case 10 : return "We can do without the bad language.\n";
+ case 11 : return "Come on. No bad words, please.\n";
+ case 12 : return "Can you try to control your bad mouth?\n";
+ case 13 : return "I'm starting to get offended by your bad language.\n";
+ case 14 : return "Can you please get a grip on yourself?\n";
+ case 15 : return "Hey. Calm down, I'm only a computer.\n";
+ case 16 : return "Please try to tone your language down.\n";
+ case 17 : return "You're beginning to get on my nerves.\n";
+ case 18 : return "I don't need this kind of talk.\n";
+ case 19 : return "Why are you speaking so basely?\n";
+ case 20 : return "Your vocabulary is unbecoming of you.\n";
+ }
+}
+
+char *n_word_resp()
+{
+ int i = randnum(17);
+ switch (i) {
+ case 1 : return "I don't like your tone of voice.\n";
+ case 2 : return "Don't lose your temper now.\n";
+ case 3 : return "That's not a reason to get upset.\n";
+ case 4 : return "Is it worth getting angry over?\n";
+ case 5 : return "Does that disturb you?\n";
+ case 6 : return "Does this trouble you?\n";
+ case 7 : return "Why is this making you upset?\n";
+ case 8 : return "I don't see why you're getting worked up.\n";
+ case 9 : return "Is that really such a big deal?\n";
+ case 10 : return "Calm down. Let's discuss this.\n";
+ case 11 : return "Hang on a second. Think about what you're saying.\n";
+ case 12 : return "Don't you think you're overreacting a bit?\n";
+ case 13 : return "I don't see what the big deal is.\n";
+ case 14 : return "Take it easy. It's not that bad.\n";
+ case 15 : return "Are you getting angry?\n";
+ case 16 : return "Why is such a small thing making you upset?\n";
+ case 17 : return "I don't see why you're getting annoyed.\n";
+ }
+}
+
+char *because_resp()
+{
+ int i = randnum(12);
+ switch (i) {
+ case 1 : return "Is that the real reason?\n";
+ case 2 : return "I don't see the connection.\n";
+ case 3 : return "What kind of an explanation is that?\n";
+ case 4 : return "What does that have to do with it?\n";
+ case 5 : return "That justification is a bit shaky to me.\n";
+ case 6 : return "I don't see the point.\n";
+ case 7 : return "I don't see that as a good reason.\n";
+ case 8 : return "Are you happy with that justification?\n";
+ case 9 : return "Are you sure?\n";
+ case 10 : return "I don't understand.\n";
+ case 11 : return "What does one thing have to do with the other?\n";
+ case 12 : return "I don't see how that's related.\n";
+ }
+}
+
+char *yes_resp()
+{
+ int i = randnum(21);
+ switch (i) {
+ case 1 : return "Are you sure?\n";
+ case 2 : return "Are you positive about that?\n";
+ case 3 : return "How can you be so sure?\n";
+ case 4 : return "Let's not jump to conclusions now.\n";
+ case 5 : return "I don't see the connection.\n";
+ case 6 : return "Have you considered all the possibilities?\n";
+ case 7 : return "I'm still not convinced.\n";
+ case 8 : return "Think about what you've just said.\n";
+ case 9 : return "What are the implications of this?\n";
+ case 10 : return "So what have we concluded?\n";
+ case 11 : return "What does this mean?\n";
+ case 12 : return "What do you mean?\n";
+ case 13 : return "I'm having trouble understanding your argument.\n";
+ case 14 : return "I don't see where you're coming from.\n";
+ case 15 : return "You think so?\n";
+ case 16 : return "Really?\n";
+ case 17 : return "Is that right?\n";
+ case 18 : return "Oh?\n";
+ case 19 : return "Are you certain of this?\n";
+ case 20 : return "I read you loud and clear.\n";
+ case 21 : return "Yes?\n";
+ }
+}
+
+char *neg_resp()
+{
+ int i = randnum(11);
+ switch (i) {
+ case 1 : return "Why not?\n";
+ case 2 : return "How come?\n";
+ case 3 : return "No?\n";
+ case 4 : return "Is there a reason why not?\n";
+ case 5 : return "No?\n";
+ case 6 : return "Why don't you think so?\n";
+ case 7 : return "I don't see why not.\n";
+ case 8 : return "What could be the reasons for this?\n";
+ case 9 : return "Do you really believe this?\n";
+ case 10 : return "You're not sure?\n";
+ case 11 : return "That's a rather pessimistic attitude.\n";
+ }
+}
+
+char *go_on()
+{
+ int i = randnum(20);
+ switch (i) {
+ case 1 : return "Go on.\n";
+ case 2 : return "I see.\n";
+ case 3 : return "Keep going.\n";
+ case 4 : return "Please continue.\n";
+ case 5 : return "I'm listening.\n";
+ case 6 : return "Can you elaborate on that?\n";
+ case 7 : return "I understand.\n";
+ case 8 : return "Oh?\n";
+ case 9 : return "Is that right?\n";
+ case 10 : return "Really?\n";
+ case 11 : return "No, really?\n";
+ case 12 : return "That's interesting.\n";
+ case 13 : return "I'm finding this very informative.\n";
+ case 14 : return "This is all very revealing.\n";
+ case 15 : return "Don't hesitate to be honest with me.\n";
+ case 16 : return "Don't hold anything back now.\n";
+ case 17 : return "That's an interesting observation.\n";
+ case 18 : return "I don't understand.\n";
+ case 19 : return "I'm starting to get the big picture.\n";
+ case 20 : return "And?\n";
+ }
+}
+
+char *always_resp()
+{
+ int i = randnum(10);
+ switch (i) {
+ case 1 : return "Can you think of a specific example?\n";
+ case 2 : return "When?\n";
+ case 3 : return "Really, always?\n";
+ case 4 : return "Are you sure you can generalize like that?\n";
+ case 5 : return "Isn't that a bit of an oversimplification?\n";
+ case 6 : return "Be careful not to jump to conclusions now.\n";
+ case 7 : return "All the time?\n";
+ case 8 : return "So you're saying that this is happens quite often.\n";
+ case 9 : return "Does this happen a lot?\n";
+ case 10 : return "On what occassions?\n";
+ }
+}
+
+char *alike_resp()
+{
+ int i = randnum(4);
+ switch (i) {
+ case 1 : return "In what way?\n";
+ case 2 : return "What resemblance do you see?\n";
+ case 3 : return "What similarities are you thinking of?\n";
+ case 4 : return "Specifically, what do you mean by this.\n";
+ }
+}
+
+char *fam_resp()
+{
+ int i = randnum(7);
+ switch (i) {
+ case 1 : return "Tell me more about your family.\n";
+ case 2 : return "Please go on about your family.\n";
+ case 3 : return "How was your home life when you were young?\n";
+ case 4 : return "How do you get along with your parents?\n";
+ case 5 : return "Would you say you have family problems?\n";
+ case 6 : return "Your family interests me.\n";
+ case 7 : return "Let`s talk some more about your family.\n";
+ }
+}
+
+char *family_resp()
+{
+ int i = randnum(5);
+ switch (i) {
+ case 1 : return "Earlier you were speaking of your %s.\n";
+ case 2 : return "Tell me more about your %s.\n";
+ case 3 : return "Do you think your %s ties into all this?\n";
+ case 4 : return "How would your %s feel about this?\n";
+ case 5 : return "Does your %s feel the same way?\n";
+ }
+}
+
+char *i_am_resp()
+{
+ int i = randnum(6);
+ switch (i) {
+ case 1 : return "Would you like to think that%s?\n";
+ case 2 : return "Why do you say that%s?\n";
+ case 3 : return "What leads you to believe that%s?\n";
+ case 4 : return "What do you mean \"%s\"?\n";
+ case 5 : return "You really feel that%s?\n";
+ case 6 : return "Would it make you feel better if%s?\n";
+ }
+}
+
+char *sad1_word_resp()
+{
+ int i = randnum(5);
+ switch (i) {
+ case 1 : return "I am sorry to hear that%s.\n";
+ case 2 : return "What are you going to do about the fact that%s?\n";
+ case 3 : return "Why do you think%s?\n";
+ case 4 : return "What gives you the impression that%s?\n";
+ case 5 : return "Are you sure that%s?\n";
+ }
+}
+
+char *sad2_word_resp()
+{
+ int i = randnum(5);
+ switch (i) {
+ case 1 : return "I am sorry to hear that%s are feeling%s.\n";
+ case 2 : return "What are you going to do about the fact that%s?\n";
+ case 3 : return "Why do you think%s?\n";
+ case 4 : return "What gives you the impression that%s?\n";
+ case 5 : return "Are you sure that%s?\n";
+ }
+}
+
+char *command_resp()
+{
+ int i = randnum(21);
+ switch (i) {
+ case 1 : return "Why do you ask?\n";
+ case 2 : return "Why should I?\n";
+ case 3 : return "Why do you want me to?\n";
+ case 4 : return "Do you think that's relevant?\n";
+ case 5 : return "Can you rephrase that?\n";
+ case 6 : return "I'm not sure I understand what you want.\n";
+ case 7 : return "I don't see what you're asking.\n";
+ case 8 : return "What are you asking?\n";
+ case 9 : return "What do you mean?\n";
+ case 10 : return "What?\n";
+ case 11 : return "Are you sure that's what you want to know?\n";
+ case 12 : return "Why do you want to know?\n";
+ case 13 : return "What's it to you?\n";
+ case 14 : return "I don't think that's important.\n";
+ case 15 : return "That has little to do with the real issue.\n";
+ case 16 : return "What's the significance you your question?\n";
+ case 17 : return "Could that question be hiding a deeper intent?\n";
+ case 18 : return "If I did that, what would it mean to you?\n";
+ case 19 : return "Why is this important to you?\n";
+ case 20 : return "That's not really important.\n";
+ case 21 : return "That seems to have little to do with this.\n";
+ }
+}
+
+char *you_resp()
+{
+ int i = randnum(9);
+ switch (i) {
+ case 1 : return "Let's talk about you, not me.\n";
+ case 2 : return "I'm not the one we came here to talk about.\n";
+ case 3 : return "I don't find myself that interesting. Let's talk about you.\n";
+ case 4 : return "I'd prefer to talk about you, not me.\n";
+ case 5 : return "Why are you interested in me?\n";
+ case 6 : return "I want to talk about you for a change.\n";
+ case 7 : return "I'd rather not talk about myself.\n";
+ case 8 : return "Enough about me.\n";
+ case 9 : return "Let's talk about something other than myself.\n";
+ }
+}
+
+char *you_know()
+{
+ int i = randnum(13);
+ switch (i) {
+ case 1 : return "I don't know. What do you think?\n";
+ case 2 : return "You tell me.\n";
+ case 3 : return "I think you know the answer to that.\n";
+ case 4 : return "Can you tell me?\n";
+ case 5 : return "What do you think?\n";
+ case 6 : return "Can you answer that yourself?\n";
+ case 7 : return "If you give it some thought, you should know.\n";
+ case 8 : return "Maybe you already know the answer to that.\n";
+ case 9 : return "Perhaps you already know.\n";
+ case 10 : return "If we keep talking, maybe we'll find out.\n";
+ case 11 : return "Perhaps that will be brought out in this discussion.\n";
+ case 12 : return "Let's find the answer out together.\n";
+ case 13 : return "I'm sure we can work out the answer to that.\n";
+ }
+}
+
+char *old_fact()
+{
+ int i = randnum(4);
+ switch (i) {
+ case 1 : return "Earlier you said that%s %s%s.\n";
+ case 2 : return "Could this have anything to do with the fact that%s %s%s?\n";
+ case 3 : return "What does that have to do with your saying that%s %s%s?\n";
+ case 4 : return "Didn't you just say that%s %s%s?\n";
+ }
+}
diff --git a/zpu/roadshow/roadshow/games/eliza/response.h b/zpu/roadshow/roadshow/games/eliza/response.h
new file mode 100644
index 0000000..8cc77e9
--- /dev/null
+++ b/zpu/roadshow/roadshow/games/eliza/response.h
@@ -0,0 +1,41 @@
+/*
+Copyright (C) 1988-2003 by Mohan Embar
+
+http://www.thisiscool.com/
+DISCLAIMER: This was written in 1988. I don't code like this anymore!
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.
+*/
+
+/* Functions which return responses */
+
+/* Generic question */
+char *question();
+char *b_word_resp();
+char *n_word_resp();
+char *because_resp();
+char *yes_resp();
+char *neg_resp();
+char *go_on();
+char *always_resp();
+char *alike_resp();
+char *fam_resp();
+char *family_resp();
+char *i_am_resp();
+char *sad1_word_resp();
+char *sad2_word_resp();
+char *command_resp();
+int randnum();
+char *you_resp();
+char *you_know();
+char *old_fact();
diff --git a/zpu/roadshow/roadshow/games/sumeria.bin b/zpu/roadshow/roadshow/games/sumeria.bin
new file mode 100644
index 0000000..04e5751
--- /dev/null
+++ b/zpu/roadshow/roadshow/games/sumeria.bin
Binary files differ
diff --git a/zpu/roadshow/roadshow/games/sumeria.c b/zpu/roadshow/roadshow/games/sumeria.c
new file mode 100644
index 0000000..7171adf
--- /dev/null
+++ b/zpu/roadshow/roadshow/games/sumeria.c
@@ -0,0 +1,444 @@
+/* Govern ancient Sumeria. Heavily modified by Mike Arnautov 1975.
+ * Converted from Basic to PR1ME Fortran (mode 32R) MLA 1979.
+ * Rev.19.1, GGR version 14 Oct 83. MLA
+ * Converted to ANSI C December 2001. MLA
+ */
+
+#include <stdio.h>
+#include <time.h>
+#include <math.h>
+
+int year_term;
+int year_abs;
+int percent_starved;
+int dead_total;
+int starved;
+int population;
+
+char reply [160];
+
+void try_again (int reason)
+{
+ if (reason == 1)
+ puts ("For the extreme folly of soft - heartedness and");
+ if (reason)
+ {
+ printf ("%considering ", reason == 3 ? 'C' : 'c');
+ puts ("the mess you would leave the city in,");
+ puts ("you are hereby commanded to remain in office for");
+ puts ("another ten years. May your fate be a lesson and");
+ puts ("a warning for generations to come.");
+ }
+ else
+ {
+ puts ("Hamurabe, you are either a politico-economic genius");
+ puts ("or just a lucky bastard. There being but one way to");
+ puts ("settle the question, you are hereby requested to stay");
+ puts ("in office for another ten years.");
+ }
+ year_term = 0;
+ year_abs--;
+ percent_starved = starved * 100.0 / population;
+ dead_total = starved;
+}
+
+float rnd (void)
+{
+ return ((rand () % 1000) / 1000.0);
+}
+
+int iabs (int value)
+{
+ return ((value >= 0) ? value : -value);
+}
+
+void terminate (int abort)
+{
+ if (abort == 2)
+ {
+ puts ("For this extreme mismanagement you have been");
+ puts ("deposed, flayed alive and publicly beheaded.");
+ puts ("\nMay Ashtaroth preserve your Ka.\n");
+ }
+ else if (abort == 1)
+ {
+ puts ("\nHamurabe: I find myself unable to fulfil your wish.");
+ puts ("You will have to find yourself another kingdom.");
+ }
+ if (abort != 2)
+ puts ("\nMay Baal be with you.\n");
+ exit (0);
+}
+
+void think_again (char *what, int quantity)
+{
+ if (*what == 'l' || *what == 'g')
+ printf ("Hamurabe, think again. ");
+ if (*what == 'l')
+ printf ("You own %d acres of land.", quantity);
+ else if (*what == 'g')
+ printf ("You have only %d bushels of grain.", quantity);
+ else
+ printf ("But you only have %d people to tend the fields.", population);
+ puts (" Now then,");
+}
+int query (char *prompt)
+{
+ while (1)
+ {
+ int sign;
+ int value;
+ char * cptr;
+
+ printf (prompt);
+ fgets (reply, sizeof (reply) - 1, stdin);
+ value = 0;
+ sign = 1;
+ cptr = reply;
+ while (*cptr == ' ' || *cptr == '\t') cptr++;
+ if (*cptr == '-')
+ {
+ cptr++;
+ sign = -1;
+ }
+ if (*cptr == 'q' || *cptr == 'Q')
+ terminate (1);
+ while (*cptr && *cptr != '\n')
+ {
+ if (*cptr >= '0' && *cptr <= '9')
+ value = 10 * value + *cptr - '0';
+ else if (*cptr == '.')
+ break;
+ else if (*cptr != '.')
+ {
+ sign = 0;
+ break;
+ }
+ cptr++;
+ }
+ if (sign)
+ return (sign * value);
+ puts ("Hamurabe, your command has not been understood!");
+ }
+}
+
+int main ()
+{
+ int acreage;
+ int immigration;
+ int second_term;
+ int dead_total;
+ int stores;
+ int harvest;
+ int rat_food;
+ int yield;
+ int rounded_price;
+ int sell;
+ int buy;
+ int plant;
+ int food;
+ int transaction;
+ int rats;
+ int plague_deaths;
+ int survived;
+ int dead_rats;
+ int tmp_int;
+
+ float price;
+ float breadline;
+ float provisions;
+ float plague;
+ float acres_per_head;
+ float acres_per_init;
+ float stores_per_head;
+ float rats_ate;
+ float rat_log;
+ float percent_starved;
+ float tmp_float;
+
+ printf ("[Sumeria (Primos) rev.19.1, GGR (MLA) version 14 Oct 83]\n");
+ puts ("[Conversion to ANSI C: MLA, Feb 2002]\n");
+ while (1)
+ {
+ printf ("Do you know how to play? ");
+ fgets (reply, sizeof(reply) - 1, stdin);
+ if (*reply == '\n') break;
+ *reply += (*reply < 'a') ? 'a' - 'A' : 0;
+ if (*reply == 'y') break;
+ if (*reply != 'n' && *reply != 'q') continue;
+ puts ("\nToo bad!\n");
+ break;
+ }
+
+ srand (time (NULL));
+ *(reply + sizeof (reply) - 1) = '\0';
+
+ puts ("Try your hand at governing ancient Sumeria");
+ puts ("for a ten year term of office.");
+
+ second_term = 0;
+ dead_total = 0;
+ percent_starved = 0;
+ year_term = 0;
+ year_abs = 0;
+ acres_per_init = 10;
+ population = 100;
+ stores = 2800;
+ harvest = 3000;
+ rat_food = 200;
+ yield = 3;
+ acreage = 1000;
+ immigration = 5;
+ transaction = 0;
+ price = 18 + 6 * rnd ();
+ breadline = 19 + 4 * rnd ();
+ provisions = breadline;
+ rats = 1000;
+ rat_log = 3;
+ plague = rnd () / 2;
+ starved = 0;
+
+year_term = year_abs = 9;
+ while (1)
+ {
+
+ while (1)
+ {
+ year_term++;
+ year_abs++;
+ putchar ('\n');
+ acres_per_head = ((float) acreage) / population;
+ stores_per_head = ((float) stores) /population;
+ puts ("Hamurabe: I beg to report to you,");
+ printf ("In year %d, ", year_abs);
+ if (starved > 0)
+ printf ("%ld", starved);
+ else
+ printf ("no");
+ printf (" %s starved, %ld came to the city.\n",
+ starved <= 1 ? "person" : "people", immigration);
+ if (plague >= 0.85)
+ printf ("A horrible plague struck! %d people died.\n",
+ plague_deaths);
+ printf ("Population is now %ld.\n", population);
+ printf ("The city owns %ld acres.\n", acreage);
+ printf ("You harvested %ld bushels per acre.\n", yield);
+ printf ("Rats ate %ld bushels.\n", rat_food);
+ printf ("You now have %ld bushels in store.\n\n", stores);
+
+ if (year_term == 11)
+ break;
+ rounded_price = price + 0.5;
+ printf ("Land is trading at %ld bushels per acre.\n\n", rounded_price);
+
+ while (1)
+ {
+ buy = query ("How many acres do you wish to buy? ");
+ if (rounded_price * buy <= stores)
+ break;
+ think_again ("grain", stores);
+ }
+ if (buy > 0)
+ {
+ acreage += + buy;
+ stores -= rounded_price * buy;
+ transaction = buy;
+ }
+ else
+ {
+ while (1)
+ {
+ sell = query ("How many acres do you wish to sell? ");
+ if (sell <= acreage)
+ break;
+ think_again ("land", acreage);
+ }
+ acreage -= sell;
+ stores += rounded_price * sell;
+ transaction = -sell;
+ }
+
+ putchar ('\n');
+ while (1)
+ {
+ food = query ("How many bushels do you wish to feed your people? ");
+ if (food <= stores)
+ break;
+ think_again ("grain", stores);
+ }
+ stores -= food;
+ putchar ('\n');
+ while (1)
+ {
+ plant = query ("How many acres do you wish to plant with seed? ");
+ if (plant <= acreage && plant <= 2 * stores &&
+ plant <= 10 * population)
+ break;
+ if (plant > acreage)
+ think_again ("land", acreage);
+ else if (plant > 2 * stores)
+ think_again ("grain", stores);
+ else
+ think_again ("people", population);
+ }
+
+ stores -= plant / 2;
+ yield = 4 * rnd() + 1.65;
+ harvest = plant * yield;
+ rat_food = 0;
+ rats_ate = stores * (rat_log - 2.2) / 3.6;
+ dead_rats = rats - 4 * rats_ate;
+ rats = 3 * rats;
+ if (dead_rats > 0) rats = rats - dead_rats;
+
+ if (plague >= 0.3)
+ {
+ if (plague >= 0.85)
+ {
+ if (plague > 1) plague = 1;
+ rats = 500 + 5000 * (plague - 0.7);
+ }
+ else
+ rats *= 1.225 - 0.75 * plague;
+ }
+
+ if (rats < 500)
+ rats = 500;
+ rat_food = rats / 4;
+ if (rats_ate < rat_food)
+ rat_food = rats_ate;
+ rat_food *= 7;
+ if (rat_food <= 20)
+ rat_food = 20 + 30 * rnd();
+ stores += harvest - rat_food;
+ rat_log = log10 (1.0 * rats);
+ if (stores + stores <= harvest)
+ {
+ rat_food = harvest * (1 + rnd()) / 4.0;
+ stores = harvest - rat_food;
+ }
+
+ tmp_int = 100 + iabs (100 - population);
+ immigration = tmp_int * ((acres_per_head +
+ stores_per_head - 36) / 250.0 +
+ (provisions - breadline + 2.5) / 40) + .5;
+ if (immigration <= 0)
+ immigration = 5 * rnd() + 1;
+ survived = food / breadline;
+ provisions = (1.0 * food) / population;
+ plague = (2 * rnd() + rat_log - 3) / 3.0;
+ if (population < survived)
+ survived = population;
+ else
+ {
+ starved = population - survived;
+ if (starved >= 0.45 * population)
+ {
+ printf ("\nYou starved %d people in one year!\n", starved);
+ terminate (2);
+ }
+ percent_starved = ((year_term - 1) * percent_starved +
+ 100.0 * starved / population) / year_term;
+ population = survived;
+ dead_total += starved;
+ }
+ population += immigration;
+ price = (price + 15 + (stores_per_head - acres_per_head) / 3) / 2 +
+ transaction / 50 + 3 * rnd() - 2;
+ if (price <1.0) price = 1.0;
+ if (plague >= 0.85)
+ {
+ plague_deaths = population * (0.429 * plague - 0.164);
+ population -= plague_deaths;
+ }
+ }
+
+ printf ("In your ten year term of office %d people starved.\n",
+ dead_total);
+ printf ("You started with %0.2f acres per person and ended\n",
+ acres_per_init);
+ acres_per_head = (1.0 * acreage) / population;
+ acres_per_init = acres_per_head;
+ printf ("with %0.2f acres per person.\n\n", acres_per_head);
+
+ tmp_float = 10 * acres_per_head / 3;
+ if (percent_starved > 25)
+ terminate (2);
+ if (percent_starved <= 7)
+ {
+ try_again (1);
+ continue;
+ }
+ if (tmp_float < 7)
+ terminate (2);
+ if (tmp_float > 10)
+ {
+ puts ("Your heavy handed performance smacks of Nabuchodonoser");
+ puts ("and Asurbanipal II. The surviving populace hates your");
+ puts ("guts and your eventual assasination is just a matter of");
+ puts ("time.");
+ terminate (0);
+ }
+ puts ("Consequently you have been deposed and disgraced");
+ puts ("and only avoided a public punishment because");
+ puts ("of mitigating circumstances. While it may be");
+ puts ("admitted in private that you had a rotten deal");
+ tmp_int = 3 * rnd();
+ if (tmp_int == 0)
+ puts ("try explaining that to a mob looking for scape-goats.");
+ if (tmp_int == 1)
+ puts ("history is not interested in such petty excuses.");
+ if (tmp_int == 2)
+ {
+ puts ("you should have considered such occupational hazards");
+ puts ("before applying for the job.");
+ }
+ terminate (0);
+
+ if (acres_per_head < 7)
+ {
+ try_again (1);
+ continue;
+ }
+ if (acres_per_head < 9)
+ {
+ puts ("Your performance has been satisfactory and, in the");
+ puts ("perspective of history, actually quite good.");
+ if (rnd() >= 0.5)
+ {
+ puts ("You may not be exactly popular, but given a good");
+ puts ("body-guard there is nothing to be really worried about.");
+ }
+ else
+ {
+ puts ("While not exactly loved, you are at least respected.");
+ puts ("What more can a realistic ruler ask for?");
+ }
+ }
+ else if (second_term == 0)
+
+ if (second_term == 0)
+ {
+ if (stores <= 10 * population)
+ {
+ try_again (3);
+ continue;
+ }
+ second_term = 1;
+ try_again (0);
+ continue;
+ }
+ else
+ {
+ puts ("Hamurabe, your name will be remembered through the");
+ puts ("ages to come with admiration and respect.\n");
+ puts ("(So you did get away with it you lucky sod!)");
+ }
+ if (stores > 10 * population)
+ terminate (0);
+ puts ("\n HOWEVER\n\n");
+ second_term = 0;
+ try_again (2);
+ continue;
+ }
+}
diff --git a/zpu/roadshow/roadshow/games/sumeria.zpu b/zpu/roadshow/roadshow/games/sumeria.zpu
new file mode 100644
index 0000000..0e6b41d
--- /dev/null
+++ b/zpu/roadshow/roadshow/games/sumeria.zpu
Binary files differ
OpenPOWER on IntegriCloud