You init a 2-d matrix like this
board = [[0] * width for _ in range(height)]
Instead of
board = [[0] * width] * height
as it creates the list once and every row references the same list.
Is it not the same in the first case, we still use * so each column in each row should reference the same element for a given row. But this is not the case, why?
See List of lists changes reflected across sublists unexpectedly
When multiplying a list, the objects in the resulting list will be the same instance with the same
id(). So[0] * width(alist) will be shared across all rows[0..height).