private void MaybeChangeDirection() { if (SealedRandom.NextDouble() < 0.25) { _currentTarget = SealedRandom.Next(0, 4); } }
public override void ResetIteration() { var x = SealedRandom.Next(0, 2) == 0 ? SealedRandom.NextDouble() : -SealedRandom.NextDouble(); var y = SealedRandom.Next(0, 2) == 0 ? SealedRandom.NextDouble() : -SealedRandom.NextDouble(); _currentTarget = SealedRandom.Next(0, 4); _agentPosition = new Tuple <double, double>(x, y); _step = 1; _currentScore = 0; }
private void CreateImages() { _images = new double[TotalTimeSteps][, ]; _smallImageX = SealedRandom.Next(0, 11); _smallImageY = SealedRandom.Next(0, 11); _targetCenters = new Tuple <int, int> [3]; for (int i = 0; i < TotalTimeSteps; i++) { _images[i] = GenerateImage(i); } }
private void CreateSequence() { _sequence = new double[SealedRandom.Next(1, _maxSequenceLength + 1)][]; for (int j = 0; j < _sequence.Length; j++) { _sequence[j] = new double[OutputCount]; for (int i = 0; i < OutputCount; i++) { _sequence[j][i] = SealedRandom.Next(0, 2); } } }
private void CreateSequence(int length) { _sequence = new double[length][]; for (int i = 0; i < _sequence.Length; i++) { _sequence[i] = new double[2]; for (int j = 0; j < 2; j++) { _sequence[i][j] = SealedRandom.Next(0, 2); } } }
protected void CreateSequence() { // determine the poisonous food types of this iteration for each season _poisonousFoodTypes = GetPoisonousFoodTypes(); // create the actual sequence Sequence = new Food[SequenceLength]; // if we are going to change which foods are poisonous during sequence, this is where _poisonFoodShufflePositions = GetPoisonousFoodShufflePositions(); int nextShuffleDayIndex = 0; for (int i = 0; i < Years; i++) { for (int j = 0; j < Seasons; j++) { for (int k = 0; k < _days; k++) { int currentDayIndex = i * Seasons * _days * _foodTypes + j * _days * _foodTypes + k * _foodTypes; // shuffle dem poisons if (_poisonFoodShufflePositions.Count != 0 && k >= _poisonFoodShufflePositions[nextShuffleDayIndex]) { _poisonousFoodTypes = GetPoisonousFoodTypes(); } // create array of foods Food[] foods = new Food[_foodTypes]; for (int l = 0; l < _foodTypes; l++) { Food food = new Food(); food.Type = j * _foodTypes + l; food.IsPoisonous = _poisonousFoodTypes.Contains(food.Type); foods[l] = food; } // shuffle foods foods = foods.OrderBy(x => SealedRandom.Next()).ToArray(); // copy to sequence for (int l = 0; l < _foodTypes; l++) { Sequence[currentDayIndex + l] = foods[l]; } } } } }
public override void ResetIteration() { Debug.DLogHeader("SEASON TASK NEW ITERATION", true); _days = SealedRandom.Next(DaysMin, DaysMax + 1); CreateSequence(); Debug.DLog($"{"Years:",-16} {Years}" + $"\n{"Seasons:",-16} {Seasons}" + $"\n{"DaysMin:",-16} {DaysMin}" + $"\n{"DaysMax:",-16} {DaysMax}" + $"\n{"Foods:",-16} {_foodTypes}" + $"\n{"Max score:",-16} {MaxScore}", true); //Debug.Log($"Sequence:\n{Utilities.ToString(Sequence)}", true); _step = 1; _score = 0d; }
private List <int> GetPoisonousFoodTypes() { List <int> pFoodTypes = new List <int>(); for (int i = 0; i < Seasons; i++) { int[] allFoodTypes = new int[_foodTypes]; // fill array with all foodTypes for (int j = 0; j < allFoodTypes.Length; j++) { allFoodTypes[j] = j + i * _foodTypes; } // shuffle allFoodTypes = allFoodTypes.OrderBy(x => SealedRandom.Next()).ToArray(); // use first half as random poisonous foods for (int k = 0; k < _poisonFoods; k++) { pFoodTypes.Add(allFoodTypes[k]); } } return(pFoodTypes); }
private void CreateSequence(int length) { Sequence = new double[length][]; for (int i = 0; i < Sequence.Length; i++) { bool hasOnes = false; Sequence[i] = new double[_vectorSize]; // Make sure we don't have any all-zero vectors, as the algorithm has trouble handling these do { for (int j = 0; j < Sequence[i].Length; j++) { double value = SealedRandom.Next(0, 2); if (value == 1) { hasOnes = true; } Sequence[i][j] = value; } } while (EliminiateZeroVectors && _vectorSize > 1 && !hasOnes); } }
private List <int> GetPoisonousFoodShufflePositions() { List <int> shufflePositions = new List <int>(); // If we have a specific date specified, just use this to shuffle the food items around. if (_specificPoisonousTypeChange != -1) { shufflePositions.Add(_specificPoisonousTypeChange); return(shufflePositions); } if (_poisonousTypeChanges == 0) { return(shufflePositions); } // this will not happen on the first, the second or the last day, that would be pointless. int[] allPositions = new int[_days - 3]; // fill array with all foodTypes for (int i = 0; i < allPositions.Length; i++) { allPositions[i] = i + 2; } // shuffle allPositions = allPositions.OrderBy(x => SealedRandom.Next()).ToArray(); // use first x as random positions to change for (int k = 0; k < _poisonousTypeChanges; k++) { shufflePositions.Add(allPositions[k]); } // sort ascending shufflePositions = new List <int>(shufflePositions.OrderBy(x => x)); return(shufflePositions); }