1

I state that I am creating a pacman reinforcement training. The idea is to encode the positions of objects throughout the map (walls, ghosts, cookies, powers, etc ...) in an n-dimensional tensor of 0 and 1 The situation is this, the game map is a 272x232 matrix: created with the points available:

x, y, w, h

Every object has these points, consequently, I encode everything in a tensor of 0 and 1 as follows:

def getWallMatrix(self):
    matrix = np.zeros((self._h, self._w), dtype='uint8')
    for w in self._actors:
        if isinstance(w, Wall) or isinstance(w, Gate):
            x, y, w, h = w.rect()

            for i in range(0,w):
                for j in range(0,h):
                    x = int(x)
                    y = int(y)
                    matrix[y+j-1][x+i-1]=1
    return matrix

the initial idea was therefore to treat the tensor as an image and apply the function cv2.resize as follows:

observation[0] = cv2.resize(matrix, dsize=(RESIZE_H, RESIZE_W), interpolation=cv2.INTER_NEAREST)

With RESIZE_H = 68 and RESIZE_W = 68 the result is acceptable but the image is still too big for me, and if I had to put a lower value I would lose the resolution. This would create me some problems regarding the cookies distributed along the map, some disappear during the resizing.

I have seen around that someone has been able to acceptably resize the classic game map using only a 27x27 matrix of 0 and 1. How could I deal with the problem to have a compromise between very small image and quality?

NicelyCLa
  • 11
  • 3

0 Answers0