The Oracle.
Oracle: a silly command line game in bash. Nothing to do with the company.The program is meant for command line users of linux and etc. Great little party game based on the idea of the black ball oracle to predict the future. Ask it anything! You need a unix/linux system running the Bash (Bourne Again SHell).. Also included is a qbasic version which could be converted to Freebasic.
If you like this instructable, you may also like: https://www.instructables.com/id/Predict-the-future-for-someone/
Bonus: I have added at least two other command line games at the end of this instructable.
Update: Coming out with a web based version soon.
The Code.
####################################
# The oracle
#
#===============================
# Functions
#--------------------------------
# pc = position cursor
function pc () {
tput cup $1 $2
}
function header () {
clear
pc 2 10 ; echo "The Oracle"
}
function footer() {
pc 24 0
}
# end functions
#=================================
# Assignments
# --------------------------------
datafile="odata"
pay=5
a=1
m="not done"
d=" "
# end assignments
#=================================
#
# Data input
#---------------------------------
while read line
do fdata[$a]=$line
let a=a+1
done < $datafile
#===================================
# local variables
#--------------------------------
let nodf=$a
declare -i X=$nodf
# NUM=$[ ( $RANDOM % $X ) + 1 ]
#====================================
# Header
#-----------------------------------
header
#=====================================
# Begin logic
#--------------------------------------
while true; do
let turns=turns+1
clear
pc 4 1
echo " T H E O R A C L E !"
pc 25 2
echo "Computothought:(c) 1980 - 2011"
pc 7 1
echo "Please enter your question "
pc 8 1
echo "["
pc 8 2
read q
pc 10 1
echo "The Oracle will show you it's thoughts, then summon your answer."
pc 12 1
echo "So please be patient!"
pc 15 1
echo "***********************************************************************"
pc 16 1
# may have to add spaces
echo "* *"
pc 17 1
echo "***********************************************************************"
for (( y = 1;y<=100;y+=1));do
pc 16 1
# may have to add spaces
echo "* *"
pc 16 3
NUM=$[ ( $RANDOM % $X ) + 1 ]
echo ${fdata[$NUM]}
done
pc 18 1
echo "Play again (Y/n)"
read -s -n1 d
echo
case $d in
[nN] ) break ;;
esac
done
let owed=$pay*$turns
echo "Please pay the cashier $owed dollars!"
read
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# end of job:
echo
clear
pc 4 1
echo " T H E O R A C L E !"
pc 23 1
echo "Computothought: (c) 1980 - 2011"
pc 6 1
echo
echo "If you use this program more than several times and would like"
echo "to see more programs like the Oracle and the Cartomancer, please"
echo "let the author know!"
echo
# END
# end logic
#-----------------------------------
# footer
footer
#===================================
# End.
####################################
The Data.
Yes, if you are creative.
Hold that thought and let me get back to you.
Anything is possible, but you will have a difficult start.
What a youthful folly to ask!
You must wait and ask again.
Only conflict will come of the result, please pray.
It will take many who are organized to accomplish your request.
Yes, if you keep it together.
Be meek and you will get your answer.
You are lucky to get this far!
You must have the fellowship of men.
In great measure will the possession result.
One must be modest to attain their goal.
You will do good to have enthusiasm for your quest.
Let someone else take the lead to your quest.
Atone for what has been spoiled, then reask your question.
You are too far away to get the answer.
Meditation will lead you to your answer.
Bite through to your goal.
If you handle life with grace!
There is to be a coming apart for fate to be realized.
All must return to what is.
Not knowing the true answer will be better.
You must tame the power of the great.
Watch the corners of the mouth.
The greatest preponderance will be fate.
It will be the abysmals, sorry!
You will be lucky to hold on to what you have.
Influence will be the stepping stone to your quest.
Just be patient for a while.
It is a time for getting away.
The power of the great is upon you.
Yes, there is a progression to be attained.
The crystal ball is losing light and no answer may be attained now.
Everyone close will be part of your answer.
No, there is too much opposition.
Not likely, there are obstructions in the way.
Yes, deliverance will come.
Not as much as you might as supposed.
Yes and more than was planned.
Yes, if there is a breakthrough.
Maybe if you come to meet.
Now is the time to gather together for the answer.
Yes, only if there is a push upward.
No, oppression will stop your quest.
Yes, no, and maybe…….
What the oracle says is opposite to your true answer.
The answer will take longer and you will pay for the wait.
Only through an arousing!
It is not time for a move, you must keep still.
Let fate develop as it will.
You must see the marrying maiden first.
More than you ever imagined.
You may wonder and wander, but it is time to move.
Only if you act gently.
Yes, with great joy!
No, so you must let go of it to spread out.
Only with limitations.
Look within yourself and you can find the answer.
Only with preponderance of the small.
It will come to be after completion.
Only before completion.
I love Elizabeth!
Only God knows…
Get It Working.
$ chmod +x oracle
To run the batch file use:
$ ./oracle
Have fun!
Bonus:
'---------------------------------------------------------------------------------------------------
REM **************************************************************************
REM * program: oracle pc
REM * note : random choosing of answer for a question.
REM * programmer: Computothought
REM * last update: 03/10/11
REM *------------------------------------------------------------------------
RESTORE odata
WIDTH 80, 25
CLS
RANDOMIZE TIMER
DIM x$(64)
rem To.sound = 1
FOR x = 0 TO 63
READ x$(x)
NEXT x
m$ = "Not done"
pay = 0
WHILE m$ = "Not done"
pay = pay + 1
CLS
LOCATE 4, 1
PRINT " T H E O R A C L E !"
LOCATE 5, 1
PRINT " Computothought 2009"
FOR x = 1 TO 1500
NEXT x
LOCATE 7, 1
LINE INPUT "Please enter your question: ", q$
SELECT CASE LEFT$(q$, 1)
CASE CHR$(248)
rem To.sound = 1
CASE CHR$(255)
rem To.sound = 0
END SELECT
LOCATE 10, 1
PRINT "The Oracle will show you it's thoughts, then summon your answer."
LOCATE 12, 1
PRINT "So please be patient!"
LOCATE 15, 1
PRINT "<" + STRING$(76, "=") + ">"
LOCATE 16, 1
PRINT "<"; TAB(78); ">"
LOCATE 17, 1
PRINT "<" + STRING$(76, "=") + ">"
FOR Z = 1 TO 1000
LOCATE 16, 3
PRINT STRING$(75, " ");
LOCATE 16, 3
PRINT x$(RND(1) * 63);
rem IF To.sound = 1 THEN
rem PLAY "l16" + CHR$(INT(RND(1) * 7) + 65)
rem END IF
NEXT Z
FOR x = 1 TO 5
NEXT x
INPUT "Are you done (Y/n)"; d$
IF UCASE$(d$) <> "N" THEN
m$ = "Done"
END IF
WEND
PRINT "Please pay the cashier "; pay * 5; " dollars!"
zz$ = ""
zz$ = INPUT$(1)
' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
endvofvjob:
VIEW PRINT
LOCATE 25, 1
PRINT STRING$(79, " ");
LOCATE 24, 1
rem EXIT SUB
END
Odata:
DATA "Yes, if you are creative."
DATA "Yes, if you are receptive."
DATA "Anything is possible, but you will have a difficult start."
DATA "What a youthful folly to ask!"
DATA "You must wait and ask again."
DATA "Only conflict will come of the result, please pray."
DATA "It will take many who are organized to accomplish your request."
DATA "Yes, if you keep it together."
DATA "Be meek and you will get your answer."
DATA "You are lucky to get this far!"
DATA "You must have the fellowship of men."
DATA "In great measure will the possession result."
DATA "One must be modest to attain their goal."
DATA "You will do good to have enthusiasm for your quest."
DATA "Let someone else take the lead to your quest."
DATA "Atone for what has been spoiled, then reask your question."
DATA "You are too far away to get the answer."
DATA "Meditation will lead you to your answer."
DATA "Bite through to your goal."
DATA "If you handle life with grace!"
DATA "There is to be a coming apart for fate to be realized."
DATA "All must return to what is."
DATA "Not knowing the true answer will be better."
DATA "You must tame the power of the great."
DATA "Watch the corners of the mouth."
DATA "The greatest preponderance will be fate."
DATA "It will be the abysmals, sorry!"
DATA "You will be lucky to hold on to what you have."
DATA "Influence will be the steeping stone to your quest."
DATA "Just be patient for a while."
DATA "It is a time for getting away."
DATA "The power of the great is upon you."
DATA "Yes, there is a progression to be attained."
DATA "The crytal ball is losing light and no answer may be attained now."
DATA "Everyone close will be part of your answer."
DATA "No, there is too much opposition."
DATA "Not likely, there are obstructions in the way."
DATA "Yes, deliverance will come."
DATA "Not as much as you might as supposed."
DATA "Yes and more than was planned."
DATA "Yes, if there is a breakthrough."
DATA "Maybe if you come to meet."
DATA "Now is the time to gather together for the answer."
DATA "Yes, only if there is a push upward."
DATA "No, oppression will stop your quest."
DATA "Yes, no, and maybe......."
DATA "What the oracle says is opposite to your true answer."
DATA "The answer will take longer and you will pay for the wait."
DATA "Only through an arousing!"
DATA "It is not time for a move, you must keep still."
DATA "Let fate develop as it will."
DATA "You must see the marrying maiden first."
DATA "More than you ever imagined."
DATA "You may wonder and wander, but it is time to move."
DATA "Only if you act gently."
DATA "Yes, with great joy!"
DATA "No, so you must let go of it to spread out."
DATA "Only with limitations."
DATA "Look within yourself and you can find the answer."
DATA "Only with preponderance of the small."
DATA "It will come to be after completion."
DATA "Only before completion."
DATA "I love Elizabeth!"
DATA "Only God knows..."
Php Version (in Progress).
oracle.html:
[code]
<html>
<body>
<center><h1>The Oracle</h1><center>
<hr>
<form method="post" action="oracle.php">
Enter your question of the future to the oracle:
<br>
<br>
<input type="text" name="message" />
<input type="submit" />
</form>
<br>
<br>
When you press submit, this page will disappear. Then after cogitating, the Oracle will give you the answer,
<hr>
</body>
</form>
[/code]
oracle.php
[code]
<html>
<body>
<center><h1> The Oracle</h1></center>
<hr>
Your question was:
<br>
<center>
<?php echo $_POST["message"]; ?>
</center>
<br>
Your answer is:
<br>
<br>
<center>
<?PHP
$lines = file('odata');
// Loop through our array
.
foreach ($lines as $line) {
}
echo $lines[rand(1,63)] . "<br />";
?>
</center>
<hr>
</body>
<html>
[/code]
odata:
you can use the original odata file. Just make sure it is in the same directory (unless you change the code to reflect the real location).
Bonus Game 1: Dr. Bash.
$ chmod +x eliza
To run the batch file use:
$ ./eliza
[code]
echo "WELCOME TO DR. BASH'S COUCH"
while [ "1" = "1" ]
do
read line
line=`echo $line | tr "[a-z]" "[A-Z]" |
sed 's/^/ /; s/$/ /; s/\./ /g
s/ I / i /g; s/ YOU ARE/ you are/g; s/ AM / am /g; s/ ME / me /g
s/ YOU / you /g
s/ MY / my /g; s/ YOUR / your /g; s/ MINE / mine /g; s/ ARE / are /g
s/ me / YOU /g; s/ my / YOUR /g; s/ your / DR. BASHS /g;
s/ i / YOU /g; s/ am / ARE /g;s/ mine / YOURS /g; s/ are / IS /; s/ you / DR. BASH /
s/^ //; s/ $//'`
echo "$line"
case "$line" in
*YOU\ ARE\ *) echo "`echo $line |
sed 's/^.*YOU\ ARE/WHY DO YOU THINK YOU ARE/' `?" ;;
*YOU\ HAVE\ *) echo "`echo $line |
sed 's/^.*YOU\ HAVE/HOW LONG HAVE YOU HAD/'`?" ;;
YOU*) echo "WHEN DID YOU FIRST REALIZE THAT $line?" ;;
*BECAUSE*) echo "IS THAT REALLY THE REASON?";;
*DO\ DR.\ SPOCK\ THINK*) echo "CAN YOU ANSWER THAT YOURSELF?";;
GO*|EAT*|TRY*|HELP*|PUT*) echo "WHY DO YOU WANT ME TO $line?";;
YES*) echo "HOW CAN YOU BE SURE?";;
NO*) echo "TRY NOT TO BE SO NEGATIVE.";;
*MOTHER*|*FATHER*|*BROTHER*|*SISTER*) echo "TELL ME MORE ABOUT YOUR FAMILY.";;
WHY*|WHO*|WHAT*|HOW*) echo "YOU TELL ME `echo $line | sed s/?/./g`";;
QUIT) exit;;
*) echo "WHY DO YOU SAY $line?";;
esac
done
[/code]
Bonus Game 2: Akalabeth Re-Bourne
You can download it from here. https://code.google.com/p/akalabeth-rebourne/downloads/detail?name=akr-0.2.tar.gz&can=2&q=
Instructions are included in the download.
Downloads
Modded Dos Animation.
Thought I might try a possible nix version of a dos animation?[
[code]
# case matters
clear
echo " HI, I AM STICK MAN"
echo "."
echo " O"
echo " -[]-"
echo " /\\"
read a
clear
echo " I KNOW Kung-fu! HI YA!"
echo "."
echo " O l l o "
echo " -[]- -[]-"
echo " /\\____________/\___L_____o "
read a
clear
echo " poor man, boo hoo (puts weopon down)"
echo "."
echo " O"
echo " -[]-"
echo " /\\ l_______________L______o"
read a
clear
echo "Lets pick him up"
echo ". "
echo " O"
echo " []-L"
echo " _____________/\\__\_____o_______"
read a
clear
echo " ARG!"
echo " L"
echo " ii"
echo " O"
echo " []"
echo " /\\"
read a
clear
echo " WOOPS!!!!"
echo "."
echo " o"
echo " []__" _
echo " O"
echo " []-"
echo " _______________/\\"
read a
clear
echo " AHHHHHH!"
echo " ______ ________"
echo " I [] I I [] I"
echo " I [] I o I [] I"
echo " I [] I []__ I [] I"
read a
clear
echo " AHHHHHH! (cont.)"
echo " ______ ________"
echo " I[] I I[][] I"
echo " I []I o I []I"
echo " I[] I []__ I [] I"
read a
clear
echo " BOOM (hits wall)"
echo " 1"
echo " 1 O"
echo " 1[]__"
echo " 1"
echo " 1"
read a
clear
echo " OWWWW!!!!!! leaves impression in wall and is covered in debris"
echo "."
echo " 1"
echo " 1"
echo ". "
echo " L[[[[[]o"
read a
clear
echo " stick man to the rescue"
read a
clear
echo " picks man up, brushes him off, and sets him on his feet (he is wearing a cape)"
echo "."
echo " o O _____"
echo " []-[] "
echo " L II"
read a
clear
echo " Stick man says: Let's be friends"
echo " the dude says: sure"
echo " and they were friends, they shook on it"
echo "."
echo " o O "
echo " []\\/[] "
echo " L II"
read a
clear
echo " THE END"
read a
clear
echo " movie made by LEVO GAMES and modded by computothought"
read a
exit
[/code]
Astrology
Yet another program to play with: http://www.astrowin.org/anonymous/AstroSrc%20-%20v134%20source%20code.zip