<commit_before>#!/usr/bin/env python

import argparse

from drive.road import StraightRoad, ZigZagRoad
from drive.field import Field
from drive.vehicle import HumanVehicle, RandomVehicle, LoopVehicle
from drive.sensor import PositionSensor
from drive.motor import AccelerationMotor, PositionMotor
from drive.scorer import StayOnRoadScorer
from drive.model import PositionPredictionModel, PositionBehaviorModel
from drive.logs import Logs
from drive.graphics import Graphics
from drive.plots import Plots, PositionPredictionPlots, PositionBehaviorPlots
from drive.game import Game



if __name__ == "__main__":
  parser = argparse.ArgumentParser()
  parser.add_argument('--plots', choices=[None,
                                          "default",
                                          "positionPrediction",
                                          "positionBehavior"],
                      default=None,
                      help="Enable plots")
  parser.add_argument('--disableGraphics', action='store_true',
                      help="Disable graphics")
  parser.add_argument('--motor', choices=["acceleration", "position"],
                      default="acceleration")
  parser.add_argument('--road', choices=["straight", "zigzag"],
                      default="zigzag")
  parser.add_argument('--vehicle', choices=["human", "random", "loop"],
                      default="human")
  parser.add_argument('--model', choices=["positionPrediction",
                                          "positionBehavior"],
                      default="positionBehavior")
  parser.add_argument('--fieldWidth', type=int,
                      default=100)
  parser.add_argument('--sensorNoise', type=float,
                      default=0)
  parser.add_argument('--motorNoise', type=float,
                      default=0)
  parser.add_argument('--goal', type=float,
                      default=None)
  parser.add_argument('--plotEvery', type=int,
                      default=25)
  parser.add_argument('--manualRun', action='store_true',
                      help="Wait for input on each timestep")

  args = parser.parse_args()

  if args.road == "straight":
    road = StraightRoad()
  elif args.road == "zigzag":
    road = ZigZagRoad()

  field = Field(road, width=args.fieldWidth)

  sensorNoise = (0, args.sensorNoise)
  sensor = PositionSensor(noise=sensorNoise)

  motorNoise = (0, args.motorNoise)
  if args.motor == "acceleration":
    motor = AccelerationMotor(noise=motorNoise)
  elif args.motor == "position":
    motor = PositionMotor(noise=motorNoise)

  startPosition = field.width / 2
  if args.vehicle == "human":
    vehicle = HumanVehicle(field, sensor, motor, startPosition=startPosition)
  if args.vehicle == "random":
    vehicle = RandomVehicle(field, sensor, motor, startPosition=startPosition,
                            motorValues=[-1, 0, 1])
  if args.vehicle == "loop":
    vehicle = LoopVehicle(field, sensor, motor, startPosition=startPosition,
                          motorValues=[-3, 3])

  scorer = StayOnRoadScorer(field, vehicle)

  if args.model == "positionPrediction":
    model = PositionPredictionModel(tmParams={
      "columnDimensions": [1024],
      "minThreshold": 35,
      "activationThreshold": 35,
      "maxNewSynapseCount": 40,
      "cellsPerColumn": 8,
      "initialPermanence": 0.4,
      "connectedPermanence": 0.6,
      "permanenceIncrement": 0.1,
      "permanenceDecrement": 0.1,
    })
  elif args.model == "positionBehavior":
    motorValues = [-1, 0, 1]
    if args.vehicle == "human":
      motorValues = range(-4, 4+1)
    model = PositionBehaviorModel(motorValues=motorValues,
                                  bmParams={
      "numSensorColumns": 1024,
      "numCellsPerSensorColumn": 16
    })

  plots = None
  if args.plots == "positionPrediction":<commit_msg>Update loop vehicle<commit_after>#!/usr/bin/env python

import argparse

