Summon a Robot AI Mind for MSIE 5 into your presence with MSIE.

The Alife Mind-Module or Main Program Loop

1. Theory of Seed AI Algorithm Steps: Code the Main Alife Loop

   /^^^^^^^^^\ Artificial aLife Rejuvenates Itself /^^^^^^^^^\
  / visual    \                                   / ________  \
 /  memory     \      | | |        | | | | |     / / audSTM \  \
|   _______     |     | | |        | + | | |    | /  vault   \  |
|  /image  \    |     | | |        | | | + |    | \__________/  |
| / percept \---|-------+ |        | | | | +    |oldest memories|
| \ engram  /   |    a|C|f|        | | + | |    |to be forgotten|
|  \_______/    |    b|O|i|        + | | | |    |               |
|               |    s|N|b|        | | | + |    |bulk of memory |
|               |    t|C|e|        | + | | |    |to be recycled |
|               |    r|E|r|        + | | | |    |periodically by|
|               |    a|P|s|        | | | | +    |backwards shift|
|   _______     |    c|T| |        | | + | |    |   ________    |
|  /fresh  \    |    t|_|_|_       |_|_|_|_|    |  /        \   |
| / image   \   |    /Psi   \-----/ English \---|-/ auditory \  |
| \ engram  /---|---/concepts\---/  lexicon  \--|-\ phonemes /  |
|  \_______/    |   \________/   \___________/  |  \________/   |
Decision-Tree of Mind-Design

Diagram of the Main Alife Program Loop

            ___________                    ___________           
           /           \                  /           \          
          /  Motorium   \                /  Security   \         
          \_____________/\    ______    /\_____________/
       __________         \  /      \  /          _________
      /          \         \/  main  \/          /         \
     (  Volition  )--------<   Alife  >---------( Sensorium )
      \__________/         /\  loop  /\          \_________/
           _____________  /  \______/  \  _____________
          /             \/              \/             \
          \    Think    /                \   Emotion   /
           \___________/                  \___________/

A diagram from AI4U page 157 is a framework of Mind.

Code the Alife loop shown above in your chosen programming language.
Use either an actual loop with subroutine calls, or make a ringlet
of perhaps object-oriented module stubs, each calling the next stub.
Provide the ESCAPE key or other mechanisms for the user to stop the AI.
Spread your code around the Web and invite AI coders to expand on it.
Watch for a proliferation of unique AI Mind entities evolving rapidly
on the Web and competing genetically for the survival of the fittest.

The first step in coding an artificial Mind in a given programming
language XYZ is to write a simple xyzmind Alife loop that cycles
through the following stubs and requires a user input for each cycle:
- Security
- Sensorium
- Emotion
- Think
- Volition
- Motorium.

Each stub will later be a branching call to the named function or
subroutine. This particular list of mind-module stubs is intended
to be a standard for the coding of AI Minds, but you the AI coder
are free to deviate from the standard, especially to improve it.
The stubs are ordered in their particular sequence for reasons of
synergy in the serial simulation of massively parallel processing
(MPP), but you are free to re-order the sequence as you create AI.

You may demonstrate on-screen how the main Alife mind-loop cycles
through each stub, by showing the user a tutorial message such as,
"The Sensorium function will be called at this point in the loop."

A time-delay during each message may prevent an unreadable blur,
if the loop would otherwise cycle too fast for human users to read.
You may choose whether to let the stub-messages 1) scroll down the
screen by cycling repeatedly, or 2) fill the screen as a list of
all the stubs once per cycle, or 3) occupy the whole screen briefly
as a statement of which module is to be called -- with or without
a graphic image or animation of the subroutine about to be called.

At least once per Alife cycle, and preferably at the point where
the Sensorium stub is to be displayed or highlighted, you should
code either a program pause or a slow delay to give the embryonic
Mind a chance to receive a minimum of input from the environment.
If your Sensorium message asks the human user to press the RETURN
key, then you are already on the way to more advanced coding where
the user will end any sentence of input by pressing the RETURN key.

