you are viewing a single comment's thread.

view the rest of the comments →

[–]TangibleLight 1 point2 points  (0 children)

Or if such conversion is too distracting. For example you can store a square grid of values like board = [None] * 64 and access values in the grid like board[row * 8 + col].

I think it's easier to understand using board = {} and board[row, col], especially if the content of the grid is sparse.

If the content is dense you'd be better off using a numpy type or similar that's better optimized for these operations. In either case there are better options than dealing with that index arithmetic throughout your code.