Exemple #1
0
        public bool initializeAmoeba(double x, double y, double z, int radius, AbstractEnvironmentType env, Libutility util)
        {
            int     try_count    = 0;
            Point3d IniIndexLoca = env.getIndexByPosition(x, y, z);
            int     start_x      = (int)IniIndexLoca.X - radius > 0 ? (int)IniIndexLoca.X - radius : 0;
            int     start_y      = (int)IniIndexLoca.Y - radius > 0 ? (int)IniIndexLoca.Y - radius : 0;
            int     start_z      = (int)IniIndexLoca.Z - radius > 0 ? (int)IniIndexLoca.Z - radius : 0;
            int     end_x        = (int)IniIndexLoca.X + radius < env.u ? (int)IniIndexLoca.X + radius : env.u - 1;
            int     end_y        = (int)IniIndexLoca.Y + radius < env.v ? (int)IniIndexLoca.Y + radius : env.v - 1;
            int     end_z        = (int)IniIndexLoca.Z + radius < env.w ? (int)IniIndexLoca.Z + radius : env.w - 1;

            do
            {
                tempx = util.getRand(start_x, end_x + 1);
                tempy = util.getRand(start_y, end_y + 1);
                tempz = util.getRand(start_z, end_z + 1);
                try_count++;
            }while (!iniSuccess(tempx, tempy, tempz, env, util) && try_count < 10);
            curx = tempx;
            cury = tempy;
            curz = tempz;
            //Location = new Point3d(curx, cury, curz);
            Location = env.getPositionByIndex(curx, cury, curz);
            occupyCell(curx, cury, curz, env);
            selectRandomDirection(env, util);
            prev_loc = new Point3d(x, y, z);
            return(true);
        }
Exemple #2
0
        public bool initializeAmoeba(double x, double y, double z, AbstractEnvironmentType env, Libutility util)
        {
            Point3d indexLoca = env.getIndexByPosition(x, y, z);

            tempx = (int)indexLoca.X;
            tempy = (int)indexLoca.Y;
            tempz = (int)indexLoca.Z;
            curx  = tempx;
            cury  = tempy;
            curz  = tempz;
            //Location = new Point3d(curx, cury, curz);
            Location = env.getPositionByIndex(curx, cury, curz);
            occupyCell(curx, cury, curz, env);
            selectRandomDirection(env, util);
            prev_loc = Location;
            return(true);
        }
Exemple #3
0
 public bool initializeAmoeba(AbstractEnvironmentType env, Libutility util)
 {
     do
     {
         tempfloatx = (float)util.getDoubleRand(env.getUMin(), env.getUMax());
         tempfloaty = (float)util.getDoubleRand(env.getVMin(), env.getVMax());
         tempfloatz = (float)util.getDoubleRand(env.getWMin(), env.getWMax());
         Point3d indexPos = env.getIndexByPosition(tempfloatx, tempfloaty, tempfloatz);
         tempx = (int)indexPos.X;
         tempy = (int)indexPos.Y;
         tempz = (int)indexPos.Z;
     }while (!iniSuccess(tempx, tempy, tempz, env, util));
     curx = tempx;
     cury = tempy;
     curz = tempz;
     //Location = new Point3d(curx, cury, curz);
     Location = env.getPositionByIndex(curx, cury, curz);
     occupyCell(curx, cury, curz, env);
     selectRandomDirection(env, util);
     prev_loc = Location;
     return(true);
 }
