Hello.
This time it might be a bit more complicated.
def start_game():
global no_winner
no_winner = True
rows_cols()
global board
board = make_board()
print_board()
player_select()
def rows_cols():
global rows
global columns
rows = int(raw_input('Height: '))
columns = int(raw_input('Width: '))
if rows < 4:
rows = 4
if columns < 4:
columns = 4
def make_board():
fielda = []
fieldb = []
for i in range(columns):
fieldb.append('.')
for i in range(rows):
fielda.append(fieldb)
return fielda
def print_board():
global row
global dot
for row in board:
for dot in row:
print dot,
print
for i in range(columns):
print i,
print
def player_select():
select = int(raw_input('Human enemy(1) or Computer enemy(2)?: '))
if select == 1:
select_1()
elif select == 2:
select_2()
else:
player_select()
def select_1():
print 'Player 1 = X'
print 'Player 2 = O'
while no_winner == True:
turn_player1()
turn_player2()
def select_2():
print 'Player = X'
print 'Computer = O'
while no_winner == True:
turn_player1()
turn_comp()
def turn_player1():
print 'Turn Player 1'
playchip = int(raw_input('Throw a coin in column: '))
board[0][playchip] = 'X'
print_board()
def turn_player2():
print 'Turn Player 2'
playchip = int(raw_input('Throw a coin in column: '))
board[0][playchip] = 'O'
print_board()
def turn_comp():
import random
print 'Turn Computer'
playchip = random.randint(0, columns - 1)
board[0][playchip] = 'O'
print_board()
def dot_blank():
for i in range(columns):
for i in range(rows):
if board[0][playchip] == '.':
return True
return False
start_game()
. . . .
. . . .
. . . .
. . . .
0 1 2 3
When I insert a Coin at Position 0 the whole column is getting filled with the coin instead of a single 'dot' in the column.
It looks like this:
X . . .
X . . .
X . . .
X . . .
0 1 2 3
Any ideas to fix this?
Thanks in advance