예제 #1
0
    private void generateCell(Genom genom, bool mutationOnly = false)
    {
        GameObject newCell = Instantiate(cellPrefab);

        if (genom != null)
        {
            Cell nc = newCell.GetComponent <Cell>();

            Genom g = genom.clone();
            if (mutationOnly || Random.value > 0.5)
            {
                nc.getGenom().mutate();
            }
            else if (leaderBoard.Count > 1)
            {
                nc.getGenom().crossWith(leaderBoard[Random.Range(0, leaderBoard.Count)]);
            }

            nc.setGenom(g);
        }

        Vector3 newPosition = new Vector3(Random.value * worldSize - worldSize / 2, 1, Random.value * worldSize - worldSize / 2);

        newCell.transform.SetPositionAndRotation(newPosition, Quaternion.identity);
    }