An alternative would have been to ask the user to "press any key"
or to press the SPACE bar, but by asking for a carriage-return you
may quickly train every user to end all input by pressing RETURN.
Thus if your early code anticipates the requirements of later code,
then both you and your users may enjoy a smoother path to true AI.

Please host your emerging xyzmind main Alife loop code out on the
Web as free AI source code with an explicit message permitting AI
enthusiasts anywhere to copy, tweak, rework and improve upon your
initial contribution. If you have the expertise to code the Alife
loop of subordinate module stubs in several programming languages,
put each AI embryo on the Web as a unique file along the lines of
"xmind.html" or "ymind.html" or "zmind.html" and so on. Do try to
web-host the perfect Alife stub-loop without including any of the
actual subroutines or function-calls among the bare-bone stubs of
the Alife mind-loop source code. As you then code further, use a
separate file and a separate webpage to show one of many pathways
of further evolution of the xyzmind.

Do not worry that someone may web-post a better, or flashier, or
more elegant main Alife loop than you do in your chosen language.
The very presence of multiple xyzmind initiatives on the Web will
encourage programmers in the XYZ programming language to look at
all the offerings before changing the world by finishing the Mind.

If you have no intention of devoting a large chunk of your life
to coding artificial intelligence in the XYZ programming language
that you know so well, consider putting the first XYZ Seed AI up
on the Web as a Grand Challenge to all XYZ programmers after you.

If you teach a course or write a book on any programming language,
why not cast all your examples and problem code in terms of an AI?
Why not splendidly predispose all your students and readers to be
able to perform the best jobs of the coming AI prosperity engine?

Consider writing grant proposals to fund your collective AI work,
or consider funding your website as an affiliate commercial site.
Communicate and share your results on Usenet or in AI Web forums.

