The World class represents the world state in the simulation. It contains all the lifelets, food and messages. It also keeps track of statistics and is responsible for spawning all the lifelets.
 public Obstacle(World world, Vector pos)
 {
     // Init
     _world = world;
     _uid = _gid++;
     _pos = pos;
 }
 public ShelledLifelet(Lifelet lifelet, World world)
 {
     // Init
     _lifelet = lifelet;
     _world = world;
     _validWorldAge = _world.Age;
 }
 public RandomLifelet(World world, Vector pos)
     : base(world,pos)
 {
     // Init
     _direction = new Vector(this.RandomGen.Next(-1,2),this.RandomGen.Next(-1,2));
     _speed = 2.0;
 }
Esempio n. 4
0
 public Food(World world, Vector pos, double energy)
     : base(world,pos)
 {
     // Init
     _energy = energy;
     _maxAge = Math2.JitteredValue(Config.FoodMaxAge,Config.FoodMaxAgeJitter);
 }
 public Message(World world, char contents, Lifelet sender)
     : base(world,sender.Position)
 {
     // Init
     _contents = contents;
     _maxAge = Math2.JitteredValue(Config.MessageMaxAge,Config.MessageMaxAgeJitter);
     _sender = sender;
 }
        private double _speed; // Our speed we want

        #endregion Fields

        #region Constructors

        public CannibalLifelet(World world, Vector pos)
            : base(world,pos)
        {
            // Init
            _speed = 1.0;

            // Initial message to find each other
            talk('!');
        }
        private double _speed; // Our speed we want

        #endregion Fields

        #region Constructors

        public SnakeLifelet(World world, Vector pos)
            : base(world,pos)
        {
            // Init
            _direction = new Vector(this.RandomGen.Next(-1,2),this.RandomGen.Next(-1,2));
            _speed = 2.0;

            // Initial message to find each other
            talk('!');
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LifeSimulation.Core.Lifelet"/> class.
 /// </summary>
 public Lifelet(World world, Vector pos)
 {
     // Init
     _world = world;
     _uid = _gid++;
     _pos = pos;
     _vel = new Vector(0,0);
     _velReq = new Vector(0,0);
     _color = (Color)world.Statistics[this.Type + "_Color"]; // We assign a fixed color based on the value kept in the statistics
     _age = 0;
     _health = Config.LifeletInitialHealth;
     _energy = Config.LifeletInitialEnergy;
 }