public Behaviors(World world) { this.world = world; BehaviorList = new Dictionary<int, string>(); ranGen = new Random(); moveMod = 1; turnMod = 0.04; energyMod = 0.5; blacklistMethods = new List<String>(); createMethodBlacklist(); int index = 0; //Constructing the dictionary of possible actions foreach (var method in GetType().GetMethods()) { //Ignore operations that aren't related to an organism. if (!blacklistMethods.Contains(method.Name)) { BehaviorList.Add(index, method.Name); index++; } } }
public OrganismManager(Behaviors behaviors, World world, Random ranGen) { this.world = world; this.ranGen = ranGen; readConfig(); maxSpeed = 1.5; defaultGenSize = 30; extinctionCarryOver = 15; this.behaviors = behaviors; genDirectory = "Organisms"; organismTerminate = "[/Organism]"; behaviorsInitiate = "[Behaviors]"; constantsInitiate = "[Constants]"; if(!System.IO.Directory.Exists(genDirectory)) { Directory.CreateDirectory(genDirectory); } if(!File.Exists(genDirectory + "//" + "Organisms.txt")) { List<Organism> defaultOrganisms = new List<Organism>(); //Add 10 random organisms for(int i = 0; i<defaultGenSize;i++) { defaultOrganisms.Add(newRandomOrganism()); } writeOrganismsToFile(defaultOrganisms); } activeOrganisms = new List<Organism>(); deadOrganisms = new List<Organism>(); genOriginals = new List<Organism>(); OnExtinction += OrganismManager_OnExtinction; }
public FoodManager(World world, Random ranGen) { //The maximum amount of food that can exist within any particular cell arrayDepth = 10; //The span of the grid gridSize = 50; this.ranGen = ranGen; foodGrid = new Food[gridSize, gridSize, arrayDepth]; activeFood = new List<Food>(); this.world = world; ranGen = new Random(); maxFood = 100; }
public MainWindow() { //Decide Window Height/Width windowHeight = 760; windowWidth = 760; InitializeComponent(); //Initializing the main clock mainClock = new Timer(); mainClock.Interval = 1; //Force the window to match the size of the content this.SizeToContent = SizeToContent.WidthAndHeight; //Initialize the canvas canvas = new Canvas(); //Set the canvas size to the desired window width and height. canvas.Width = windowWidth; canvas.Height = windowHeight; canvas.Background = new SolidColorBrush(Colors.Black); //Display the canvas on the window this.Content = canvas; //As the last thing after inital setup, start the main clock. mainClock.Elapsed += mainClock_Elapsed; foodVisuals = new List<FoodVisual>(); organismVisuals = new List<OrganismVisual>(); world = new World(); world.getOrganismManager().OnOrganismAddition += MainWindow_OnOrganismAddition; world.getFoodManager().OnFoodAddition += MainWindow_OnFoodAddition; mainClock.Start(); world.getFoodManager().createInitialFood(); world.getOrganismManager().loadOrganismsFromMemory(); }