Не Помню
Профи
(924)
2 недели назад
import random
import sys
board=[i for i in range(0,9)]
player, computer = '',''
# Corners, Center and Others, respectively
moves=((1,7,3,9),(5,),(2,4,6,8))
# Winner combinations
winners=((0,1,2),(3,4,5),(6,7,8),(0,3,6),(1,4,7),(2,5,8),(0,4,8),(2,4,6))
# If I can win, others do not matter.
for i in range(1,10):
if make_move(board, computer, i, True)[1]:
move=i
break
if move == -1:
# If player can win, block him.
for i in range(1,10):
if make_move(board, player, i, True)[1]:
move=i
break
if move == -1:
# Otherwise, try to take one of desired places.
for tup in moves:
for mv in tup:
if move == -1 and can_move(board, computer, mv):
move=mv
break
return make_move(board, computer, move)
def space_exist():
return board.count('X') + board.count('O') != 9
player, computer = select_char()
print('Player is [%s] and computer is [%s]' % (player, computer))
result='%%% Deuce ! %%%'
while space_exist():
print_board()
print('#Make your move ! [1-9] : ', end='')
move = int(input())
moved, won = make_move(board, player, move)
if not moved:
print(' >> Invalid number ! Try again !')
continue
if won:
result='*** Congratulations ! You won ! ***'
break
elif computer_move()[1]:
result='=== You lose ! =='
break;
print_board()
print(result)
qwerty000755
Гуру
(3323)
2 недели назад
Если правильно понял вопрос, то вот:
100110[2] + 52[8] = 38 + 42 = 80
110 + 110[2] = 110 + 6 = 116
154 - 154[8] = 154 - 108 = 2E[16]
77[8] - A[16] = 63 - 10 = 53
77[8] + 77[16] = 63 + 119 = 182
Основание системы счисление указано в [скобках] справа от числа, если не указано, то там [10].
Когда будешь переписывать, основание пиши не так, как тут, а без скобок возле правого нижнего угла числа