wolfDefenderWindows function

List<(int, int)> wolfDefenderWindows(
  1. int tokens
)

The token ranges of the windows of tokens tokens. Each has at most 2046 tokens; each after the first starts 64 tokens before the end of the one before it. No tokens is one empty window.

Implementation

List<(int, int)> wolfDefenderWindows(int tokens) {
  const size = wolfDefenderWindowPositions - 2;
  final windows = <(int, int)>[];
  var start = 0;
  while (true) {
    final end = math.min(start + size, tokens);
    windows.add((start, end));
    if (end == tokens) return windows;
    start = end - wolfDefenderWindowOverlap;
  }
}