#!/usr/bin/python -i
""" npc.py
Copyright (C) 1998 Aloril
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.
"""
import time
import const,defworld
from event import *
from imind import imind
from mind import mind
class mind_edit:
def __init__(self,mind):
self.mind=mind
def send_events(self,input):
return self.mind.mind.run_step(self.mind.time,input)
class npc(imind):
def __init__(self, name):
imind.__init__(self,name,1,"farmer",xyz=(-50,-50,defworld.village_height))
self.mind=mind(self.id)
self.map.things[self.id]=self.mind
self.send_events([event('look',what=self.mind)])
self.init_mind_goals()
self.prev_time=`self.time`
def init_mind_goals(self):
medit=mind_edit(self)
e=defworld.editor(medit)
e.learn(self.mind,defworld.goals)
def run(self):
while 1:
input=[]
while self.prev_time==`self.time`:
input=input+self.receive_events()
time.sleep(const.client_sleep)
output=self.mind.run_step(self.time,input)
print self.id,self.time,input,output
self.send_events(output)
self.prev_time=`self.time`
if __name__=="__main__":
c=npc("Ali")
c.run()
               (
geocities.com/siliconvalley/station/4279)                   (
geocities.com/siliconvalley/station)                   (
geocities.com/siliconvalley)