The aLife module is the main program loop at the top level of the
artificial Mind. It is not called "Mind," because the program as
a whole is called "Mind." It is called "aLife" (for "artificial
life") to emphasize the idea that the self-rejuvenating
artificial Mind is a potentially immortal life-form. The "aLife"
designation also serves the memetic purposes of attracting aLife
devotees, of generating results on "aLife" searches in Internet
search engines such as Google, and of legitimizing on-topic
discussion of aLife AI in Usenet and other

2. The Main Alife Loop As the Most Stable Mind-Module

As of the Mind-1.1 release, the content of the aLife module has
stopped fluctuating and has had all extraneous elements "demoted"
into lower modules called by the topmost aLife loop. As a result,
the further evolution of the AI Mind proceeds in the lower
modules while the stable and elegantly simple aLife module serves
to invite translations ("ports") into additional programming
languages, since the first step in porting the AI is to recreate
the main aLife loop in the target language.

Of great help in stabilising and clearly defining the main aLife
loop has been the successful inclusion of a "mind.txt" file as
in the Comprehensive Perl Archive Network (CPAN):

Name           Description
-------------  -------------------------------------------
AI::Mind::     Perl implementation of main AI Mind module.
::Sensorium    Audition; other human/robot input senses.
::Emotion      Quasi-physiological influence upon thought.
::Think        Syntax and vocabulary of natural languages.
::Volition     Contemplative selection of motor options.
::Motorium     Robotic activation of motor initiatives.

Programmers in other languages may envy Perl programmers with respect
to the CPAN archive because it propagates to mirror sites around
the world and carries standardization and orderliness with it.

The mind.txt file proposes AI namespace modules, while Mind.Forth
and the JavaScript AI actually implement the proposed modules as
either working (but still evolving) code or as place-holder stubs.

3. Massive Parallelization Will Render the Alife Loop Obsolete

However stable and permanent the main aLife loop may seem to be,
it remains a primitive imitation of massive parallelism ("maspar")
in a natural, biological brain-mind. Therefore the aLife loop
must eventually stop looping and be replaced with a maspar
mindgrid in which perhaps coordinated but essentially autonomous
processes cooperate as a Minskyan "society of mind" or as parts
whose whole is greater than their sum -- an emergent phenomenon.

Until then, the aLife mind-loop at the top of the artificial Mind
describes in rough measure the actual function of the AI Mind by
listing the ingredient subroutines, which are arranged for very
special reasons in a very special order. Sensorium input at the
beginning leads to Motorium output at the end of the aLife loop.
In between, Emotion reacts to sensory inputs so as potentially
to influence the Think module, which in turn informs the Volition
module with the data necessary to issue orders to the Motorium.

Any museum is welcome to put an immortal Mind-1.1 on display and
thus gain the duh!bious distinction of housing the oldest living
AI veteran, but the real no-nonsense non-senescence will emerge
when Mind-||-MasPar is massively parallel and no longer needs a
serially von Neuman aLife module orchestrating the other modules.

If a museum or a school or a corporation displays a pre-maspar
AI Mind running year in and year out on an extremely stable
operating system (OS), then aLife main loop instances may
survive into the future well beyond the introduction of
massively parallel mindgrids that make the aLife loop obsolete.
Then it may be a mark of distinction for an enterprise to have
a living Mind so ancient that it still makes use of an aLife loop.

4. Alife Code Is Not AI Until the Living Mind Quickens

Whosoever starts an aLife AI loop running has not yet created a
living Mind until the software "quickens" in the nether regions
or subroutines well below the topmost aLife loop. Like a baby
that "quickens" in the womb when its heart begins to pump blood
and fetal motion can be felt, likewise an AI Mind only begins to
function as such when it receives inputs, thinks about them, and
generates linguistic thought or robotic movement as output.
In the software of the AI Mind, the aLife loop is more like a
skeleton than like flesh and blood.

ASCII theory-of-mind diagrams are unique to this AI project.

5. JavaScript Seed AI source code with User Manual
// aLife() (artificial life) is the Robot AI Mind main loop.
function aLife() {  // ATM 27oct2002; or your ID & date.
   Security();  // For human control and operation of the AI.
   Sensorium(); // Audition; other human-robot input senses.
   Emotion();   // Quasi-physiological influence upon thought.
   Think();     // Syntax and vocabulary of natural languages.
   Volition();  // Contemplative selection of motor options.
   Motorium();  // Robotic activation of motor initiatives.
   if (life == true) {  // If the AI has not met with misadventure,
     fyi = "aLife: calling itself; t = "+t+"; rejuvenations = "+rjc;
     Voice(); // Display the Voice:brain "For Your Information".
     TID=window.setTimeout("aLife();",rsvp); // Call aLife again.
   }  // End of quasi-loop time-delay of rsvp-value milliseconds.
} // End of one pass through the aLife Mind that repeats itself.

6. Mind.Forth free artificial general intelligence with User Manual
\ ALIFE (artificial life) is the Robot AI Mind main loop.
:  ALIFE  \ ATM 11mar2005; or your ID & date.
  TIME&DATE byear ! bmonth ! bday ! bhour ! bminute ! bsecond !
  TABULARASA   \ Clears a "clean slate" of memory arrays.
  enBoot       \ English bootstrap loads initial concepts.
  BEGIN        \ Start the main program mind loop running.
    SECURITY   \ For human control and operation of the AI.
    SENSORIUM  \ Audition; other human-robot input senses.
  ( EMOTION    \ Quasi-physiological influence upon thought. )
    THINK      \ Syntax and vocabulary of natural languages. )
  ( VOLITION   \ Contemplative selection of motor options. )
  ( MOTORIUM   \ Robotic activation of motor initiatives. )
  AGAIN        \ Repeat if the AI has not met with misadventure.
; \ End of main module called when user types:  ALIFE [RETURN].

The Mind.Forth User Manual explains how to operate the Forthmind.

