project/grid.py
def click(self, pos, direction, surface):
        """
        Clicking on cell spawns ant in specified direction
        """
        x, y = int(pos[0] / self.scale), int(pos[1] / self.scale)
        prev_x, prev_y = self.ant[0] * self.scale, self.ant[1] * self.scale
        new_x, new_y = x * self.scale, y * self.scale

        if self.ant != (-1, -1):  # There is an ant on the field currently
            # make sure previous cell where ant was can still update later
            # by making that cell empty (white)
            self.curr_array[self.ant[0], self.ant[1]] = -1
            # On clicking, deletes previous ant
            pygame.draw.rect(surface, (255, 255, 255),
                             [prev_x, prev_y, self.scale - self.border, self.scale - self.border])

        # Creates new ant in specified direction
        self.ant = (x, y)
        pygame.draw.rect(surface, (255, 0, 0),
                         [new_x, new_y, self.scale - self.border, self.scale - self.border])
        self.direction = direction

        Clicking on cell spawns ant in specified direction
        
Clicking on cell spawns ant in specified direction
Clicking on cell spawns ant in specified direction
def click(self, pos, direction, surface):
        x, y = int(pos[0] / self.scale), int(pos[1] / self.scale)
        prev_x, prev_y = self.ant[0] * self.scale, self.ant[1] * self.scale
        new_x, new_y = x * self.scale, y * self.scale
        if self.ant != (-1, -1):  
            self.curr_array[self.ant[0], self.ant[1]] = -1
            pygame.draw.rect(surface, (255, 255, 255),
                             [prev_x, prev_y, self.scale - self.border, self.scale - self.border])
        self.ant = (x, y)
        pygame.draw.rect(surface, (255, 0, 0),
                         [new_x, new_y, self.scale - self.border, self.scale - self.border])
        self.direction = direction
def click ( self , pos , direction , surface ) : x , y = int ( pos [ 0 ] / self . scale ) , int ( pos [ 1 ] / self . scale ) prev_x , prev_y = self . ant [ 0 ] * self . scale , self . ant [ 1 ] * self . scale new_x , new_y = x * self . scale , y * self . scale if self . ant != ( - 1 , - 1 ) : self . curr_array [ self . ant [ 0 ] , self . ant [ 1 ] ] = - 1 pygame . draw . rect ( surface , ( 255 , 255 , 255 ) , [ prev_x , prev_y , self . scale - self . border , self . scale - self . border ] ) self . ant = ( x , y ) pygame . draw . rect ( surface , ( 255 , 0 , 0 ) , [ new_x , new_y , self . scale - self . border , self . scale - self . border ] ) self . direction = direction
Clicking on cell spawns ant in specified direction
Clicking on cell spawns ant in specified direction
"""
        Clicking on cell spawns ant in specified direction
        """ # There is an ant on the field currently # make sure previous cell where ant was can still update later # by making that cell empty (white) # On clicking, deletes previous ant # Creates new ant in specified direction
self
pos
direction
surface