--
Related Stack Overflow quest
Related Stack Overflow quest
-
Blitting images onto a tile that is part of a grid in pygame
-
why when the x and y size are not the same the grid is not showing properly
-
Using a matrix as a sprite and testing if two sprites overlap
-
How to find the button on the entered position by user and change it's color in pygame?
-
How can i draw rectangles in multiple rows and columns in pygame?
Related Stack Overflow quest
- Pygame lags after drawing full window grid
- How Can I Improve My Terrain Generator Performance I Get 40 FPS
Related Stack Overflow quest
Related Stack Overflow quest
-
how can I edit a sudoku grid in pygame using mouse and keyboard detection?
-
How do you detect a click in a cell of a grid and change its color?
-
Is it possible to update a pygame drawing attribute when clicking in a cell of a grid?
Related Stack Overflow quest
Related Stack Overflow quest
Related Stack Overflow quest
Related Stack Overflow quest
-
How to draw a chessboard with Pygame and move the pieces on the board??
-
python pygame mouse events not working and not raising errors
Related Stack Overflow quest
- How to convert an image in pygame to a numpy array or to a number?
- KeyError when trying to blit image on to screen from Numpy array in Pygame
import numpy
board = [
["bR", "bN", "bB", "bQ", "bK", "bB", "bN", "bR"],
["bp", "bp", "bp", "bp", "bp", "bp", "bp", "bp"],
["--", "--", "--", "--", "--", "--", "--", "--"],
["--", "--", "--", "--", "--", "--", "--", "--"],
["--", "--", "--", "--", "--", "--", "--", "--"],
["--", "--", "--", "--", "--", "--", "--", "--"],
["wp", "wp", "wp", "wp", "wp", "wp", "wp", "wp"],
["wR", "wN", "wB", "wQ", "wK", "wB", "wN", "wR"]
]
values, indices = numpy.unique(board, return_inverse=True)
indices = indices.reshape((8, 8))
print(values, '\n')
print(indices)
lookup = {
"--": 0,
"wK": 1, "wQ": 2, "wR": 3, "wB": 4, "wN": 5, "wp": 6,
"bK": 7, "bQ": 8, "bR": 9, "bB": 10, "bN": 11, "bp": 12
}
indices = numpy.array([[lookup[p] for p in row] for row in board])
print(indices)