%------------------------------------------------------------ % File "main.t". % % Written by Phil Edmonds, Feb 97. % % This is the main file that runs the artificial life simulation. % It creates and initializes the world, then adds a few creatures. % Then it asks the world to start the simulation import World in "world.ti", SimVar in "simvar.tu", Mousey in "mouse.tu", Herbivore in "herbivor.tu", Refresher in "refresh.tu", FamilyTree in "ftree.tu" % instantiate, initialize, and draw the world var w : ^World new w w -> Init w -> DrawWorld % create and add a mouse to the world var a : ^Mousey new a a -> InitMousey (SimVar.W_MAX_X div 2, SimVar.W_MAX_Y div 2, "Benji") a -> JoinWorld (w) var ft : array 1 .. SimVar.HERBS_TO_START of ^FamilyTree % create and add some herbivores for count : 1 .. SimVar.HERBS_TO_START new ft (count) var h : ^Herbivore new h h -> InitHerbivore (SimVar.W_MAX_X div 2, SimVar.W_MAX_Y div 2, "Herbie" + intstr (count), ft (count)) h -> JoinWorld (w) % initialize the family tree for this one ft (count) -> Init (h) % increment the statistic w->AddStatistic("Herbivores at start") end for % create a refresher, so that the screen is touched up once in awhile var r : ^Refresher new r r -> InitRefresher ("refresher", 20) r -> JoinWorld (w) %---------------------------------------------------------------------- % AND NOW, THE SIMULATION! % randomize () w -> Simulate (SimVar.MAXTIME) for count : 1 .. SimVar.HERBS_TO_START var stream : int open : stream, "ftree" + intstr (count) + ".out", put ft (count) -> Prnt (stream) var d, t : string date (d) time (t) put : stream, "Timestamp: ", d + " " + t close : stream end for % clean up (print stats) w -> Fini