chooseAction method

int chooseAction(
  1. List<double> state
)

Implementation

int chooseAction(List<double> state) {
  if (_rand.nextDouble() < epsilon) return _rand.nextInt(nActions);
  final pred = network.predict([state]);
  final row = pred[0];
  double best = row[0];
  int bestIdx = 0;
  for (var i = 1; i < row.length; i++) {
    if (row[i] > best) {
      best = row[i];
      bestIdx = i;
    }
  }
  return bestIdx;
}