Ejemplo n.º 1
0
def Play(board, Comp_position, Opp_position, Comp_symbol, player_symbol, pos_remain):
    comp_winstrike = dict()
    player_winstrike = dict()

    comp_winstrike = winstrike(board, Comp_position, Comp_symbol)

    player_winstrike = winstrike(board, Opp_position, player_symbol)

    for i in comp_winstrike:
        keys = comp_winstrike[i].keys()
        values = comp_winstrike[i].values()

        if 2 in values:
            ind = values.index(2)
            key = keys[ind]
            return CheckConstraints(i, board, 3, Comp_symbol, key)

    for i in player_winstrike:

        keys = player_winstrike[i].keys()
        values = player_winstrike[i].values()

        if 2 in values:

            ind = values.index(2)
            key = keys[ind]
            return CheckConstraints(i, board, 3, player_symbol, key)

    corner = [1, 3, 7, 9]

    for i in corner:
        if (i in Comp_position) or (i in Opp_position):
            continue
        else:
            return position.positionnum(i)

    return position.positionnum(random.choise(pos_remain))
Ejemplo n.º 2
0
				curr_player = player1
				curr_symbol = pl1_symb
			else:

				curr_player = player2
				curr_symbol = pl2_symb

			print curr_player + " : Enter the postion from 1 to 9 : "

			pos = input()

			if pos == 0 or pos > 9:
				continue

			i, j = position.positionnum(pos)

		
			while True:

				if flag == 1:
					if raw_input():
						pass
					break
				if board[i][j] != " ":

					
					os.system('clear')
					display(board)
				
					print curr_player + " : Choose another place in grid : "