本文整理汇总了Python中Player.player方法的典型用法代码示例。如果您正苦于以下问题:Python Player.player方法的具体用法?Python Player.player怎么用?Python Player.player使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player.player方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: choosePC
# 需要导入模块: import Player [as 别名]
# 或者: from Player import player [as 别名]
def choosePC(self):
choice = raw_input ("Do you want to play against a friend? Y/N: ")
if choice == "Y" or choice == "y":
self.playerList[0] = Player.player()
self.playerList[1] = Player.player()
elif choice == "N" or choice == "n":
self.playerList[0] = Player.player()
self.playerList[1] = CompPlayer.compPlayer()
self.playerList[1].setIsEasy(self.setMode())
else:
print ("'" + str(choice) + "' is not an option. Please try again.")
self.choosePC()
示例2: init
# 需要导入模块: import Player [as 别名]
# 或者: from Player import player [as 别名]
def init(data):
data.mode = 'start'
data.modeCache = 'start'
data.frameCount = 0
data.ScreenWidth = data.screen.get_width()
data.ScreenHeight = data.screen.get_height()
data.map = map.map('fastest', 64, 64,scale = 1.5)
data.cellWidth, data.cellHeight = data.map.getCellsize()
data.buildings = Building.building.buildings
Building.building.setMap(data.map)
Unit.Unit.setMap(data.map)
Unit.Unit.setScreen(data.screen)
player1 = Player.player('Protoss', 8,9,0)
player2 = Player.player('Terran', 53,51,1)
pMPic = 'Other/PauseMenu.png'
data.pauseMenu = load.load_image(pMPic)
data.currentPlayer = player1
data.otherPlayer = player2
#MenuFile = 'Other/Menu/Protoss Menu.png'
data.MenuImage = data.currentPlayer.MenuImage #load.load_image(MenuFile)
Menu_h = data.MenuImage.get_height()
data.MenuHeight = Menu_h
PointerFile = 'Other/Pointer.png'
data.pointerImage = load.load_image(PointerFile)
#pygame.mouse.set_visible(False)
data.AutoScrollWidth = 20
data.ViewBox = Menu.ViewBox(data.map)
data.buildMode = False
data.placeMode = False
data.currentBuildIndex = None
data.currentBuildClass = None
data.selected = None
data.buttonStatus = [0]*9
data.currentPlayer.drawFogOfWar()
示例3: main
# 需要导入模块: import Player [as 别名]
# 或者: from Player import player [as 别名]
def main():
numPlayers = -1
#test Ben
#sublime text can't work with stdin, so hardcoded it as a 2 player game while on sublime
while(True):
try:
response = raw_input('How many players do you want? ')
numPlayers = int(response)
except ValueError:
print "Please enter a number"
continue
if (numPlayers >= 0 and numPlayers <= 4):
break
else:
print "Please enter a number betweeen 0 and 4"
players = []
for i in range (0, numPlayers):
players.append(Player.player(i))
AiNum = -1
try:
response = raw_input("Add an Ai player?")
if response == "Yes" or response == "yes" or response == "y":
AiNum = len(players)
players.append(Ai.ai(AiNum))
numPlayers +=1
except EOFError:
print " Not building, on sublime"
if AiNum != -1 and numPlayers == 1:
numRuns = input('How many runs? ')
else:
numRuns = 1
if numRuns > 1:
stats = []
for x in xrange(numRuns):
numPlayers = 1
players = []
AiNum = len(players)
players.append(Ai.ai(AiNum))
board = Board.board()
devCardsDeck = Devcards.devcards()
#board.createBatchCSV(players)
#board.batchUpdate()
#print board.printBoard()
firstPlacement(numPlayers, players, board, AiNum)
stats.append(playMainGame(numPlayers, players, board, devCardsDeck, AiNum))
print stats
print "average turns (excluding robber) = ", sum(stats)/float(numRuns)
else:
board = Board.board()
devCardsDeck = Devcards.devcards()
board.createBatchCSV(players)
board.batchUpdate()
print board.printBoard()
firstPlacement(numPlayers, players, board, AiNum)
playMainGame(numPlayers, players, board, devCardsDeck, AiNum)
示例4: tileInitialization
# 需要导入模块: import Player [as 别名]
# 或者: from Player import player [as 别名]
def tileInitialization(numPlayers, ai):
board = Board.board()
devCardsDeck = Devcards.devcards()
players = []
for i in range (0, numPlayers):
players.append(Player.player(i))
AiNum = -1
if ai:
players.append(Ai.ai(len(players)))
players[-1].verbose = True
numPlayers +=1
if not ai or numPlayers > 1:
board.createBatchCSV(players)
board.batchUpdate()
return board, players
示例5: __init__
# 需要导入模块: import Player [as 别名]
# 或者: from Player import player [as 别名]
def __init__(self, i, verbose = False, gamePlayVerbose = True):
self.AI = Player.player(i)
self.vertexToCentralityMap = VertexToCentralityDict.getMap()
#weights for features
#change this for not baseline
#self.weights = {'incomeIncrease' : 100, 'centrality' : .2, 'costInTurns' : -1.0, 'costInRes' : -2.0, 'port' : 2.0}
#this is the baseline
self.weights = {'incomeIncrease' : 100, 'centrality' : 0.2, 'costInTurns' : -5.0, 'costInRes' : -10.0, 'port' : 20.0}
self.diceProbs = [0.0, 0.0, 0.028,0.056,0.083,0.111,0.139,0.167,0.139,0.111,0.083,0.056,0.028]
self.income = {'wood':0.0, 'sheep':0.0, 'brick': 0.0, 'ore': 0.0, 'grain' : 0.0}
self.savedBestOpt = [None, None]
self.overallScarcity = None
self.savedPaths = {}
self.portsMap = {5 : 'three', 6 : 'three', 3 : 'three', 4 : 'three', 28 : 'three', 17 : 'three', 53 : 'three',
54 : 'three', 39 : 'ore', 40 : 'ore', 8 : 'sheep', 9 : 'sheep', 50 : 'grain', 51 : 'grain', 37 : 'wood', 47: 'wood', 16 : 'brick', 26 : 'brick'}
self.verbose = verbose
self.gamePlayVerbose = gamePlayVerbose
self.scarceWeightsInc = {'overall' : 0.0, 'soon' : 0.0, 'cur' : 3.0, 'gross' : 0.0} #this should sum to three for baseline
self.scarceWeightsCost = {'overall' : 0.0, 'soon' : 0.0, 'cur' : 3.0, 'gross' : 0.0} #this should sum to three for baseline
示例6: connect
# 需要导入模块: import Player [as 别名]
# 或者: from Player import player [as 别名]
def connect(self, slot, name, guid):
if not self.has_key(slot):
self[slot] = Player.player(name, guid, slot)
示例7: parse
# 需要导入模块: import Player [as 别名]
# 或者: from Player import player [as 别名]
def parse(data):
global ID, player
if "ID" in data and not ID:
try:
start = getIndexOfSub(data,"ID")
if start == -1 or not '#' in data[start:]:
raise ValueError("Parsing ID{int}#: Message corrupted")
stop = start+3
for ch in data[start+2:]:
if stop > len(data): raise ValueError("Parsing ID{int}#: stop >= len(data)")
if ch == '#': break
else: stop += 1
if stop > BUFFER_SIZE: raise ValueError("Parsing ID{int}#: stop > BUFFER_SIZE:")
ID = int(data[start+2:stop-1])
print "ID {0}".format(ID)
player = Player.player(ID)
except ValueError as error:
print "Error in parse ID: {0}".format(error)
if "RX" in data and ID:
try:
start = getIndexOfSub(data,"RX")
if start == -1 or not ('Y' in data[start:] and '#' in data[start:]):
raise ValueError("Parsing RX{float}Y{float}#: Message corrupted")
stop = start+3
for ch in data[start+2:]:
if stop >= len(data): raise ValueError("Parsing RX{float}Y{float}#: stop >= len(data)")
if ch == 'Y': break
else: stop += 1
if stop > BUFFER_SIZE: raise ValueError("Parsing RX{float}Y{float}#: stop > BUFFER_SIZE:")
X = float(data[start+2:stop-1])
print "X {0}".format(X)
start = stop
stop = start+1
for ch in data[start+1:]:
if stop >= len(data): raise ValueError("Parsing RX{float}Y{float}#: stop >= len(data)")
if ch == '#': break
else: stop += 1
if stop > BUFFER_SIZE: raise ValueError("Parsing RX{float}Y{float}#: stop > BUFFER_SIZE:")
Y = float(data[start:stop])
print "Y {0}".format(Y)
player.moveSentry((X,Y))
except ValueError as error:
print "Error in parse RX: {0}".format(error)
if "PL" in data and ID:
try:
start = getIndexOfSub(data,"PL")
if start == -1 or not ('R' in data[start:] and '#' in data[start:]):
raise ValueError("Parsing PL{float}X{float}#: Message corrupted")
stop = start+3
for ch in data[start+2:]:
if stop >= len(data): raise ValueError("Parsing PL{float}R{float}#: stop >= len(data)")
if ch == 'R': break
else: stop += 1
if stop > BUFFER_SIZE: raise ValueError("Parsing PL{float}X{float}#: stop > BUFFER_SIZE:")
L = float(data[start+2:stop-1])
print "L {0}".format(L)
start = stop
stop = start+1
for ch in data[start+1:]:
if stop >= len(data): raise ValueError("Parsing PL{float}R{float}#: stop >= len(data)")
if ch == '#': break
else: stop += 1
if stop > BUFFER_SIZE: raise ValueError("Parsing PL{float}R{float}#: stop > BUFFER_SIZE:")
R = float(data[start:stop])
print "R {0}".format(R)
player.setLight(L)
player.shoot(R)
except ValueError as error:
print "Error in parse RX: {0}".format(error)
示例8:
# 需要导入模块: import Player [as 别名]
# 或者: from Player import player [as 别名]
import pygame, sys, os, math
import Player, environment, entity
from pygame.locals import *
from pygame.draw import *
pygame.init()
window = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
fpsClock = pygame.time.Clock()
scroll = 0
scrolling = 0
player = Player.player()
player.x = 150
player.window = window.get_height()
entities = [
environment.platform(),
environment.platform(),
environment.platform(),
environment.wall(),
entity.bonus(),
environment.platform(),
environment.wall(),
environment.platform(),
environment.platform(),
environment.platform(),
environment.platform(),
environment.wall(),
]
entities[0].x = 100
entities[0].y = 300
示例9: connect
# 需要导入模块: import Player [as 别名]
# 或者: from Player import player [as 别名]
def connect(self, tag, name, team):
if not self.has_key(name):
self[name] = Player.player(name, tag, team)