A Table of AI Mind Variables explains where, why
and how each variable is used to create Seed AI.

7. Analysis of the Modus Operandi

The aLife (artificial life) module is the main program loop of
the Robot AI Mind in Forth and in JavaScript. It is one of many
loops within the seed AI, and it is not even the topmost loop,
because the program as a whole repeatedly loops through the
rejuvenation process, as a benefit of which the embodiment of
mind does not age, but youthens.

The artificial Mind works by cycling sequentially through brain-
mind functions which are really supposed to be happening all at once
in parallel. Until we have parallel hardware and parallel languages,
the artificial life and AI Mind robotics project must make do
by merely pretending to function with massive parallelism.

Luckily, Forth is inherently a structured-programming language; that
is, Mind.Forth will not even run at any stage in its development
unless you, the programmer, keep your subroutines well-organized
in such a way that each AI function builds upon previously coded
functions already up and running further back in the source code.
You may "stub in" a subroutine so that a higher function will at
least find a lower function, but you may not avoid coding the AI
functionality in a bottom-up, strictly hierarchical architecture.

Paradoxically, Mind.Forth is the software implementation of a top-
down approach to AI, so in Mind.Forth and in the JavaScript version
you have the best of both worlds: a top-down overview of AI, coded
in the best traditions of bottom-up, genetic-algorithm software.

In the release of Mind-1.0 there was a limit on how many engrams
of memory could be filled before the aLife module stopped the AI.
Mind-1.1 features the Rejuvenate module that makes each Robot AI
Mind potentially immortal -- more so in Forth than in JavaScript.

Because the current (circa 2002) AI Mind implementation cycles
through three main mental modalities (thinking; re-entry; sensory
input), the main program loop ALIFE "catches the wave"
of each modality at its top (except that re-entry may be appended
to the thinking or language functions), so you the user/programmer
may also explore each modality from its top level down to details.

For lack of Massively Parallel Processing (MPP), the main loop ALIFE
must cycle one-by-one through the modalities (functions) of a mind
until further evolution through programmer design or autopoiesis.

The Mind.Forth Tabularasa (Latin for "blank slate") provides the empty
memory space analogous to the brain of a newborn child.

The enBoot module loads some initial concepts into the three arrays
of the mindcore "Psi", English lexicon "En", and auditory memory "Aud".
Any item of enBoot has to be carefully coordinated so as to have the
right "flags" that function as synaptic associative tags from one part of
the mindgrid to another. Once the Robot AI Mind is up and running,
the software will automatically create all the flags which earlier
had to be entered so carefully into enBoot by the programmer.

The aLife loop calls the Security module where the human programmer
of the Robot AI Mind may code levels of security or diagnostics
to be observed while the AI is running.

The Sensorium module calls Audition for a user to type in or speak
a message, and Sensorium could branch out not only into the five basic
human senses but also into exotic and humanly impossible senses that
only a robot could have. If there is no human user entering data,
the AI skips the Sensorium module and composes a thought of its own.
Thus the AI may gradually learn reams of data, or explore the Internet,
or communicate with other AI entities.

The Emotion module is only stubbed in and has not yet been implemented.
Its placement between sensing and thinking suggests the idea that we
react emotionally to our sensory perceptions just in time to influence
our thoughts.

The Think module uses the English module to generate thoughts.
There could also be additional natural language subroutines for a
multilingual AI for the purposes of Machine Translation (MT) or
for the simultaneous interpreting of foreign languages by a robot.

The Volition and Motorium modules have not yet been implemented,
but their placement here shows the idea that thinking shapes our will
and that free will controls the motor output of an intelligent being.

8. Troubleshooting and Robotic Psychosurgery

