本文整理汇总了Python中Game.Game.play_game方法的典型用法代码示例。如果您正苦于以下问题:Python Game.play_game方法的具体用法?Python Game.play_game怎么用?Python Game.play_game使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game.Game
的用法示例。
在下文中一共展示了Game.play_game方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: eval_func
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import play_game [as 别名]
def eval_func(chromosome):
player = Player(chromosome)
game = Game([player] + player_list, verbose=False, quiet=True) # Start the game in quiet mode.
ranking = game.play_game()
score = ranking.index('GA Player')
return score * score
示例2: TestTwoPlayer
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import play_game [as 别名]
class TestTwoPlayer(unittest.TestCase):
def setUp(self):
self.players = [FakePlayer(), FakePlayer()]
self.game = Game(self.players, verbose=False)
def test_two_turns(self):
# Starting conditions in game engine
self.assertEqual(self.game.players[0].food, 300)
self.assertEqual(self.game.players[1].rep, 0.0)
# Make sure data sent to player classes is right
# Note that after this point, self.players[0] is not
# necessarily self.game.players[0] because of shuffling
self.game.play_round()
self.assertEqual(self.players[0].food, 302)
self.assertEqual(self.players[0].rep, 0)
self.game.play_round()
self.assertEqual(self.players[0].food, 304)
self.assertEqual(self.players[0].rep, 1.0)
# Test that Game is sending the correct arguments to BasePlayers
self.assertEqual(self.players[0].hunt_choices_args,
(2, 302, 1.0, 1, [1.0]))
self.assertEqual(self.players[0].hunt_outcomes_args, ([0],))
self.assertEqual(self.players[0].round_end_args, (2, 1, 2))
# Test that Game stayed synched with Player.
self.assertEqual(self.players[0].food, self.game.players[0].food)
self.assertEqual(self.players[0].rep, self.game.players[0].rep)
def test_full_game(self):
#Make sure the game runs to completion without errors
self.game.play_game()
def test_m(self):
self.assertEqual(self.game.calculate_m(), 1)
self.assertEqual(self.game.m_bonus, 2)
示例3: get_arguments
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import play_game [as 别名]
# Change these to edit the default Game parameters
DEFAULT_VERBOSITY = True
DEFAULT_MIN_ROUNDS = 300
DEFAULT_AVERAGE_ROUNDS = 1000
DEFAULT_END_EARLY = False
DEFAULT_PLAYERS = ([Player()] * 5) + ([Player1()] * 5) + ([Player2()] * 5) + ([Player3(0.0001)] * 5) + ([Freeloader()] * 5) + ([Alternator()] * 1) + ([MaxRepHunter()] * 5) + ([Random(0.3)] * 2) + ([Random(0.96)] * 2) + ([FairHunter()] * 2) + ([BoundedHunter(0.8,0.999)] * 5) + ([AverageHunter()] * 3) + ([Pushover()] * 1)
# Bare minimum test game. See README.md for details.
if __name__ == '__main__':
(players, options) = arguments.get_arguments()
# The list of players for the game is made up of
# 'Player' (your strategy)
# bots from get_arguments (the bots to use)
player_list = players
# **options -> interpret game options from get_arguments
# as a dictionary to unpack into the Game parametersi
winnerMap = {}
for i in range(200) :
game = Game(player_list, **options)
winner = game.play_game()
print ("Winner: " + winner)
sys.stdout.flush()
if (not winner in winnerMap):
winnerMap[winner] = 1
else :
winnerMap[winner] += 1;
print (str(winnerMap))
示例4: Alternator
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import play_game [as 别名]
from __future__ import division, print_function
from Game import Game
from bots import *
from Player import Player
from Grace import Grace
from Guy import Guy
# Bare minimum test game. See README.md for details.
if __name__ == '__main__':
players = [Freeloader(), Alternator(), FairHunter(), Random(0.8), Player(), MaxRepHunter(), BoundedHunter(0.5,1)]
game = Game(players)
game.play_game()
#for i in range(0,input()):
# game.play_round()
示例5: Freeloader
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import play_game [as 别名]
from __future__ import division, print_function
from Game import Game
import GamePrinter
from Players import Pushover, Freeloader, Alternator
# Bare minimum test game. See README.md for details.
if __name__ == '__main__':
players = [Pushover(), Freeloader(), Alternator()]
game = Game(players)
gameResults = game.play_game()
GamePrinter.PrintGameRoundList(gameResults)