private BrainCommand CommandInReproductionState(BrainInput data) { int emptyCellDirection; if (data.Health < h1) { State = BrainState.LowHealth; return(new BrainCommand(CreatureAction.Go, FindMostSafeCell(data.Cells))); } else if (data.Energy <= e2) { State = BrainState.Normal; return(CommandInNormalState(data)); } else if ((emptyCellDirection = FindSafeCellForChild(data.Cells)) >= 0) { State = BrainState.Normal; return(new BrainCommand(CreatureAction.Reproduce, emptyCellDirection)); } else if (data.Cells[0].StandingCreatures.Count == 1) { return(new BrainCommand(CreatureAction.Go, FindMostSafeCell(data.Cells))); } else { return(new BrainCommand(CreatureAction.Hit, 0)); } }
private BrainCommand CommandInLowHealthState(BrainInput data) { if (data.Health >= h1) { if (data.Energy > e2) { State = BrainState.Reproduction; return(CommandInReproductionState(data)); } else if (data.Energy < e1) { State = BrainState.LowEnergy; return(CommandInLowEnergyState(data)); } else { State = BrainState.Normal; return(CommandInNormalState(data)); } } else { return(new BrainCommand(CreatureAction.Go, FindMostSafeCell(data.Cells))); } }
private BrainCommand CommandInNormalState(BrainInput data) { if (data.Health < h1) { State = BrainState.LowHealth; return(new BrainCommand(CreatureAction.Go, FindMostSafeCell(data.Cells))); } else if (data.Energy < e1) { State = BrainState.LowEnergy; return(new BrainCommand(CreatureAction.Eat, 0)); } else { if (ContainsMorePowerfulCreature(data.Cells[0].StandingCreatures)) //на клетке жука стоит жук сильнее { return(new BrainCommand(CreatureAction.Go, FindMostSafeCell(data.Cells))); } else if (data.Cells[0].StandingCreatures.Count > 1 && data.Cells[0].StandingCreatures.Count(x => x.Alpha != Alpha) > 0) { return(new BrainCommand(CreatureAction.Hit, 0)); } else if (data.Energy > e2) { int emptyCell = FindSafeCellForChild(data.Cells); if (emptyCell >= 0) { return(new BrainCommand(CreatureAction.Reproduce, emptyCell)); } else { State = BrainState.Reproduction; return(new BrainCommand(CreatureAction.Go, FindMostSafeCell(data.Cells))); } } else if (data.Cells[0].FoodCount < CreatureParameters.FoodAbsorbCostPerUnit * absorbAble) //нет еды на своей клетке { return(new BrainCommand(CreatureAction.Go, FindMostSafeCell(data.Cells))); } else { return(new BrainCommand(CreatureAction.Eat, 0)); } } }
public BrainCommand Process(BrainInput data) { if (State == BrainState.Normal) { return(CommandInNormalState(data)); } else if (State == BrainState.Reproduction) { return(CommandInReproductionState(data)); } else if (State == BrainState.LowEnergy) { return(CommandInLowEnergyState(data)); } else { return(CommandInLowHealthState(data)); } }
private BrainCommand CommandInLowEnergyState(BrainInput data) { if (data.Health < h1) { State = BrainState.LowHealth; return(new BrainCommand(CreatureAction.Go, FindMostSafeCell(data.Cells))); } else if (data.Energy >= e1) { State = BrainState.Normal; return(CommandInNormalState(data)); } else { if (data.Cells[0].FoodCount > 0.3 * absorbAble) { return(new BrainCommand(CreatureAction.Eat, 0)); } else { return(new BrainCommand(CreatureAction.Go, FindMostSafeCell(data.Cells))); } } }