public Health(Life life, double value) { this.Name = "Health"; this.Description = "The health rate of the life, and it will die when the healty is empty."; this.Life = life; this.value = value; Empty = new Stimulus(life, life.NoReactionStimulus); life.BuildReaction(Empty, life.Behaviours[Behaviours.Action.Die.TypeID]); Low = new Stimulus(life, life.NoReactionStimulus); life.StimulusList.Add(Low); }
public void Stimulate(Stimulus stimulus, params object[] args) { if (stimulus == null) { throw new ArgumentNullException(); } if (this.PendingStimulus.Count > 200) { return; } this.PendingStimulus.Enqueue(new PendingStimulus(stimulus, args)); }
private void cloneReaction(Stimulus stimulusFrom, Stimulus stimulusTo, Life life) { var behaviorList = new List <Behaviour>(); foreach (var reaction in stimulusFrom.Reactions) { foreach (var behaviors in reaction.Behaviours) { behaviorList.Add(behaviors.Clone(life)); } } life.BuildReaction(stimulusTo, behaviorList.ToArray()); }
public ReactionRecord(Stimulus stimulus, Reaction reaction) { if (stimulus == null) { throw new ArgumentNullException("The Stimulus cannot be null."); } if (reaction == null) { throw new ArgumentNullException("The reaction cannot be null."); } this.Stimulus = stimulus; this.Reaction = reaction; }
public Stimulus(Life life, Stimulus noReaction) { if (life == null) { throw new ArgumentNullException("The life cannot be null."); } this.Life = life; this.NoReaction = noReaction; this.ID = life.World.CreateStimulusID(); this.Name = "Stimulus-" + this.ID; this.Description = "A stimulus."; life.StimulusList.Add(this); }
public Reaction BuildReaction(Stimulus stimulusSource, params Behaviour[] behaviors) { if (stimulusSource == null || behaviors == null) { throw new ArgumentNullException(); } if (!this.StimulusList.Contains(stimulusSource)) { throw new Exception("Stimulus no available."); } var reaction = new Reaction(this, stimulusSource); stimulusSource.Reactions.Add(reaction); this.ReactionList.Add(reaction); return(reaction); }
public Reaction(Life life, Stimulus source) { if (life == null) { throw new ArgumentNullException("The life cannot be null."); } if (source == null) { throw new ArgumentNullException("The source cannot be null."); } this.Life = life; this.Source = source; this.behaviours = new LifeGameX.RandomList <LifeGameX.Behaviour>(); this.Description = "A reaction when " + this.Life + " is stimulated by " + this.Source.Name + " . "; life.RandomWeightList.Add(this); }
public Stimulus(Life life, Stimulus noReaction) { if (life == null) { throw new ArgumentNullException("The life cannot be null."); } /*if (noReaction == null) * throw new ArgumentNullException("NoReaction stimulus required.");*/ this.Reactions = new RandomList <Reaction>(); this.Life = life; this.NoReaction = noReaction; this.ID = life.World.CreateStimulusID(); this.Name = "Stimulus-" + this.ID; this.Description = "A stimulus."; life.StimulusList.Add(this); }
public void Stimulate(Stimulus stimulus, params object[] args) { this.PendingStimulus.Enqueue(new PendingStimulus(stimulus, args)); }
public PendingStimulus(Stimulus stimulus, object[] args) { this.Stimulus = stimulus; this.Args = args; }