Exemple #4
0
 public bool initializeAmoeba(double x, double y, double z,  int radius, AbstractEnvironmentType env, Libutility util)
 {
     int try_count = 0;
     Point3d IniIndexLoca = env.getIndexByPosition(x, y, z);
     int start_x = (int)IniIndexLoca.X - radius > 0 ? (int)IniIndexLoca.X - radius : 0;
     int start_y = (int)IniIndexLoca.Y - radius > 0 ? (int)IniIndexLoca.Y - radius : 0;
     int start_z = (int)IniIndexLoca.Z - radius > 0 ? (int)IniIndexLoca.Z - radius : 0;
     int end_x = (int)IniIndexLoca.X + radius < env.u ? (int)IniIndexLoca.X + radius : env.u - 1;
     int end_y = (int)IniIndexLoca.Y + radius < env.v ? (int)IniIndexLoca.Y + radius : env.v - 1;
     int end_z = (int)IniIndexLoca.Z + radius < env.w ? (int)IniIndexLoca.Z + radius : env.w - 1;
     do
     {
         tempx = util.getRand(start_x, end_x + 1);
         tempy = util.getRand(start_y, end_y + 1);
         tempz = util.getRand(start_z, end_z + 1);
         try_count++;
     }
     while (!iniSuccess(tempx, tempy, tempz, env, util) && try_count<10);
     curx = tempx;
     cury = tempy;
     curz = tempz;
     //Location = new Point3d(curx, cury, curz);
     Location = env.getPositionByIndex(curx, cury, curz);
     occupyCell(curx, cury, curz, env);
     selectRandomDirection(env, util);
     prev_loc = new Point3d(x, y, z);
     return true;
 }
Exemple #5
0
 public bool initializeAmoeba(double x, double y, double z, AbstractEnvironmentType env, Libutility util)
 {
     Point3d indexLoca = env.getIndexByPosition(x, y, z);
     tempx = (int)indexLoca.X;
     tempy = (int)indexLoca.Y;
     tempz = (int)indexLoca.Z;
     curx = tempx;
     cury = tempy;
     curz = tempz;
     //Location = new Point3d(curx, cury, curz);
     Location = env.getPositionByIndex(curx, cury, curz);
     occupyCell(curx, cury, curz, env);
     selectRandomDirection(env, util);
     prev_loc = Location;
     return true;
 }
Exemple #6
0
 public bool initializeAmoeba(AbstractEnvironmentType env, Libutility util)
 {
     do
     {
         tempfloatx = (float)util.getDoubleRand(env.getUMin(), env.getUMax());
         tempfloaty = (float)util.getDoubleRand(env.getVMin(), env.getVMax());
         tempfloatz = (float)util.getDoubleRand(env.getWMin(), env.getWMax());
         Point3d indexPos = env.getIndexByPosition(tempfloatx, tempfloaty, tempfloatz);
         tempx = (int)indexPos.X;
         tempy = (int)indexPos.Y;
         tempz = (int)indexPos.Z;
     }
     while (!iniSuccess(tempx, tempy, tempz, env, util));
     curx = tempx;
     cury = tempy;
     curz = tempz;
     //Location = new Point3d(curx, cury, curz);
     Location = env.getPositionByIndex(curx, cury, curz);
     occupyCell(curx, cury, curz, env);
     selectRandomDirection(env, util);
     prev_loc = Location;
     return true;
 }
Exemple #7
0
 public void doMotorBehaviors(AbstractEnvironmentType env, Libutility util)
 {
     _distance_traveled++;
     prev_loc = Location;
     //_cur_speed = _max_speed * (1 - _distance_traveled / _deathDistance);
     _cur_speed = PhysaSetting._speed;
     if (env.getGriddataByIndex(curx, cury, curz) == 1)
         _distance_traveled = 0;
     _moved_successfully = false;
     if (util.getRandDouble() < PhysaSetting._pcd)
     {
       selectRandomDirection(env, util);
       resetFloatingPointPosition(env);
       return;
     }
     Point3d curLoc = Location;
     curLoc.Transform(Transform.Translation(orientation));
     //Location = curLoc;
     tempfloatx = (float)curLoc.X;
     tempfloaty = (float)curLoc.Y;
     tempfloatz = (float)curLoc.Z;
     switch (PhysaSetting.border_type)
     {
         case 0:
             if(env.constrainPos(ref tempfloatx, ref tempfloaty, ref tempfloatz,0))
                 selectRandomDirection(env, util);
             break;
         case 1:
             env.constrainPos(ref tempfloatx, ref tempfloaty, ref tempfloatz, 1);
             break;
         case 2:
             env.constrainPos(ref tempfloatx, ref tempfloaty, ref tempfloatz, 0);
             orientation = env.bounceOrientation(curLoc, orientation);
             break;
         default:
             break;
     }
     //if(env.constrainPos(ref tempfloatx, ref tempfloaty, ref tempfloatz))
     //    selectRandomDirection(util);
     Point3d temppos = env.getIndexByPosition(tempfloatx, tempfloaty, tempfloatz);
     tempx = (int)temppos.X;
     tempy = (int)temppos.Y;
     tempz = (int)temppos.Z;
     if (env.isOccupidByParticleByIndex(tempx, tempy, tempz))
     {
         selectRandomDirection(env,util);
         return;
     }
     else if (env.isWithinObstacleByIndex(tempx, tempy, tempz) && util.getRandDouble() > PhysaSetting.escape_p)
     {
         selectRandomDirection(env,util);
         return;
     }
     else
     {
         _moved_successfully = true;
         Location = env.projectLocationToEnv(new Point3d(tempfloatx, tempfloaty, tempfloatz));
         env.clearGridCellByIndex(curx, cury, curz);
         //env.agedata[curx, cury, curz]++;
         env.occupyGridCellByIndex(tempx, tempy, tempz, ID);
         curx = tempx;
         cury = tempy;
         curz = tempz;
         //float trailIncrement = calculateTrailIncrement(util);
         //env.increaseTrailByIndex(curx, cury, curz, trailIncrement);
         env.increaseTrailByIndex(curx, cury, curz, _ca_torealease);
         //if (_moved_successfully && !_die && _distance_traveled % division_frequency_test == 0)
         if (_moved_successfully && !_die)
             doDivisionTest(env);
     }
 }