8.1.a. Symptom: In initial stages of coding, the AI Mind goes into an
unwanted infinite loop and there is no obvious way to stop the AI program.
8.1.b. Solution: If necessary, reboot the machine. Afterwards, install
one or more safety features into the code so as to prevent reoccurrence
of the symptom. One mechanism of temporary safety is a snippet of code
that counts how many times a loop has executed, so as to stop and quit
when an arbitrary number of loopings is reached. Advantage: The loop-counter
may be governed with a variable holding a maximum quantity of your choice,
so that you may start low and gradually let the AI run longer and longer
before automatic, sudden death. Drawback: Such a built-in expiration-point
is a negative feature for artificial life and must eventually be removed.
A better and more permanent solution is to implement an intuitive way for
the human user to halt the AI Mind program, such as by pressing [ESCAPE].
Such a response to human input belongs more properly in some other module,
such as Sensorium or Audition, but it makes sense to start all AI coding
with an escape mechanism that migrates as the AI Mind grows more complex.

8.2.a. Symptom: A blur of fast execution prevents the programmer or user
from observing the AI program and watching to see if it operates properly.
8.2.b. Solution: Make the Alife loop stop at an arbitrary point (preferably
in the Sensorium stub or module) and request a minimal human input, such as
pressing the carriage-return [ENTER] key. Triple advantage: Sensorium is a
natural choice for interaction with the user; the user learns to end all
input by pressing [ENTER] or [RETURN]; the user may have a choice of pressing
[ENTER] to keep the program going or [ESCAPE] to halt and quit the program.

8.3.a. Symptom: No behavior is apparent, even while the main
Alife mind-loop seems to be starting and stopping properly. It is not clear
what the AI is doing or whether it is even doing anything.
8.3.b. Solution: Insert temporary messages into any given stub or module to
announce on-screen (or by voice?) that the control of program-flow is passing
through each stub or module. A simple message, e.g., "Now in the Think module",
may be kept ready to use in the code by commenting it out in between sessions
of troubleshooting. If multiple programmers are working on a single AI project,
such diagnostic options permit coders to inform colleagues with progress-reports.
If you are trying to obtain funding from management, the diagnostic messages
may be turned on for the sake of an impressive display and be turned off later.
Coders may choose to implement a system-wide feature of diagnostic messages.

8.4.a. Symptom: Sluggishness in AI operation or a gradual slowdown
of overall responsiveness puzzles the user of the AI at any stage in the coding --
early or primitive; late or advanced.
8.4.b. Solution: The main ALife loop or ringlet of modules may be stacking up
cumulative callings of itself without ever returning properly from sub-modules.
In object-oriented artificial intelligence (OO AI), it may be necessary or
advisable to switch from using a reiterative loop to using a ringlet of otherwise
independent mind-modules that perform their function and then call the next
module in the ringlet serving as a loop. Considerations of timing may be involved
here; that is, a ringlet of object-oriented modules may cope better than a loop
with such time-related problems as generating event-driven responses to inputs.

If you encounter additional symptoms and devise or need solutions, find a
forum such as Usenet and share what you have with other AI programmers.

9. Alife Resources for Seed AI Evolution

Return to top; or to the Mind project sitemap; or to
ai4u_faq.html Frequently Asked Questions (FAQ) about AI4U
ai4udex.html Index of the AI4U Textbook of Artificial Intelligence
aisteps.html AI Algorithm Steps - Artificial Intelligence Algorithms For Humanoid Robots
Mind.html Artificial Intelligence Seed AI in JavaScript
mind4th.html Mind.Forth Artificial Intelligence for Robots
PODsales.html Sales history of the Print-On-Demand AI4U Textbook
The aLife mind-module is the subject of
Chapter 1 in your AI4U textbook of robot AI.
The book AI4U: Mind-1.1 Programmer's Manual
is available for students at prestigious universities in the library collection.
  • Hong Kong University Call Number: 006.3 M981
  • North Carolina State University (NCSU) Call Number: Q335 .M87 2002
  • Texas A&M University
    At your own library you may submit a request for
    the acquisition of AI4U with ISBN 0595654371.