Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def evaluate(board, w = defaultWeights):
- # Extract height and width and create a board that is more
- # suitable for evaluation
- height = len(board) - 1
- width = len(board[0])
- evalboard = copy.copy(list(reversed(board[0:height])))
- # Remove full rows
- clearedRows = 0
- while True:
- for h in range(height):
- if 0 not in evalboard[h]:
- del evalboard[h]
- evalboard = copy.copy(evalboard + [[0]*width])
- clearedRows += 1
- break
- else:
- break
- # Extract height of each column
- evalboard = [list(r) for r in evalboard]
- columnHeight = [0]*width
- for c in range(width):
- # Works if I add the assert!!!
- #assert height == 20
- h = height-1
- while h > 0:
- if evalboard[h][c] != 0:
- break
- h -= 1
- # Set to h + 1 since we convert from zero-index to one-index
- columnHeight[c] = h + 1
- # Get the max height as well
- print(evalboard)
- print('columnh', columnHeight, 'height', height, 'width', width)
- maxHeight = max(columnHeight)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement