public override IPointAdapter GetNextLocation()
    {
        IPointAdapter point = positions[currentIteration];

        IterationHandler.GetInstance().UpdateIteration(currentIteration);
        if (currentIteration == deathDate) //notify the movement script that the cell should die
        {
            isDone = true;
            CellDoneHandler.CellDone();
            foreach (ICellDeathListener listener in cellDeathListeners)
            {
                listener.Notify();
            }
        }
        else if (children.ContainsKey(currentIteration)) //send the command to create the new e-coli object
        {
            model.GiveBirthToCell(children[currentIteration]);
        }

        if (currentIteration == iterations && !isDone)
        {
            CellDoneHandler.CellDone();
            isDone = true;
        }
        currentIteration = currentIteration + 1 > iterations ? iterations : currentIteration + 1;

        return(point);
    }
Example #2
0
 public Customer()
 {
     if (adapter == null)
     {
         adapter = Connector.Instance().PointAdapter;
     }
 }
Example #3
0
    // Start is called before the first frame update
    void Start()
    {
        model = Model.GetInstance();
        model.AddListener(this);
        List <Cell> cells = model.GetCells(0);

        if (cells == null)
        {
            return;
        }

        for (int i = 0; i < model.GetNumCells(0); i++) //create the E-Coli objects for the cells
        {
            IPointAdapter point = cells[i].GetNextLocation();
            Movement      tmp   = Instantiate(eColi, new Vector3(point.GetX(), 1, point.GetZ()), Quaternion.Euler(0, cells[i].GetAngle(), 0));
            tmp.SetCell(cells[i]);
        }

        AbstractEnvironment environment = model.environment;

        if (environment is MultiLigandEnvironment)
        {
            foreach (Environment env in ((MultiLigandEnvironment)environment).GetEnvironments())
            {
                Instantiate(food, new Vector3(env.GetX(), 1.88f, env.GetZ()), Quaternion.identity);
            }
        }
        else
        {
            Instantiate(food, new Vector3(environment.GetX(), 1.88f, environment.GetX()), Quaternion.identity);
        }
    }
Example #4
0
    private float smartnessFactor; //decides how random the movement of the bacteria should be 1=deterministic and 0=random

    public SmartInternals(float x, float z, float dT, float v, float smartnessFactor)
    {
        this.dT = dT;
        this.v  = v;
        this.smartnessFactor = smartnessFactor;//smartnessFactor;

        model = Model.GetInstance();

        location = new Vector3Adapter(x, z);
    }
Example #5
0
        public long UpdatePoint(PointObject pointObj)
        {
            IPointAdapter adapter = Connector.Instance().PointAdapter;

            if (adapter != null)
            {
                adapter.UpdatePoint(pointObj);
            }
            points += pointObj.Value;
            return(points);
        }
Example #6
0
    public void Notify(Cell cell)
    {
        IPointAdapter point = cell.GetNextLocation();
        Movement      tmp   = Instantiate(eColi, new Vector3(point.GetX(), 1, point.GetZ()), Quaternion.Euler(0, cell.GetAngle(), 0));

        tmp.SetCell(cell);
        // Play lil particle effect
        var cellBirthMain = cellBirth.main;

        cellBirthMain.simulationSpeed = model.GetTimeScaleFactor();
        Instantiate(cellBirth, new Vector3(point.GetX(), 2, point.GetZ()), Quaternion.Euler(0, cell.GetAngle(), 0));
    }
    protected void CalculateNextLocation(IPointAdapter location)
    {
        float dX = v * dT * MathFloat.Cos(angle), dZ = v * dT * MathFloat.Sin(angle);

        while (location.GetX() + dX > 14 || location.GetX() + dX < -14 || location.GetZ() + dZ > 14 || location.GetZ() + dZ < -14)
        {
            angle = CalculateTumbleAngle();
            dX    = v * dT * MathFloat.Cos(angle);
            dZ    = v * dT * MathFloat.Sin(angle);
        }
        location.Add(dX, dZ);
    }
    //Method that returns the number of cells that are within a given distance of the given location
    //only to be used with cells that have a ForwardsInternals as their internals (since iteration does not make sense otherwise)
    public int GetNumOfCloseCells(int iteration, float distance, IPointAdapter location)
    {
        int num = 0;

        distance *= distance; //removes the need for sqrt operation

        foreach (Cell cell in cells[iteration])
        {
            if (!(cell.GetInternals() is ForwardInternals))
            {
                continue;
            }
            IPointAdapter cellLocation = ((ForwardInternals)cell.GetInternals()).GetPosition(iteration);
            if (MathFloat.Pow(cellLocation.GetX() - location.GetX(), 2) + MathFloat.Pow(cellLocation.GetZ() - location.GetZ(), 2) <= distance)
            {
                num++;
            }
        }

        return(num);
    }
Example #9
0
 public IPointAdapter GetNextLocation()
 {
     location = CalculateNextPoint(location.GetX(), location.GetZ(), model.environment);
     return(location);
 }
 public bool Equals(IPointAdapter other)
 {
     return(point.x == other.GetX() && point.z == other.GetZ());
 }
 private Vector3 TranslateToVector3(IPointAdapter pointToTranslate) => new Vector3(pointToTranslate.GetX(), transform.position.y, pointToTranslate.GetZ());
Example #12
0
 public Internals(float x, float z, float v, float dT, float angle, ICellRegulation regulator) : base(v, dT, angle, regulator)
 {
     location = new Vector3Adapter(x, z);
 }