Exemple #8
0
        public void doMotorBehaviors(AbstractEnvironmentType env, Libutility util)
        {
            _distance_traveled++;
            prev_loc = Location;
            //_cur_speed = _max_speed * (1 - _distance_traveled / _deathDistance);
            _cur_speed = PhysaSetting._speed;
            if (env.getGriddataByIndex(curx, cury, curz) == 1)
            {
                _distance_traveled = 0;
            }
            _moved_successfully = false;
            if (util.getRandDouble() < PhysaSetting._pcd)
            {
                selectRandomDirection(env, util);
                resetFloatingPointPosition(env);
                return;
            }
            Point3d curLoc = Location;

            curLoc.Transform(Transform.Translation(orientation));
            //Location = curLoc;
            tempfloatx = (float)curLoc.X;
            tempfloaty = (float)curLoc.Y;
            tempfloatz = (float)curLoc.Z;
            switch (PhysaSetting.border_type)
            {
            case 0:
                if (env.constrainPos(ref tempfloatx, ref tempfloaty, ref tempfloatz, 0))
                {
                    selectRandomDirection(env, util);
                }
                break;

            case 1:
                env.constrainPos(ref tempfloatx, ref tempfloaty, ref tempfloatz, 1);
                break;

            case 2:
                env.constrainPos(ref tempfloatx, ref tempfloaty, ref tempfloatz, 0);
                orientation = env.bounceOrientation(curLoc, orientation);
                break;

            default:
                break;
            }
            //if(env.constrainPos(ref tempfloatx, ref tempfloaty, ref tempfloatz))
            //    selectRandomDirection(util);
            Point3d temppos = env.getIndexByPosition(tempfloatx, tempfloaty, tempfloatz);

            tempx = (int)temppos.X;
            tempy = (int)temppos.Y;
            tempz = (int)temppos.Z;
            if (env.isOccupidByParticleByIndex(tempx, tempy, tempz))
            {
                selectRandomDirection(env, util);
                return;
            }
            else if (env.isWithinObstacleByIndex(tempx, tempy, tempz) && util.getRandDouble() > PhysaSetting.escape_p)
            {
                selectRandomDirection(env, util);
                return;
            }
            else
            {
                _moved_successfully = true;
                Location            = env.projectLocationToEnv(new Point3d(tempfloatx, tempfloaty, tempfloatz));
                env.clearGridCellByIndex(curx, cury, curz);
                //env.agedata[curx, cury, curz]++;
                env.occupyGridCellByIndex(tempx, tempy, tempz, ID);
                curx = tempx;
                cury = tempy;
                curz = tempz;
                //float trailIncrement = calculateTrailIncrement(util);
                //env.increaseTrailByIndex(curx, cury, curz, trailIncrement);
                env.increaseTrailByIndex(curx, cury, curz, _ca_torealease);
                //if (_moved_successfully && !_die && _distance_traveled % division_frequency_test == 0)
                if (_moved_successfully && !_die)
                {
                    doDivisionTest(env);
                }
            }
        }