def runHome(self, gameState):
        actions = gameState.getLegalActions(self.index)
        homeSquares = []
        wallsList = gameState.data.layout.walls.asList()

        #create list of homeSquares
        if (gameState.isOnRedTeam(self.index)):  #how to tell if redTeam
            #Creates a list of home spaces for red Team
            for y in range(1, 14):
                if ((15, y) not in wallsList):
                    homeSquares.append((15, y))  #check if space is wall
            #print(homeSquares)
        else:
            #Creates a list of home spaces for blue Team
            for y in range(1, 14):
                if y != 3:
                    if ((16, y) not in wallsList):
                        homeSquares.append((16, y))
            #print(homeSquares)

        bestDist = 9999
        actionDist = 9999
        for action in actions:
            successor = self.getSuccessor(gameState, action)
            pos2 = successor.getAgentPosition(self.index)

            #calculate closest home square for this action
            # and replace action if its better than prev action
            for h in homeSquares:
                homeDist = self.getMazeDistance(h, pos2)
                if homeDist < actionDist:
                    actionDist = homeDist
                    CaptureAgent.debugDraw(self, [h], [0, 0, 1], clear=True)

            if actionDist < bestDist:
                bestAction = action
                bestDist = actionDist
        return bestAction