Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        // SELF-ASSEMBLY IMAGE POINTS (Uncomment for Self-Assembly Algorithm)
        //imagePixels = PointsFromImage(new Vector3(20, 0, 20));
        //NumAgents = imagePixels.Count;



        /////////  OBJECT INSTANTIATIONS  /////////

        // INSTANTIATE AGENTS (with different agent placement methods)
        agents = new Agents(agent, whiteGlowMaterial, NumAgents);
        agents.PlaceAgentsRandomly(AreaMin, AreaMax, minDistance);
        //agents.PlaceAgentsInRows(new Vector3(-30, 0, 10));

        //agents.PlaceAgentsRandomlyDictionary(AreaMin, AreaMax, minDistance);
        //agents.PlaceAgentsInRowsDictionary(new Vector3(0, 0, 0));


        // LIST/COLLECTIONS INSTANTIATION
        randomStartPositions = agents.randomStartPositions;
        listAgents           = agents.listAgents;
        steeringForces       = CM.StartingSteeringDirections(listAgents.Count, velocity);
        dictionaryAgents     = agents.dictionaryAgents;


        // INSTANTIATE SEED
        //SeedInstance = new Seed(seed, SeedPosition, blueGlowMaterial);


        // INSTANTIATE LEADER
        //LeaderInstance = new Leader(leader, leaderStartPosition, blueGlowMaterial, velocity);



        /////////  COROUTINE METHODS  /////////

        // SQUARE MARCH (-> Use with PlaceAgentsInRows)
        //StartCoroutine("SquareMarch");


        // MESSAGE PROPAGATION ALGORITHM (-> Use with PlaceAgentsRandomly)
        //GameObject emitter = Instantiate(agent, SeedPosition, Quaternion.identity);
        //emitter.GetComponent<Renderer>().material = blueGlowMaterial;
        //StartCoroutine(Blink(emitter));
        //StartCoroutine("MessagePropagation");


        // SELF ASSEMBLY ALGORITHM (^ uncomment the imagePixels instantiation)
        //StartCoroutine("SelfAssemblyOneByOne");
        //StartCoroutine(SequentialAssembly(SeekAssignedPosition));
        //StartCoroutine(SequentialAssembly(SeekClosestPosition));


        // PARTICLE SWARM OPTIMIZATION
        SO = new SwarmOptimization(randomStartPositions, NumAgents, velocity, AreaMin, AreaMax);
        StartCoroutine(ParticleSwarmOptimization(200));
    }