public void HawkAgainstHawkHasAWinnerAndALoser() { var hawk1 = new Bird(BirdType.Hawk); var hawk2 = new Bird(BirdType.Hawk); var confrontation = new ConfrontationResolver(WinPayOff, TimeWastingPenalty, LosingPenalty); confrontation.Resolve(hawk1, hawk2); Assert.Equal(WinPayOff - LosingPenalty, hawk1.LifePoints + hawk2.LifePoints); }
public void DoveAlwaysLosesToHawkByWalkover() { var hawk = new Bird(BirdType.Hawk); var dove = new Bird(BirdType.Dove); var confrontation = new ConfrontationResolver(WinPayOff, TimeWastingPenalty, LosingPenalty); confrontation.Resolve(dove, hawk); Assert.Equal(WinPayOff, hawk.LifePoints); Assert.Equal(0, dove.LifePoints); }
public void DoveAgainstDoveWastesTimeButOneWins() { var dove1 = new Bird(BirdType.Dove); var dove2 = new Bird(BirdType.Dove); var confrontation = new ConfrontationResolver(WinPayOff, TimeWastingPenalty, LosingPenalty); confrontation.Resolve(dove1, dove2); Assert.Equal(WinPayOff - 2 * TimeWastingPenalty, dove1.LifePoints + dove2.LifePoints); }
static void Main(string[] args) { var outputFilePath = args.Length > 0 ? args[0] : defaultOutputFilePath; IConsole logger = new ConsoleLogger(); ConfrontationResolver confrontationResolver = new ConfrontationResolver(WinPayOff, timeWastingPenalty, losingPenalty); Population initialPopulation = new Population(startDoves, startHawks); using (TextWriter outputStream = new StreamWriter(File.Open(outputFilePath, FileMode.Create, FileAccess.Write, FileShare.Read))) { var simulation = new Simulation(initialPopulation , new BreedingSeasonFactory(confrontationsPerSeason , confrontationResolver , logger) , breedingSeasons , outputStream); simulation.Run(); } }