示例#1
0
def init_sheep(canvas_local, n):
    agents = {}
    X = list()
    for i in range(n):
        np.random.seed(i)
        x = np.random.randint(50, 550)
        y = np.random.randint(50, 550)
        X.append([x, y])
        agents['sheep' + str(i)] = sheep.Agent(canvas_local, x - 5, y - 5, x + 5, y + 5, 'green')

    herd = sheep.Agent(canvas_local, 50, 550, 60, 560, 'red')
    return np.array(X, np.float64), agents, herd
示例#2
0
def init_sheep(canvas_local, n):
    agents = {}
    X = list()
    for i in range(n):
        x = 50 + np.random.randint(5) + 5 * i
        y = 50 + np.random.randint(5) + 5 * i
        X.append([x, y])
        agents['sheep' + str(i)] = sheep.Agent(canvas_local, x - 5, y - 5,
                                               x + 5, y + 5, 'green')

    # 牧羊犬的初始位置
    herd = sheep.Agent(canvas_local, 50, 550, 60, 560, 'red')
    return np.array(X), agents, herd
def init_sheep(canvas_local, n):
    agents = {}
    X = list()
    for i in range(n-1):
        np.random.seed(i)
        x = np.random.randint(100, 300)
        y = np.random.randint(100, 300)
        X.append([x, y])
        agents['sheep' + str(i)] = sheep.Agent(canvas_local, x - 5, y - 5, x + 5, y + 5, 'green')

    # 离群点的特殊的一只羊,在目标区域
    X.append([550, 550])
    agents['sheep' + str(n-1)] = sheep.Agent(canvas_local, 550 - 5, 550 - 5, 550 + 5, 550 + 5, 'green')
    # 牧羊犬的初始位置
    herd = sheep.Agent(canvas_local, 50, 550, 60, 560, 'red')
    return np.array(X), agents, herd
示例#4
0
def init_sheep(canvas_local, n):
    agents = {}
    X = list()
    for i in range(n):
        np.random.seed(i)
        if i % 2 == 0:
            x = np.random.randint(50, 250)
            y = np.random.randint(350, 550)
        else:
            x = np.random.randint(350, 550)
            y = np.random.randint(50, 250)
        X.append([x, y])
        agents['sheep' + str(i)] = sheep.Agent(canvas_local, x - 5, y - 5, x + 5, y + 5, 'green')

    # 牧羊犬的初始位置
    herd = sheep.Agent(canvas_local, 50, 550, 60, 560, 'red')
    return np.array(X), agents, herd
示例#5
0
def init_sheep(canvas_local, n):
    agents = {}
    X = list()
    tags = []
    left = []
    right = []
    for i in range(n):
        np.random.seed(i)
        x = np.random.randint(50, 500)
        y = np.random.randint(50, 500)
        if i % 2 == 0:
            tags.append(1)
            left.append([x, y])
        else:
            tags.append(0)
            right.append([x, y])
        X.append([x, y])
        agents['sheep' + str(i)] = sheep.Agent(canvas_local, x - 5, y - 5,
                                               x + 5, y + 5, 'green')

    herd_1 = sheep.Agent(canvas_local, 50, 550, 60, 560, 'red')
    herd_2 = sheep.Agent(canvas_local, 550, 50, 560, 60, 'blue')

    return np.array(X), agents, herd_1, herd_2, np.array(left), np.array(right)