Example #1
0
 public void occupyCell(int x, int y, int z, AbstractEnvironmentType env)
 {
     env.clearGridCellByIndex(curx, cury, curz);
     env.occupyGridCellByIndex(tempx, tempy, tempz, ID);
     curx = tempx;
     cury = tempy;
     curz = tempz;
     resetFloatingPointPosition(env);
     if (_moved_successfully)
     {
         env.increaseTrailByIndex(curx, cury, curz, _ca_torealease);
     }
 }
Example #2
0
 public void occupyCell(int x, int y, int z, AbstractEnvironmentType env)
 {
     env.clearGridCellByIndex(curx, cury, curz);
     env.occupyGridCellByIndex(tempx, tempy, tempz, ID);
     curx = tempx;
     cury = tempy;
     curz = tempz;
     resetFloatingPointPosition(env);
     if (_moved_successfully)
         env.increaseTrailByIndex(curx, cury, curz, _ca_torealease);
 }
Example #3
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);
     }
 }
Example #4
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);
                }
            }
        }