Mind.py

Roman Suzi rnd at onego.ru
Tue Aug 17 11:59:58 EDT 2004


Now it has persistant Memory. Hope it's not a crime ;-)

-><------------------------------------------------------------------

#!/usr/bin/python
# -*- mode: python -*-
# $Id: aLife.py,v 1.1 2004/08/17 15:58:04 rnd Exp $

"""
aLife() (artificial life) is the Robot AI Mind main loop.
"""

import sys, time, os, shelve
from Security import Security
from Sensorium import Sensorium
from Emotion import Emotion
from Think import Think
from Volition import Volition
from Motorium import Motorium
from Voice import Voice

class Mind:
    pass

def TabulaRasa():
   ms = shelve.open("mind", "c")
   ms['mind'] = Mind()
   ms.close()

def RestoreMemory():
   return shelve.open("mind", "c")['mind']

def SaveMemory(m):
    stored = shelve.open("mind", "c")
    stored['mind'] = m
    stored.close()

rsvp = 1000

def aLife():  # ATM 27oct2002 or your ID & date.
    try:
       m = RestoreMemory()
       Security(m)  # For human control and operation of the AI.
       Sensorium(m) # Audition other human-robot input senses.
       Emotion(m)   # Quasi-physiological influence upon thought.
       Think(m)     # Syntax and vocabulary of natural languages.
       Volition(m)  # Contemplative selection of motor options.
       Motorium(m)  # Robotic activation of motor initiatives.
    except:
        raise
        sys.exit(0)
    rjc = int((sys.argv[1:2] or ['0'])[0])
    # If the AI has not met with misadventure,
    fyi = "aLife: calling itself t = %s rejuvenations = %i" % (time.strftime("%Y.%m.%d %H:%H:%S"), rjc)
    print fyi # Display the Voice:brain "For Your Information".
    Voice(m)
    time.sleep(rsvp/1000) # End of quasi-loop time-delay of rsvp-value milliseconds.
    sys.argv[1] = str(rjc + 1)
    SaveMemory(m)
    os.execv(sys.argv[0], sys.argv) # Call aLife again.
# End of one pass through the aLife Mind that repeats itself.

if __name__ == "__main__":
   if sys.argv[1] == '0':
       print "aLife: mind is born"
       TabulaRasa()
   aLife()

# End of aLife.py



More information about the Python-list mailing list