public Abiotic.Abiotic GetNewAbiotic(Type abioticType) { var x = RandomHolder.GetInstance().Random.Next(1, World.XMax); var y = RandomHolder.GetInstance().Random.Next(1, World.XMax); var newAbiotic = Activator.CreateInstance(abioticType, x, y); return(newAbiotic as Abiotic.Abiotic); }
public Plant.Plant GetNewPlant(Type plantType) { var x = RandomHolder.GetInstance().Random.Next(1, World.XMax); var y = RandomHolder.GetInstance().Random.Next(1, World.XMax); var health = RandomHolder.GetInstance().Random.Next(1, Plant.Plant.MaxHealth); var newPlant = Activator.CreateInstance(plantType, x, y, health); return(newPlant as Plant.Plant); }
public Animal.Animal GetNewAnimal(Type animalType) { var x = RandomHolder.GetInstance().Random.Next(1, World.XMax); var y = RandomHolder.GetInstance().Random.Next(1, World.XMax); var gender = (Gender)RandomHolder.GetInstance().Random.Next(0, 1); var consumptionType = RandomHolder.GetInstance().Random.Next(0, 1) == 0 ? ConsumptionType.Vegan : ConsumptionType.Predator; var newAnimal = Activator.CreateInstance(animalType, x, y, gender, consumptionType); return(newAnimal as Animal.Animal); }
public override Intention RequestIntention() { RandomDelta = RandomHolder.GetInstance().Random.Next(-1, 2); while (RandomDelta == 0) { RandomDelta = RandomHolder.GetInstance().Random.Next(-1, 2); } var rand = RandomHolder.GetInstance().Random.Next(2); if (rand == 0) { return(new Intention { DeltaX = 0, DeltaY = (RandomDelta * Speed) }); } return(new Intention { DeltaX = (RandomDelta * Speed), DeltaY = 0 }); }
public void SetHealth() { Health = RandomHolder.GetInstance().Random.Next(1, 10); }
public int GetRandomHealth() { return(RandomHolder.GetInstance().Random.Next(1, 10)); }
public int GetRandom() { return(RandomHolder.GetInstance().Random.Next(1, World.XMax)); }
public int[,] SudokuMapBuilder() { Start: int[,] Map = new int[9, 9]; int mapCounter = 1; List <int[, ]> mapHolder = new List <int[, ]>(); RandomNumberCorector randomNumberCorector = new RandomNumberCorector(); List <NumberCorectorValueTypes> NumberCorectorsList = new List <NumberCorectorValueTypes>(); RandomNumber randomNumber = new RandomNumber(); MapContainer mapContainer = new MapContainer(); int i = 0; int indexi = 0; int j = 0; int indexj = 0; int indexjComparer = 3; int countSquares = 0; int FailFailCount = 0; int mapCounter_A = 0; int mapCounter_B = 0; int countRow = 0; int countColumn = 0; bool ifStartsNewSquare = false; int failCount = 0; int numberCheck = 0; int countMapCounterAtempts = 0; RandomHolder = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; for (i = indexi; i < Map.GetLength(0); i++) { countRow++; for (j = indexj; j < indexjComparer; j++) { countColumn++; if (countColumn > 3) { countColumn = 1; } do { numberCheck = randomNumber.Get(countRow, countColumn, randomNumberCorector, NumberCorectorsList, RandomHolder); if (numberCheck == 666 || randomNumberCorector.TotalImposibleFromHolderList(numberCheck, NumberCorectorsList)) { ifStartsNewSquare = true; if (mapCounter > mapHolder.Count) { mapCounter = 1; } failCount++; mapCounter_A = mapCounter; if (mapHolder.Count == 8 && failCount == 1) { FailFailCount++; } if (failCount > 1) { mapCounter++; failCount = 0; } if (FailFailCount == 5) { mapCounter = 5; mapHolder.RemoveRange(mapHolder.Count - 5, 5); FailFailCount = 0; } mapCounter_B = mapCounter; mapContainer.Get(mapHolder, ref Map, mapCounter); RandomHolder = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; if (mapCounter_A != mapCounter_B) { NumberCorectorsList = new List <NumberCorectorValueTypes>(); } MapStepBack.SetIndexersToProperPpositions(Map, ref i, ref j, ref indexi, ref indexj, ref indexjComparer, ref countRow, ref countSquares); randomNumberCorector.RemoveSquareNumbers(ref NumberCorectorsList); countColumn = 0; break; } else { Map[i, j] = numberCheck; } } while (NumberChecking.NumberDuplicate(Map, Map[i, j], ref randomNumberCorector, ref NumberCorectorsList, countRow, countColumn, j)); if (ifStartsNewSquare == false) { RandomHolder.Remove(Map[i, j]); } ifStartsNewSquare = false; } if (countRow == 3) { countMapCounterAtempts++; NumberCorectorsList = new List <NumberCorectorValueTypes>(); CountTry++; if (CountTry > 30) { CountTry = 0; goto Start; } mapContainer.Add(Map, ref mapHolder); mapCounter = 1; countSquares++; if (countSquares == 3 && indexi + 3 < Map.GetLength(0)) { countSquares = 0; indexi += 3; indexj = 0; indexjComparer = 3; countRow = 0; RandomHolder = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; } else { RandomHolder = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; if (i == 5) { i = 2; } else if (i == 8) { i = 5; } else { i = -1; } if (i != 8 && j != 9) { indexjComparer += 3; } else { i = Map.GetLength(0); } indexj += 3; countRow = 0; } } } return(Map); }
public void SetGender() { Gender = RandomHolder.GetInstance().Random.Next(0, 2) == 0 ? Gender.Male : Gender.Female; }