from drive.road import StraightRoad, ZigZagRoad
from drive.field import Field
from drive.vehicle import HumanVehicle, RandomVehicle, LoopVehicle
from drive.sensor import PositionSensor
from drive.motor import AccelerationMotor, PositionMotor
from drive.scorer import StayOnRoadScorer
from drive.model import PositionPredictionModel, PositionBehaviorModel
from drive.logs import Logs
from drive.graphics import Graphics
from drive.plots import Plots, PositionPredictionPlots, PositionBehaviorPlots
from drive.game import Game



if __name__ == "__main__":
  parser = argparse.ArgumentParser()
  parser.add_argument('--plots', choices=[None,
                                          "default",
                                          "positionPrediction",
                                          "positionBehavior"],
                      default=None,
                      help="Enable plots")
  parser.add_argument('--disableGraphics', action='store_true',
                      help="Disable graphics")
  parser.add_argument('--motor', choices=["acceleration", "position"],
                      default="acceleration")
  parser.add_argument('--road', choices=["straight", "zigzag"],
                      default="zigzag")
  parser.add_argument('--vehicle', choices=["human", "random", "loop"],
                      default="human")
  parser.add_argument('--model', choices=["positionPrediction",
                                          "positionBehavior"],
                      default="positionBehavior")
  parser.add_argument('--fieldWidth', type=int,
                      default=100)
  parser.add_argument('--sensorNoise', type=float,
                      default=0)
  parser.add_argument('--motorNoise', type=float,
                      default=0)
  parser.add_argument('--goal', type=float,
                      default=None)
  parser.add_argument('--plotEvery', type=int,
                      default=25)
  parser.add_argument('--manualRun', action='store_true',
                      help="Wait for input on each timestep")

  args = parser.parse_args()

  if args.road == "straight":
    road = StraightRoad()
  elif args.road == "zigzag":
    road = ZigZagRoad()

  field = Field(road, width=args.fieldWidth)

  sensorNoise = (0, args.sensorNoise)
  sensor = PositionSensor(noise=sensorNoise)

  motorNoise = (0, args.motorNoise)
  if args.motor == "acceleration":
    motor = AccelerationMotor(noise=motorNoise)
  elif args.motor == "position":
    motor = PositionMotor(noise=motorNoise)

  startPosition = field.width / 2
  if args.vehicle == "human":
    vehicle = HumanVehicle(field, sensor, motor, startPosition=startPosition)
  if args.vehicle == "random":
    vehicle = RandomVehicle(field, sensor, motor, startPosition=startPosition,
                            motorValues=[-1, 0, 1])
  if args.vehicle == "loop":
    vehicle = LoopVehicle(field, sensor, motor, startPosition=startPosition,
                          motorValues=[0, -1, 0, 1, 0, 1, 0, -1])

  scorer = StayOnRoadScorer(field, vehicle)

  if args.model == "positionPrediction":
    model = PositionPredictionModel(tmParams={
      "columnDimensions": [1024],
      "minThreshold": 35,
      "activationThreshold": 35,
      "maxNewSynapseCount": 40,
      "cellsPerColumn": 8,
      "initialPermanence": 0.4,
      "connectedPermanence": 0.6,
      "permanenceIncrement": 0.1,
      "permanenceDecrement": 0.1,
    })
  elif args.model == "positionBehavior":
    motorValues = [-1, 0, 1]
    if args.vehicle == "human":
      motorValues = range(-4, 4+1)
    model = PositionBehaviorModel(motorValues=motorValues,
                                  bmParams={
      "numSensorColumns": 1024,
      "numCellsPerSensorColumn": 16
    })

  plots = None
  if args.plots == "positionPrediction":
{'fraction_non_alphanumeric': 0.11765468932416656, 'fraction_numerical': 0.012712414061486575, 'mean_word_length': 2.552995391705069, 'pattern_counts': {'":': 46, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6769965', 'n_tokens_mistral': 2282, 'n_tokens_neox': 2077, 'n_words': 463}