public IEnumerable<string> GeneratePlaySequence(int diskCount) { string result = ""; var converter = new AlphaNumericConverter(); for (int i = 1; i <= diskCount; i++) { if (PowerOfTwoValidator.IsNot(result.Length + 1)) continue; var temp = result; result = temp + converter.NumericToAlpha(i) + temp; } var pattern = result.ToArray().Select(n => Convert.ToString(n)).ToArray(); return pattern; }
public Move GenerateNextMove(Game game, int diskCount, string disk) { var index = new AlphaNumericConverter().AlphaToNumeric(disk); var move = new Move { Disk = disk }; var oddStackPositionStepDirection = StackHasOddNumberOfDisks(diskCount) // If stack has an odd disk count ? StepDirection.Left // start with move to left : StepDirection.Right; // else start with move to the right // Disks moves alternate between left and right move.StepDirection = DiskIsInEvenStackPosition(index) ? ReverseStepDirection(oddStackPositionStepDirection) : oddStackPositionStepDirection; return move; }
public Game() { _alphaNumericCalc = new AlphaNumericConverter(); _diskFinder = new DiskFinder(); _towerFinder = new TowerFinder(); }