def test_convertHead_right(self): #no food grid = np.zeros((4,4))-1 #empty grid[3,1] = 0 #head isFree = SnakeRL.convertHead( 3, 1, 4, 4, grid) truth = [1,0,1,1] #up not free for i,j in zip(isFree, truth): self.assertEqual(i, j) # with food grid[2,1] = -2 #food isFree = SnakeRL.convertHead( 3, 1, 4, 4, grid) for i,j in zip(isFree, truth): self.assertEqual(i, j)
def test_convertHead_start(self): #no food grid = np.zeros((4,4))-1 #empty grid[0,0] = 0 #head isFree = SnakeRL.convertHead( 0, 0, 4, 4, grid) truth = [1,1,0,0] #up and right are free for i,j in zip(isFree, truth): self.assertEqual(i, j) # with food grid[0,1] = -2 #food isFree = SnakeRL.convertHead( 0, 0, 4, 4, grid) for i,j in zip(isFree, truth): self.assertEqual(i, j)