private void changeDirection() { sinkAngle = RandomeNumberGenerator.uniformMaxDirection(directionMean); sinkDirection = Operations.ConvertAngleToDirection(sinkAngle); changeDirectionMean(); }
private void checkTheNewDirection() { bool didChange = false; int dir; int counter = 0; bool CheckTwoDirections = (PastDirections.Count > 1); int currentDirection = 0; if (PastDirections.Count > 1) { currentDirection = PastDirections.Pop(); } else { currentDirection = sinkDirection; } int oldDirection = 0; if (CheckTwoDirections) { oldDirection = PastDirections.Pop(); } do { counter++; sinkAngle = RandomeNumberGenerator.uniformMaxDirection(directionMean); //sinkDirection = Operations.ConvertAngleToDirection(sinkAngle); dir = Operations.ConvertAngleToDirection(sinkAngle); if (dir % 2 == 0) { if ((dir - 1) != sinkDirection) { if (CheckTwoDirections) { if ((dir - 1) != oldDirection) { sinkDirection = dir; didChange = true; } } else { sinkDirection = dir; didChange = true; } } } else if ((dir + 1) != sinkDirection) { if (CheckTwoDirections) { if ((dir + 1) != oldSinkDirection) { didChange = true; sinkDirection = dir; } } else { didChange = true; sinkDirection = dir; } } } while ((!didChange) && counter < 3); PastDirections.Push(currentDirection); if (didChange) { // int hold = PastDirections[(PastDirections.Count-1)]; PastDirections.Clear(); PastDirections.Push(currentDirection); PastDirections.Push(sinkDirection); switch (dir) { case 1: directionMean = 360; break; case 2: directionMean = 180; break; case 3: directionMean = 90; break; case 4: directionMean = 270; break; case 5: directionMean = 45; break; case 6: directionMean = 225; break; case 7: directionMean = 135; break; case 8: directionMean = 315; break; case 0: directionMean = 0; break; default: break; } } }