public IBuilder <GameLevel> Generate() { InitializeStrategies(); do { Reset(); foreach (IGeneratorStrategy strategy in _strategies) { Type requiredType = strategy.RequiredStrategy(); if (requiredType != null) { IGeneratorStrategy required = GetNextCompletedStrategyOfType(requiredType); strategy.SetRequiredStrategy(required); } strategy.RunStrategy(_map); } } while (!IsMapValid()); foreach (IGeneratorStrategy strategy in _postValidStrategies) { Type requiredType = strategy.RequiredStrategy(); if (requiredType != null) { IGeneratorStrategy required = GetNextCompletedStrategyOfType(requiredType); strategy.SetRequiredStrategy(required); } strategy.RunStrategy(_map); } return(this); }
public SumMemoTable Generate(Int64 maxDigits, Int64 digitRange) { var maxLinearSum = maxDigits * digitRange; var maxSquareSum = maxDigits * digitRange * digitRange; var sumMemoTable = new SumMemoTable(maxDigits, digitRange); _strategy = new OneDigitGeneratorStrategy(sumMemoTable); _strategy.Run(); for (var i = 1; i < maxDigits; i++) { for (var j = 0; j <= digitRange; j++) { if (j == 0) { _strategy = new FirstDigitZeroGeneratorStrategy(sumMemoTable, i); } else { _strategy = new FirstDigitNonZeroGeneratorStrategy(sumMemoTable, i, j); } _strategy.Run(); } } return sumMemoTable; }
public ILevelConfigurator UseStrategy(IGeneratorStrategy strategy) { _parameters.Strategy = strategy; return(this); }
public void SetRequiredStrategy(IGeneratorStrategy strategy) { _requiresStrategy = strategy; }
public void AddPostValidStrategy(IGeneratorStrategy strategy) { _postValidStrategies.Add(strategy); }
public void AddGeneratorStrategy(IGeneratorStrategy strategy) { _strategies.Add(strategy); }
public void UseStrategy(IGeneratorStrategy <TDatabase> strategy) { _strategy = strategy; }