ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I was really board while traveling so I converted this little program to bash that sort of emulates the little black balls that can predict your future. I originally wrote it in basic for TRS-80 magazine years ago.
---------------------------------------------------------
Here is a simple game in Bash scripting language that comes with linux for the command line. it will be in two parts. The command or program file and the data file which can be easily edited with vim. Once you save the program you will have to issue the command chmod +x oracle (or the name of the file you save it as).
Quote:
Oracle:
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 "Computoman: 1980 - 2009"
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 "Computoman: 1980 - 2009"
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.
####################################
Odata
Code:
Yes, if you are creative.
Yes, if you are receptive.
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 steeping 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 crytal 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...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.