<commit_before>import { getNow } from 'puz/util';
import { PlayerWithMoves } from './interfaces';

type Timestamp = number;

export interface CarBoost {
  score: number;
  time: Timestamp; // of last score update
}

export class Boost {
  cars: CarBoost[] = [];

  setPlayers = (players: PlayerWithMoves[]) => {
    const now = getNow();
    if (players.length != this.cars.length) {
      this.cars = players.map(p => ({ score: p.moves, time: now }));
    } else {
      this.cars = this.cars.map((car, i) => ({
        score: players[i].moves,
        time: players[i].moves > car.score ? now : car.time,
      }));
    }
  };

  isBoosting = (index: number) => this.cars[index]?.time > getNow() - 1000;
}
<commit_msg>fix racer boost<commit_after>import { getNow } from 'puz/util';
import { PlayerWithMoves } from './interfaces';

type Timestamp = number;

export interface CarBoost {
  score: number;
  time: Timestamp; // of last score update
}

export class Boost {
  cars: CarBoost[] = [];

  setPlayers = (players: PlayerWithMoves[]) => {
    if (players.length != this.cars.length) {
      this.cars = players.map(p => ({ score: p.moves, time: 0 }));
    } else {
      this.cars = this.cars.map((car, i) => ({
        score: players[i].moves,
        time: players[i].moves > car.score ? getNow() : car.time,
      }));
    }
  };

  isBoosting = (index: number) => this.cars[index]?.score && this.cars[index]?.time > getNow() - 1000;
}

{'fraction_non_alphanumeric': 0.17496542185338865, 'fraction_numerical': 0.006224066390041493, 'mean_word_length': 2.9427792915531334, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2447981', 'n_tokens_mistral': 523, 'n_tokens_neox': 498, 'n_words': 118}