/// <summary> /// Simulate one iteration of the algorithm /// </summary> /// <param name="cave"></param> /// <returns></returns> public Cave doSimulation(Cave cave) { Cell[,] copyMap = cave._celullarMap; for (int x = 0; x < Utility.WIDTH; x++) { for (int y = 0; y < Utility.HEIGTH; y++) { if (!cave.IsBorderCell(x, y)) { if (cave._celullarMap[x, y].state == Utility.STATE.Rock) { if (CustomRandomNumberGenerator.GetRandom() < this._growthHorizontalChance) { copyMap[x - 1, y].state = Utility.STATE.Rock; } if (CustomRandomNumberGenerator.GetRandom() < this._growthHorizontalChance) { copyMap[x + 1, y].state = Utility.STATE.Rock; } if (CustomRandomNumberGenerator.GetRandom() < this._growthVerticalChance) { copyMap[x, y + 1].state = Utility.STATE.Rock; } } } } } cave._celullarMap = copyMap; return(cave); }
public Cave InitializeCave(Cave cave) { _iterationCount = 50; for (int x = 0; x < Utility.WIDTH; x++) { for (int y = 0; y < Utility.HEIGTH; y++) { cave._celullarMap[x, y].state = Utility.STATE.Rock; } } RWalkSeeds = new List <AARandWalkStrategy>(); for (int i = 0; i < seedNumber; i++) { AARandWalkStrategy seed = new AARandWalkStrategy( CustomRandomNumberGenerator.GetRandomInt(40, 90), CustomRandomNumberGenerator.GetRandomInt(20, 55) ); cave._celullarMap[seed._x, seed._y].state = Utility.STATE.Air; RWalkSeeds.Add(seed); } return(cave); }
public void NextAction() { if (this._isAlive) { if (_age > _maxLifetime) { this._isAlive = false; } else if (_age > _minLifetime && _age < _maxLifetime) { if (CustomRandomNumberGenerator.GetRandom() < _lifetimeDeathChance) { this._isAlive = false; } else { Move(); } } else { Move(); } _age++; } }
public async Task GenerateRandomNumberAsync( [Summary("The lower limit")] int min, [Summary("The upper limit")] int max) { string generatedNumber; try { generatedNumber = CustomRandomNumberGenerator.GenerateNumber(min, max).ToString(); } catch (Exception) { throw new Exception("Wrong command usage. Try: random lower-limit upper-limit"); } await ReplyAsync(embed : generatedNumber.EmbedMessage()).ConfigureAwait(false); }
private void CreateSeed() { seeds = new List <AASeedStrategy>(); int seedNumber = CustomRandomNumberGenerator.GetRandomInt(6, 10); int seedDistance = Utility.WIDTH / seedNumber; for (int i = 1; i < seedNumber; i++) { int trueDistance = 0; while ((i * trueDistance <= 0 || i * trueDistance >= Utility.WIDTH)) { trueDistance = seedDistance + CustomRandomNumberGenerator.GetRandomInt(-2, 2); } seeds.Add(new AASeedStrategy(i * trueDistance, _floorLimit - 1)); } }
/// <summary> /// Initialize the cave by setting random cells to active; /// </summary> /// <returns>New initialized map</returns> public Cave InitializeCave(Cave cave) { for (int x = 0; x < Utility.WIDTH; x++) { for (int y = 0; y < Utility.HEIGTH; y++) { if (!cave.IsBorderCell(x, y)) { if (CustomRandomNumberGenerator.GetRandom() < this._wallChance) { cave._celullarMap[x, y].state = Utility.STATE.Rock; } } else { cave._celullarMap[x, y].state = Utility.STATE.Rock; } } } return(cave); }
private void Move() { if (this._age == 0) { this._y--; } else { if (CustomRandomNumberGenerator.GetRandom() < _growthChanceNorth) { this._y--; } else if (CustomRandomNumberGenerator.GetRandom() < _growthChanceWest) { this._x--; } else if (CustomRandomNumberGenerator.GetRandom() < _growthChanceEast) { this._x++; } } }
private void Move() { int number = CustomRandomNumberGenerator.GetRandomInt(1, 5); Debug.WriteLine(number); if (number == 1) { _y--; } else if (number == 2) { _y++; } else if (number == 3) { _x--; } else if (number == 4) { _x++; } }
/// <summary> /// Initialize the cave by setting random cells to active; /// </summary> /// <returns>New initialized map</returns> public Cave InitializeCave(Cave cave) { for (int x = 0; x < Utility.WIDTH; x++) { for (int y = _upperFloorLimit; y < _lowerFloorLimit; y++) { if (!cave.IsBorderCell(x, y)) { if (!(CustomRandomNumberGenerator.GetRandom() < this._activeChanceOnCrust)) { cave._celullarMap[x, y].state = Utility.STATE.Rock; } } else { cave._celullarMap[x, y].state = Utility.STATE.Rock; } } for (int y = _lowerFloorLimit; y < Utility.HEIGTH; y++) { if (!cave.IsBorderCell(x, y)) { if (!(CustomRandomNumberGenerator.GetRandom() < this._activeChanceGround)) { cave._celullarMap[x, y].state = Utility.STATE.Rock; } } else { cave._celullarMap[x, y].state = Utility.STATE.Rock; } } } return(cave); }