hw6/hw6_grader.py
def runq4():
  """
  Runs their expectimax agent a few times and checks for victory!
  """
  random.seed(SEED)
  nGames = 20

  print(('Running your agent %d times to compute the average score...' % nGames))
  print(('The timeout message (if any) is obtained by running the game once, rather than %d times' % nGames))
  params = '-l smallClassic -p ExpectimaxAgent -a evalFn=better -q -n %d -c' % nGames
  games = pacman.runGames(**pacman.readCommand(params.split(' ')))
  timeouts = [game.agentTimeout for game in games].count(True)
  wins = [game.state.isWin() for game in games].count(True)
  averageWinScore = 0
  if wins >= nGames / 2:
    averageWinScore = average([game.state.getScore() if game.state.isWin() else None for game in games])
  print(('Average score of winning games: %d \n' % averageWinScore))
  return timeouts, wins, averageWinScore

  Runs their expectimax agent a few times and checks for victory!
  
Runs their expectimax agent a few times and checks for victory!
Runs their expectimax agent a few times and checks for victory!
def runq4():
  random.seed(SEED)
  nGames = 20
  print(('Running your agent %d times to compute the average score...' % nGames))
  print(('The timeout message (if any) is obtained by running the game once, rather than %d times' % nGames))
  params = '-l smallClassic -p ExpectimaxAgent -a evalFn=better -q -n %d -c' % nGames
  games = pacman.runGames(**pacman.readCommand(params.split(' ')))
  timeouts = [game.agentTimeout for game in games].count(True)
  wins = [game.state.isWin() for game in games].count(True)
  averageWinScore = 0
  if wins >= nGames / 2:
    averageWinScore = average([game.state.getScore() if game.state.isWin() else None for game in games])
  print(('Average score of winning games: %d \n' % averageWinScore))
  return timeouts, wins, averageWinScore
def runq4 ( ) : random . seed ( SEED ) nGames = 20 print ( ( 'Running your agent %d times to compute the average score...' % nGames ) ) print ( ( 'The timeout message (if any) is obtained by running the game once, rather than %d times' % nGames ) ) params = '-l smallClassic -p ExpectimaxAgent -a evalFn=better -q -n %d -c' % nGames games = pacman . runGames ( ** pacman . readCommand ( params . split ( ' ' ) ) ) timeouts = [ game . agentTimeout for game in games ] . count ( True ) wins = [ game . state . isWin ( ) for game in games ] . count ( True ) averageWinScore = 0 if wins >= nGames / 2 : averageWinScore = average ( [ game . state . getScore ( ) if game . state . isWin ( ) else None for game in games ] ) print ( ( 'Average score of winning games: %d \n' % averageWinScore ) ) return timeouts , wins , averageWinScore
Runs their expectimax agent a few times and checks for victory!
Runs their expectimax agent a few times and checks for victory!
"""
  Runs their expectimax agent a few times and checks for victory!
  """