示例#1
0
文件: main.py 项目: sfmailand/CS4341
	# set up globals
	global x_regex
	global y_regex

	x_regex = None
	y_regex = None

	computerBoardFile = sys.argv[1]
	userBoardFile = sys.argv[2]

	# convert the input files to board objects and check to make sure they are the same size
	computerBoard = Board(computerBoardFile)
	userBoard = Board(userBoardFile)
	
	if ((computerBoard.getBoardWidth() != userBoard.getBoardWidth()) or (computerBoard.getBoardHeight() != userBoard.getBoardHeight())):
		print "Computer board and user board must have same dimensions"
		print "Please correct this error and then play battleship"
		exit()

	global boardWidth 
	boardWidth = computerBoard.getBoardWidth()
	global boardHeight
	boardHeight = computerBoard.getBoardHeight()

	# initialize the AI for the computer
	opponentType = int(sys.argv[3])
	if (opponentType > 5) or (opponentType < 0):
		print "Invalid input. Using rollouts"
		opponentType = ROLLOUTS