示例#1
0
def runsim(rounds, redteam=None, blueteam=None, boardSize=4):
	wins = defaultdict(lambda: 0)
	# Override the bots if provided
	global BOARD_SIZE, BOTS
	if redteam:
		BOTS['red'] = redteam
	if blueteam:
		BOTS['blue'] = blueteam
	BOARD_SIZE = boardSize

	for i in range(rounds):

		print ""
		print "Round %d, fight!" % (i + 1)

		game = Game(BOARD_SIZE)
		state = State(game)
		
		def make_quipper(who):
			def quip(what):
				print who, ">>", what
			return quip
		
		while not state.is_terminal():
			move = BOTS[state.whos_turn].think(state.copy(), make_quipper(state.whos_turn))
			state.apply_move(move)

		final_score = state.get_score()
		winner = max(['red','blue'],key=final_score.get)
		print "The %s bot wins this round! (%s)" % (winner, str(final_score))
		wins[winner] = 1 + wins[winner]

	print ""
	print "Final win counts:", dict(wins)
示例#2
0
def runSim(redBot, blueBot):

    red_bot = __import__(redBot)
    blue_bot = __import__(blueBot)

    BOTS = {'red': red_bot, 'blue': blue_bot}

    ################### End importing bot ##############################

    for i in range(rounds):

        print ""
        print "Round %d, fight!" % i

        game = Game(4)
        state = State(game)

        def make_quipper(who):
            def quip(what):
                print who, ">>", what

            return quip

        while not state.is_terminal():
            move = BOTS[state.whos_turn].think(state.copy(),
                                               make_quipper(state.whos_turn))
            state.apply_move(move)

        final_score = state.get_score()
        winner = max(['red', 'blue'], key=final_score.get)
        print "The %s bot wins this round! (%s)" % (winner, str(final_score))
        wins[winner] = 1 + wins[winner]

    print ""
    print "Final win counts:", dict(wins)
示例#3
0
def runSim(redBot, blueBot):

  red_bot = __import__(redBot)
  blue_bot = __import__ (blueBot)

  BOTS = {'red': red_bot, 'blue': blue_bot}

  ################### End importing bot ##############################

  for i in range(rounds):

    print ""
    print "Round %d, fight!" % i

    game = Game(4)
    state = State(game)
    
    def make_quipper(who):
      def quip(what):
        print who, ">>", what
      return quip
    
    while not state.is_terminal():
      move = BOTS[state.whos_turn].think(state.copy(), make_quipper(state.whos_turn))
      state.apply_move(move)

    final_score = state.get_score()
    winner = max(['red','blue'],key=final_score.get)
    print "The %s bot wins this round! (%s)" % (winner, str(final_score))
    wins[winner] = 1 + wins[winner]

  print ""
  print "Final win counts:", dict(wins)
rounds = 5
wins = defaultdict(lambda: 0)

for i in range(rounds):

    print ""
    print "Round %d, fight!" % i

    game = Game(4)
    state = State(game)

    def make_quipper(who):
        def quip(what):
            print who, ">>", what

        return quip

    while not state.is_terminal():
        move = BOTS[state.whos_turn].think(state.copy(),
                                           make_quipper(state.whos_turn))
        state.apply_move(move)

    final_score = state.get_score()
    winner = max(['red', 'blue'], key=final_score.get)
    print "The %s bot wins this round! (%s)" % (winner, str(final_score))
    wins[winner] = 1 + wins[winner]

print ""
print "Final win counts:", dict(wins)
BOTS = {'red': red_bot, 'blue': blue_bot}

rounds = 5
wins = defaultdict(lambda: 0)

for i in range(rounds):

  print ""
  print "Round %d, fight!" % i

  game = Game(4)
  state = State(game)
  
  def make_quipper(who):
    def quip(what):
      print who, ">>", what
    return quip
  
  while not state.is_terminal():
    move = BOTS[state.whos_turn].think(state.copy(), make_quipper(state.whos_turn))
    state.apply_move(move)

  final_score = state.get_score()
  winner = max(['red','blue'],key=final_score.get)
  print "The %s bot wins this round! (%s)" % (winner, str(final_score))
  wins[winner] = 1 + wins[winner]

print ""
print "Final win counts:", dict(wins)