I want to simulate n queens problem using backtracking. I am calling this drawboard() function every time with a list as argument like below
def show_columns(x):
print "columns:", x
if len(x)!=0:
draw_board(x)
This list 'x' is returned from a recursive procedure and so will be updating after each iteration
So each time it is shown in separate windows.The next window is shown only after cloasing the first one and so on...
How can i make the things in a single window, or else how can i automatically close these windows after a particular time interval so that these windows are shown one by one
My function to draw chess board is as follows
def draw_board(the_board):
pygame.init()
colors = [(255,178,102), (255,255,255)]
surface_sz = 480
sq_sz = surface_sz // n
surface_sz = n * sq_sz
surface = pygame.display.set_mode((surface_sz, surface_sz))
ball = pygame.image.load("queen.png")
while True:
ev = pygame.event.poll()
if ev.type == pygame.QUIT:
break;
for row in range(n):
c_indx = row % 2
for col in range(n):
the_square = (col*sq_sz, row*sq_sz, sq_sz, sq_sz)
surface.fill(colors[c_indx], the_square)
c_indx = (c_indx + 1) % 2
for (col, row) in enumerate(the_board):
surface.blit(ball,
(col*sq_sz+ball_offset,row*sq_sz+ball_offset))
pygame.display.flip()
pygame.quit()