Exemplo n.º 1
0
CBaseBot::CBaseBot()
{
  agent_interface.id = cfg_get_unique_id() + rand();

  agent_interface.param = 0;
  agent_interface.value = 0;
  agent_interface.color_intensity = 1.0;

  agent_interface.time_stamp = get_ms_time();
  agent_interface.type = AGENT_TYPE_BOT;
  agent_interface.type_behaviour = ROBOT_TYPE_BASE;
  agent_interface.type_interaction = AGENT_TYPE_INTERACTION_WEAK;
  agent_interface.size = AGENT_BOT_SIZE*3.0;
  agent_interface.request =  AGENT_REQUEST_NULL;

  agent_interface.x = 0.1*rnd_()*POSITION_MAX_X; //*x_max;
  agent_interface.y = 0.1*rnd_()*POSITION_MAX_Y; //*y_max;
  agent_interface.z = 0.0*rnd_()*0.99;//*z_max;

  agent_interface.roll = 0.0;
  agent_interface.pitch = 0.0;
  agent_interface.yaw = 0.0;

  agent_interface.dt = cfg_get_dt();

  agent_interface.action_type = ACTION_TYPE_NULL;

  dx = 0.0;
  dy = 0.0;
  dz = 0.0;
  dyaw = 0.0;

  client = new CClient();
}
Exemplo n.º 2
0
float rnd_gauss_dist(float min, float max, float stddev)
{
    float mean = ( min + max )/2.0;
    float x = rnd_();
    float E = 2.718281828;

    float expo = - (pow((x - mean),2) / (2*pow(stddev,2)));
    return (1.0/(stddev*sqrt(2*PI))*pow(E,expo))*sgn(rnd_());
}
Exemplo n.º 3
0
CBasisFunctions::CBasisFunctions(u32 count, u32 dimension, float a_range, float b_range, float w_range, u32 function_type)
{
  this->functions_count = count;
  this->dimension = dimension;

  this->a_range = a_range;
  this->b_range = b_range;
  this->w_range = w_range;

  this->function_type = function_type;

  #ifdef DEBUG_MODE
  printf("  basis function type %u\n", this->function_type);
  #endif

  u32 j, i;

  a = (float**)malloc(this->functions_count*sizeof(float*));
  b = (float*)malloc(this->functions_count*sizeof(float));


  for (j = 0; j < this->functions_count; j++)
  {
    a[j] = (float*)malloc(this->dimension*sizeof(float));

    for (i = 0; i < this->dimension; i++)
      a[j][i] = this->a_range*rnd_();  //in range -a_range..a_range


    if (function_type == BASIS_FUNCTION_TYPE_GAUSS)
    {
      float k = 0.90;
      b[j] = this->b_range*(k + (1.0 - k)*abs_(rnd_()));
    }
    else
    {
      float k = 0.50;
      b[j] = this->b_range*(k + (1.0 - k)*abs_(rnd_()));
    }
  }

  for (j = 0; j < this->functions_count; j++)
    output.push_back(0.0);

  w = (float*)malloc(this->functions_count*sizeof(float));
  distance = (float*)malloc(this->functions_count*sizeof(float));
  for (j = 0; j < this->functions_count; j++)
  {
    w[j] = 0.0;
    distance[j] = 0.0;
  }

  for (i = 0; i < this->dimension; i++)
    input.push_back(0.0);

  linear_combination = 0.0;
}
Exemplo n.º 4
0
float gauss_dist(float mean, float stddev)
{
    float x = rnd_();
    float E = 2.718281828;
    float expo = - (pow((x - mean),2) / (2*pow(stddev,2)));
    return (1.0/(stddev*sqrt(2*PI))*pow(E,expo));
}
Exemplo n.º 5
0
void createPalms(Ogre::SceneManager *mSceneMgr)
{
	const int NumberOfPalms = 12;

	Ogre::SceneNode* mPalmsSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
		
	for (int k = 0; k < NumberOfPalms; k++)
	{
		Ogre::Vector3 RandomPos = Ogre::Vector3(rnd_(500,2500),
			0,
			rnd_(500,2500));

		Ogre::RaySceneQuery * raySceneQuery = mSceneMgr->
			createRayQuery(Ogre::Ray(RandomPos + Ogre::Vector3(0,1000000,0), 
			Ogre::Vector3::NEGATIVE_UNIT_Y));

		Ogre::RaySceneQueryResult& qryResult = raySceneQuery->execute();
		Ogre::RaySceneQueryResult::iterator i = qryResult.begin();

		if (i != qryResult.end() && i->worldFragment)
		{
			if (i->worldFragment->singleIntersection.y>105 || i->worldFragment->singleIntersection.y<20)
			{
				k--;
				continue;
			}

			RandomPos.y = i->worldFragment->singleIntersection.y;
		}
		else
		{
			k--;
			continue;
		}

		Ogre::Entity *mPalmEnt = mSceneMgr->createEntity("Palm"+Ogre::StringConverter::toString(k), "Palm.mesh");
		Ogre::SceneNode *mPalmSN = mPalmsSceneNode->createChildSceneNode();

		mPalmSN->rotate(Ogre::Vector3(-1,0,rnd_(-0.3,0.3)), Ogre::Degree(90));
		mPalmSN->attachObject(mPalmEnt);
		Ogre::Real Scale = rnd_(50,75);
		mPalmSN->scale(Scale,Scale,Scale);
		mPalmSN->setPosition(RandomPos);
	}
}
Exemplo n.º 6
0
void peak_hill_random(struct sPeakHill *func, u32 dim, u32 peak_count, u32 hill_count)
{
  u32 i, j;
  std::vector<float> tmp;
  for (i = 0; i < dim; i++)
    tmp.push_back(0.0);

  for (j = 0; j < peak_count; j++)
  {
    for (i = 0; i < dim; i++)
      tmp[i] = rnd_();
    func->p_alpha.push_back(tmp);
    func->p_r.push_back(-4.0*abs_(rnd_()));
  }

  for (j = 0; j < hill_count; j++)
  {
    for (i = 0; i < dim; i++)
      tmp[i] = rnd_();
    func->h_alpha.push_back(tmp);
    func->h_beta.push_back(10.0 + 10.0*abs_(rnd_()));
    func->h_w.push_back(abs_(rnd_()));
  }
}
Exemplo n.º 7
0
void CServer::update_position(u32 robot_idx)
{
    u32 i, j;

    float position_new[ROBOT_SPACE_DIMENSION];
    float tmp_dist = ROBOT_SPACE_DIMENSION;
    std::vector<u32> colisions_idx;

    i32 wall_idx = -1;

    for (i = 0; i < ROBOT_SPACE_DIMENSION; i++)
        position_new[i] = robots[robot_idx].position[i] + 5.0*robots[robot_idx].d[i]*dt*0.001 + 0.001*rnd_();

    for (j = 0; j < robots.size(); j++)
        //if ( (j != robot_idx) && (robots[j].type&ROBOT_SOLID_FLAG) )
        if ( (j != robot_idx) && (robots[j].type&ROBOT_STRONG_SOLID_FLAG) )
        {
            tmp_dist = vect_distance(position_new, robots[j].position, ROBOT_SPACE_DIMENSION);

            if (tmp_dist < colision_distance)
            {
                colisions_idx.push_back(j);
                if (robots[j].type&ROBOT_STRONG_SOLID_FLAG)
                    wall_idx = j;
            }
        }


    if (colisions_idx.size() == 0)
        //there is no colision
        for (i = 0; i < ROBOT_SPACE_DIMENSION; i++)
            robots[robot_idx].position[i] = saturate(position_new[i], -position_max[i], position_max[i]);
    else
    {
        for (i = 0; i < ROBOT_SPACE_DIMENSION; i++)
        {
            float tmp = 0.0;
            if (wall_idx == -1)
                tmp = -5.0*robots[robot_idx].d[i]*dt*0.001 + 0.001*rnd_();
            else
            {
                tmp = 0.1*(robots[robot_idx].position[i] - robots[wall_idx].position[i] + 0.001*rnd_());
            }

            robots[robot_idx].position[i] = saturate(robots[robot_idx].position[i] + tmp, -position_max[i], position_max[i]);
        }
    }
}
Exemplo n.º 8
0
Arquivo: dso5.c Projeto: mgius/zork
logical opncls_(integer obj, integer so, integer sc)
{
   /* System generated locals */
   logical ret_val;

   ret_val = TRUE_;
   /* 						!ASSUME WINS. */
   if (prsvec_1.prsa == vindex_1.closew) {
      goto L100;
   }
   /* 						!CLOSE? */
   if (prsvec_1.prsa == vindex_1.openw) {
      goto L50;
   }
   /* 						!OPEN? */
   ret_val = FALSE_;
   /* 						!LOSE */
   return ret_val;

L50:
   if ((objcts_1.oflag2[obj - 1] & OPENBT) != 0) {
      goto L200;
   }
   /* 						!OPEN... IS IT? */
   rspeak_(so);
   objcts_1.oflag2[obj - 1] |= OPENBT;
   return ret_val;

L100:
   if (! ((objcts_1.oflag2[obj - 1] & OPENBT) != 0)) {
      goto L200;
   }
   /* 						!CLOSE... IS IT? */
   rspeak_(sc);
   objcts_1.oflag2[obj - 1] &= ~ OPENBT;
   return ret_val;

L200:
   rspeak_(rnd_(3) + 125);
   /* 						!DUMMY. */
   return ret_val;
} /* opncls_ */
Exemplo n.º 9
0
void CServer::respawn(struct sRobot *robot)
{
    std::vector<float> position;

    u32 i, j;

    for (i = 0; i < ROBOT_SPACE_DIMENSION; i++)
        position.push_back(0.0);

    float dist_min;
    do
    {
        /*
        for (i = 0; i < ROBOT_SPACE_DIMENSION; i++)
            position[i] = rnd_()*200.0;
        */

        for (i = 0; i < ROBOT_SPACE_DIMENSION; i++)
            position[i] = rnd_()*position_max[i]*0.8;


        dist_min = 99999999999999999999.9;
        for (j = 0; j < robots.size(); j++)
        {
            float dist = 0.0;
            for (i = 0; i < ROBOT_SPACE_DIMENSION; i++)
                dist+= abs_(position[i] - robots[j].position[i]);

            if (dist < dist_min)
                dist_min = dist;
        }
    }
        while (dist_min < (colision_distance*2.0));


    for (i = 0; i < ROBOT_SPACE_DIMENSION; i++)
        robot->position[i] = position[i];
}
Exemplo n.º 10
0
CAction::CAction(u32 states_count, u32 actions_per_state, u32 action_width, std::vector<std::vector<float>> *action_init)
{
	u32 k, j, i;

	for (k = 0; k < states_count; k++)
	{
		//actions in one state
		std::vector<struct sAction> actions_tmp;

		//actions initialziation
		for (j = 0; j < actions_per_state; j++)
		{
			struct sAction action;

			for (i = 0; i < action_width; i++)
				action.action.push_back(0.0);

			if (action_init != NULL)
			{
				for (i = 0; i < action_width; i++)
					action.action[i] = (*action_init)[j][i];

			}
			else
			{
				for (i = 0; i < action_width; i++)
					action.action[i] = sgn(rnd_());
			}

			action.fitness = ACTION_FITNESS_MIN;
			action.usability = 0.0;
			actions_tmp.push_back(action);
		}

		actions.push_back(actions_tmp);
	}
}
Exemplo n.º 11
0
Arquivo: demons.c Projeto: CViles/zork
integer blow_(integer h, integer v, integer rmk, integer hflg, integer out)
{
   /* Initialized data */

   const integer rmiss = 0;
   const integer rout = 1;
   const integer rkill = 2;
   const integer rstag = 5;
   const integer rlose = 6;
   const integer rhes = 7;
   const integer rsit = 8;
   static const integer def1r[3] = { 1,2,3 };
   static const integer def2r[4] = { 13,23,24,25 };
   static const integer def3r[5] = { 35,36,46,47,57 };
   static const integer rvectr[66] = { 0,0,0,0,5,5,1,1,2,2,2,2,0,0,0,0,0,5,
      5,3,3,1,0,0,0,5,5,3,3,3,1,2,2,2,0,0,0,0,0,5,5,3,3,4,4,0,0,0,5,5,
      3,3,3,4,4,4,0,5,5,3,3,3,3,4,4,4 };
   static const integer rstate[45] = { 5000,3005,3008,4011,3015,3018,1021,
      0,0,5022,3027,3030,4033,3037,3040,1043,0,0,4044,2048,4050,4054,
      5058,4063,4067,3071,1074,4075,1079,4080,4084,4088,4092,4096,4100,
      1104,4105,2109,4111,4115,4119,4123,4127,3131,3134 };

   /* System generated locals */
   integer ret_val, i__1, i__2;

   /* Local variables */
   logical f;
   integer i, j, oa, ra, od, mi, dv, def;
   integer tbl;
   integer att, res;
   integer dweap;
   integer pblose;

   ra = objcts_1.oactio[v - 1];
   /* 						!GET VILLAIN ACTION, */
   dv = objcts_1.odesc2[v - 1];
   /* 						!DESCRIPTION. */
   ret_val = rmiss;
   /* 						!ASSUME NO RESULT. */
   if (! (hflg)) {
      goto L1000;
   }
   /* 						!HERO STRIKING BLOW? */

   /* HERO IS ATTACKER, VILLAIN IS DEFENDER. */

   pblose = 10;
   /* 						!BAD LK PROB. */
   objcts_1.oflag2[v - 1] |= FITEBT;
   if ((advs_1.aflag[h - 1] & aflags_1.astag) == 0) {
      goto L100;
   }
   rspeak_(591);
   /* 						!YES, CANT FIGHT. */
   advs_1.aflag[h - 1] &= ~ aflags_1.astag;
   return ret_val;

L100:
   att = fights_(h, 1);
   /* 						!GET HIS STRENGTH. */
   oa = att;
   def = vilstr_(v);
   /* 						!GET VILL STRENGTH. */
   od = def;
   dweap = 0;
   /* 						!ASSUME NO WEAPON. */
   i__1 = objcts_1.olnt;
   for (i = 1; i <= i__1; ++i) {
      /* 						!SEARCH VILLAIN. */
      if (objcts_1.ocan[i - 1] == v && (objcts_1.oflag2[i - 1] & 
               WEAPBT) != 0) {
         dweap = i;
      }
      /* L200: */
   }
   if (v == advs_1.aobj[aindex_1.player - 1]) {
      goto L300;
   }
   /* 						!KILLING SELF? */
   if (def != 0) {
      goto L2000;
   }
   /* 						!DEFENDER ALIVE? */
   rspsub_(592, dv);
   /* 						!VILLAIN DEAD. */
   return ret_val;

L300:
   jigsup_(593);
   /* 						!KILLING SELF. */
   return ret_val;

   /* VILLAIN IS ATTACKER, HERO IS DEFENDER. */

L1000:
   pblose = 50;
   /* 						!BAD LK PROB. */
   advs_1.aflag[h - 1] &= ~ aflags_1.astag;
   if ((objcts_1.oflag2[v - 1] & STAGBT) == 0) {
      goto L1200;
   }
   objcts_1.oflag2[v - 1] &= ~ STAGBT;
   rspsub_(594, dv);
   /* 						!DESCRIBE. */
   return ret_val;

L1200:
   att = vilstr_(v);
   /* 						!SET UP ATT, DEF. */
   oa = att;
   def = fights_(h, 1);
   if (def <= 0) {
      return ret_val;
   }
   /* 						!DONT ALLOW DEAD DEF. */
   od = fights_(h, 0);
   dweap = (i__1 = fwim_(0, WEAPBT, 0, 0, h, 1), 
         abs(i__1));
   /* 						!FIND A WEAPON. */
   /* BLOW, PAGE 4 */

   /* PARTIES ARE NOW EQUIPPED.  DEF CANNOT BE ZERO. */
   /* ATT MUST BE > 0. */

L2000:
   if (def > 0) {
      goto L2100;
   }
   /* 						!DEF ALIVE? */
   res = rkill;
   if (hflg) {
      rspsub_(595, dv);
   }
   /* 						!DEADER. */
   goto L3000;

L2100:
   if ((i__1 = def - 2) < 0) {
      goto L2200;
   } else if (i__1 == 0) {
      goto L2300;
   } else {
      goto L2400;
   }
   /* 						!DEF <2,=2,>2 */
L2200:
   att = min(att,3);
   /* 						!SCALE ATT. */
   tbl = def1r[att - 1];
   /* 						!CHOOSE TABLE. */
   goto L2500;

L2300:
   att = min(att,4);
   /* 						!SCALE ATT. */
   tbl = def2r[att - 1];
   /* 						!CHOOSE TABLE. */
   goto L2500;

L2400:
   att -= def;
   /* 						!SCALE ATT. */
   /* Computing MIN */
   i__1 = 2, i__2 = max(-2,att);
   att = min(i__1,i__2) + 3;
   tbl = def3r[att - 1];

L2500:
   res = rvectr[tbl + rnd_(10) - 1];
   /* 						!GET RESULT. */
   if (out == 0) {
      goto L2600;
   }
   /* 						!WAS HE OUT? */
   if (res == rstag) {
      goto L2550;
   }
   /* 						!YES, STAG--> HES. */
   res = rsit;
   /* 						!OTHERWISE, SITTING. */
   goto L2600;
L2550:
   res = rhes;
L2600:
   if (res == rstag && dweap != 0 && prob_(25, pblose)) {
      res = rlose;
   }

   mi = rstate[(rmk - 1) * 9 + res];
   /* 						!CHOOSE TABLE ENTRY. */
   if (mi == 0) {
      goto L3000;
   }
   i__1 = mi / 1000;
   i = mi % 1000 + rnd_(i__1) + star_1.mbase + 1;
   j = dv;
   if (! (hflg) && dweap != 0) {
      j = objcts_1.odesc2[dweap - 1];
   }
   rspsub_(i, j);
   /* 						!PRESENT RESULT. */
   /* BLOW, PAGE 5 */

   /* NOW APPLY RESULT */

L3000:
   switch (res + 1) {
   case 1:  goto L4000;
   case 2:  goto L3100;
   case 3:  goto L3200;
   case 4:  goto L3300;
   case 5:  goto L3400;
   case 6:  goto L3500;
   case 7:  goto L3600;
   case 8:  goto L4000;
   case 9:  goto L3200;
   }

L3100:
   if (hflg) {
      def = -def;
   }
   /* 						!UNCONSCIOUS. */
   goto L4000;

L3200:
   def = 0;
   /* 						!KILLED OR SITTING DUCK. */
   goto L4000;

L3300:
   /* Computing MAX */
   i__1 = 0, i__2 = def - 1;
   def = max(i__1,i__2);
   /* 						!LIGHT WOUND. */
   goto L4000;

L3400:
   /* Computing MAX */
   i__1 = 0, i__2 = def - 2;
   def = max(i__1,i__2);
   /* 						!SERIOUS WOUND. */
   goto L4000;

L3500:
   if (hflg) {
      goto L3550;
   }
   /* 						!STAGGERED. */
   advs_1.aflag[h - 1] |= aflags_1.astag;
   goto L4000;

L3550:
   objcts_1.oflag2[v - 1] |= STAGBT;
   goto L4000;

L3600:
   newsta_(dweap, 0, play_1.here, 0, 0);
   /* 						!LOSE WEAPON. */
   dweap = 0;
   if (hflg) {
      goto L4000;
   }
   /* 						!IF HERO, DONE. */
   dweap = (i__1 = fwim_(0, WEAPBT, 0, 0, h, 1), 
         abs(i__1));
   /* 						!GET NEW. */
   if (dweap != 0) {
      rspsub_(605, objcts_1.odesc2[dweap - 1]);
   }
   /* BLOW, PAGE 6 */

L4000:
   ret_val = res;
   /* 						!RETURN RESULT. */
   if (! (hflg)) {
      goto L4500;
   }
   /* 						!HERO? */
   objcts_1.ocapac[v - 1] = def;
   /* 						!STORE NEW CAPACITY. */
   if (def != 0) {
      goto L4100;
   }
   /* 						!DEAD? */
   objcts_1.oflag2[v - 1] &= ~ FITEBT;
   rspsub_(572, dv);
   /* 						!HE DIES. */
   newsta_(v, 0, 0, 0, 0);
   /* 						!MAKE HIM DISAPPEAR. */
   if (ra == 0) {
      return ret_val;
   }
   /* 						!IF NX TO DO, EXIT. */
   prsvec_1.prsa = vindex_1.deadxw;
   /* 						!LET HIM KNOW. */
   f = oappli_(ra, 0);
   return ret_val;

L4100:
   if (res != rout || ra == 0) {
      return ret_val;
   }
   prsvec_1.prsa = vindex_1.outxw;
   /* 						!LET HIM BE OUT. */
   f = oappli_(ra, 0);
   return ret_val;

L4500:
   advs_1.astren[h - 1] = -10000;
   /* 						!ASSUME DEAD. */
   if (def != 0) {
      advs_1.astren[h - 1] = def - od;
   }
   if (def >= od) {
      goto L4600;
   }
   cevent_1.ctick[cindex_1.cevcur - 1] = 30;
   cevent_1.cflag[cindex_1.cevcur - 1] = TRUE_;
L4600:
   if (fights_(h, 1) > 0) {
      return ret_val;
   }
   advs_1.astren[h - 1] = 1 - fights_(h, 0);
   /* 						!HE'S DEAD. */
   jigsup_(596);
   ret_val = -1;
   return ret_val;

} /* blow_ */
Exemplo n.º 12
0
Arquivo: demons.c Projeto: CViles/zork
void fightd_()
{
   /* Initialized data */

   const integer rout = 1;

   /* Local variables */
   logical f;
   integer i, j, ra;
   integer obj;
   integer res;
   integer out;

   for (i = 1; i <= vill_1.vlnt; ++i) {
      /* 						!LOOP THRU VILLAINS. */
      vill_1.vopps[i - 1] = 0;
      /* 						!CLEAR OPPONENT SLOT. */
      obj = vill_1.villns[i - 1];
      /* 						!GET OBJECT NO. */
      ra = objcts_1.oactio[obj - 1];
      /* 						!GET HIS ACTION. */
      if (play_1.here != objcts_1.oroom[obj - 1]) {
         if (!((objcts_1.oflag2[obj - 1] & FITEBT) == 0 || ra == 0)) {
            prsvec_1.prsa = vindex_1.fightw;
            /* 						!HAVE A FIGHT. */
            f = oappli_(ra, 0);
         }
         if (obj == oindex_1.thief) {
            findex_1.thfenf = FALSE_;
         }
         /* 						!TURN OFF ENGROSSED. */
         advs_1.aflag[aindex_1.player - 1] &= ~ aflags_1.astag;
         objcts_1.oflag2[obj - 1] &= ~ (STAGBT + FITEBT);
         if (objcts_1.ocapac[obj - 1] >= 0 || ra == 0) {
            continue;
         }
         prsvec_1.prsa = vindex_1.inxw;
         /* 						!WAKE HIM UP. */
         f = oappli_(ra, 0);
         objcts_1.ocapac[obj - 1] = abs(objcts_1.ocapac[obj - 1]);
         continue;
      }
      /* 						!ADVENTURER STILL HERE? */
      if (obj == oindex_1.thief && findex_1.thfenf) {
         continue;
      }
      /* 						!THIEF ENGROSSED? */
      if (objcts_1.ocapac[obj - 1] >= 0) {
         if ((objcts_1.oflag2[obj - 1] & FITEBT) == 0) {
            if (ra == 0) {
               continue;
            }
            /* 						!NOT FIGHTING, */
            prsvec_1.prsa = vindex_1.frstqw;
            /* 						!SET UP PROBABILITY */
            if (! oappli_(ra, 0)) {
               continue;
            }
            /* 						!OF FIGHTING. */
            objcts_1.oflag2[obj - 1] |= FITEBT;
            vill_1.vopps[i - 1] = obj;
            /* 						!SET UP OPP. */
            continue;
         }
         vill_1.vopps[i - 1] = obj;
         /* 						!FIGHTING, SET UP OPP. */
         continue;
      }
      /* 						!YES, VILL AWAKE? */
      if (vill_1.vprob[i - 1] == 0 || ! prob_(vill_1.vprob[i - 1], 
               vill_1.vprob[i - 1])) {
         vill_1.vprob[i - 1] += 10;
         /* 						!INCREASE WAKEUP PROB. */
         continue;
      /* 						!NOTHING ELSE. */
      }
      objcts_1.ocapac[obj - 1] = abs(objcts_1.ocapac[obj - 1]);
      vill_1.vprob[i - 1] = 0;
      if (ra == 0) {
         continue;
      }
      /* 						!ANYTHING TO DO? */
      prsvec_1.prsa = vindex_1.inxw;
      /* 						!YES, WAKE HIM UP. */
      f = oappli_(ra, 0);
      continue;
      /* 						!NOTHING ELSE HAPPENS. */
   }
   /* FIGHTD, PAGE 3 */

   /* NOW DO ACTUAL COUNTERBLOWS. */

   out = 0;
   /* 						!ASSUME HERO OK. */
   do {
      for (i = 1; i <= vill_1.vlnt; ++i) {
         /* 						!LOOP THRU OPPS. */
         j = vill_1.vopps[i - 1];
         if (j == 0) {
            continue;
         }
         /* 						!SLOT EMPTY? */
         prsvec_1.prscon = 1;
         /* 						!STOP CMD STREAM. */
         ra = objcts_1.oactio[j - 1];
         if (ra != 0) {
            /* 						!VILLAIN ACTION? */
            prsvec_1.prsa = vindex_1.fightw;
            /* 						!SEE IF */
            if (oappli_(ra, 0)) {
               continue;
            }
         }
         /* 						!SPECIAL ACTION. */
         res = blow_(aindex_1.player, j, vill_1.vmelee[i - 1], 0, out);

         /* 						!STRIKE BLOW. */
         if (res < 0) {
            return;
         }
         /* 						!IF HERO DEAD, EXIT. */
         if (res == rout) {
            out = rnd_(3) + 2;
         }
         /* 						!IF HERO OUT, SET FLG. */
      }
      --out;
      /* 						!DECREMENT OUT COUNT. */
   } while (out > 0);
      /* 						!IF STILL OUT, GO AGAIN. */
      return;

} /* fightd_ */
Exemplo n.º 13
0
logical nobjs_(integer ri, integer arg)
{
    /* System generated locals */
    // TODO See if arg is needed
    integer i__1, i__2 = arg;
    logical ret_val;

    /* Local variables */
    integer target;
    integer i;
    integer j;
    integer wl;
    integer nxt, odi2 = 0, odo2 = 0;

    if (prsvec_1.prso != 0) {
	odo2 = objcts_1.odesc2[prsvec_1.prso - 1];
    }
    if (prsvec_1.prsi != 0) {
	odi2 = objcts_1.odesc2[prsvec_1.prsi - 1];
    }
    ret_val = TRUE_;

    switch (ri - 31) {
	case 1:  goto L1000;
	case 2:  goto L2000;
	case 3:  goto L3000;
	case 4:  goto L4000;
	case 5:  goto L5000;
	case 6:  goto L6000;
	case 7:  goto L7000;
	case 8:  goto L8000;
	case 9:  goto L9000;
	case 10:  goto L10000;
	case 11:  goto L11000;
	case 12:  goto L12000;
	case 13:  goto L13000;
	case 14:  goto L14000;
	case 15:  goto L15000;
	case 16:  goto L16000;
	case 17:  goto L17000;
	case 18:  goto L18000;
	case 19:  goto L19000;
	case 20:  goto L20000;
	case 21:  goto L21000;
    }
    bug_(6, ri);

/* RETURN HERE TO DECLARE FALSE RESULT */

L10:
    ret_val = FALSE_;
    return ret_val;

/* O32--	BILLS */

L1000:
    if (prsvec_1.prsa != vindex_1.eatw) {
	goto L1100;
    }
/* 						!EAT? */
    rspeak_(639);
/* 						!JOKE. */
    return ret_val;

L1100:
    if (prsvec_1.prsa == vindex_1.burnw) {
	rspeak_(640);
    }
/* 						!BURN?  JOKE. */
    goto L10;
/* 						!LET IT BE HANDLED. */
/* NOBJS, PAGE 3 */

/* O33--	SCREEN OF LIGHT */

L2000:
    target = oindex_1.scol;
/* 						!TARGET IS SCOL. */
L2100:
    if (prsvec_1.prso != target) {
	goto L2400;
    }
/* 						!PRSO EQ TARGET? */
    if (prsvec_1.prsa != vindex_1.pushw && prsvec_1.prsa != vindex_1.movew && 
	    prsvec_1.prsa != vindex_1.takew && prsvec_1.prsa != vindex_1.rubw)
	     {
	goto L2200;
    }
    rspeak_(673);
/* 						!HAND PASSES THRU. */
    return ret_val;

L2200:
    if (prsvec_1.prsa != vindex_1.killw && prsvec_1.prsa != vindex_1.attacw &&
	     prsvec_1.prsa != vindex_1.mungw) {
	goto L2400;
    }
    rspsub_(674, odi2);
/* 						!PASSES THRU. */
    return ret_val;

L2400:
    if (prsvec_1.prsa != vindex_1.throww || prsvec_1.prsi != target) {
	goto L10;
    }
    if (play_1.here == rindex_1.bkbox) {
	goto L2600;
    }
/* 						!THRU SCOL? */
    newsta_(prsvec_1.prso, 0, rindex_1.bkbox, 0, 0);
/* 						!NO, THRU WALL. */
    rspsub_(675, odo2);
/* 						!ENDS UP IN BOX ROOM. */
    cevent_1.ctick[cindex_1.cevscl - 1] = 0;
/* 						!CANCEL ALARM. */
    screen_1.scolrm = 0;
/* 						!RESET SCOL ROOM. */
    return ret_val;

L2600:
    if (screen_1.scolrm == 0) {
	goto L2900;
    }
/* 						!TRIED TO GO THRU? */
    newsta_(prsvec_1.prso, 0, screen_1.scolrm, 0, 0);
/* 						!SUCCESS. */
    rspsub_(676, odo2);
/* 						!ENDS UP SOMEWHERE. */
    cevent_1.ctick[cindex_1.cevscl - 1] = 0;
/* 						!CANCEL ALARM. */
    screen_1.scolrm = 0;
/* 						!RESET SCOL ROOM. */
    return ret_val;

L2900:
    rspeak_(213);
/* 						!CANT DO IT. */
    return ret_val;
/* NOBJS, PAGE 4 */

/* O34--	GNOME OF ZURICH */

L3000:
    if (prsvec_1.prsa != vindex_1.givew && prsvec_1.prsa != vindex_1.throww) {

	goto L3200;
    }
    if (objcts_1.otval[prsvec_1.prso - 1] != 0) {
	goto L3100;
    }
/* 						!THROW A TREASURE? */
    newsta_(prsvec_1.prso, 641, 0, 0, 0);
/* 						!NO, GO POP. */
    return ret_val;

L3100:
    newsta_(prsvec_1.prso, 0, 0, 0, 0);
/* 						!YES, BYE BYE TREASURE. */
    rspsub_(642, odo2);
    newsta_(oindex_1.zgnom, 0, 0, 0, 0);
/* 						!BYE BYE GNOME. */
    cevent_1.ctick[cindex_1.cevzgo - 1] = 0;
/* 						!CANCEL EXIT. */
    moveto_(rindex_1.bkent, play_1.winner);
/* 						!NOW IN BANK ENTRANCE. */
    return ret_val;

L3200:
    if (prsvec_1.prsa != vindex_1.attacw && prsvec_1.prsa != vindex_1.killw &&
	     prsvec_1.prsa != vindex_1.mungw) {
	goto L3300;
    }
    newsta_(oindex_1.zgnom, 643, 0, 0, 0);
/* 						!VANISH GNOME. */
    cevent_1.ctick[cindex_1.cevzgo - 1] = 0;
/* 						!CANCEL EXIT. */
    return ret_val;

L3300:
    rspeak_(644);
/* 						!GNOME IS IMPATIENT. */
    return ret_val;

/* O35--	EGG */

L4000:
    if (prsvec_1.prsa != vindex_1.openw || prsvec_1.prso != oindex_1.egg) {
	goto L4500;
    }
    if (! ((objcts_1.oflag2[oindex_1.egg - 1] & OPENBT) != 0)) {
	goto L4100;
    }
/* 						!OPEN ALREADY? */
    rspeak_(649);
/* 						!YES. */
    return ret_val;

L4100:
    if (prsvec_1.prsi != 0) {
	goto L4200;
    }
/* 						!WITH SOMETHING? */
    rspeak_(650);
/* 						!NO, CANT. */
    return ret_val;

L4200:
    if (prsvec_1.prsi != oindex_1.hands) {
	goto L4300;
    }
/* 						!WITH HANDS? */
    rspeak_(651);
/* 						!NOT RECOMMENDED. */
    return ret_val;

L4300:
    i = 652;
/* 						!MUNG MESSAGE. */
    if ((objcts_1.oflag1[prsvec_1.prsi - 1] & TOOLBT) != 0 || (
	    objcts_1.oflag2[prsvec_1.prsi - 1] & WEAPBT) != 0) {
	goto L4600;
    }
    i = 653;
/* 						!NOVELTY 1. */
    if ((objcts_1.oflag2[prsvec_1.prso - 1] & FITEBT) != 0) {
	i = 654;
    }
    objcts_1.oflag2[prsvec_1.prso - 1] |= FITEBT;
    rspsub_(i, odi2);
    return ret_val;

L4500:
    if (prsvec_1.prsa != vindex_1.openw && prsvec_1.prsa != vindex_1.mungw) {
	goto L4800;
    }
    i = 655;
/* 						!YOU BLEW IT. */
L4600:
    newsta_(oindex_1.begg, i, objcts_1.oroom[oindex_1.egg - 1], 
	    objcts_1.ocan[oindex_1.egg - 1], objcts_1.oadv[oindex_1.egg - 1])
	    ;
    newsta_(oindex_1.egg, 0, 0, 0, 0);
/* 						!VANISH EGG. */
    objcts_1.otval[oindex_1.begg - 1] = 2;
/* 						!BAD EGG HAS VALUE. */
    if (objcts_1.ocan[oindex_1.canar - 1] != oindex_1.egg) {
	goto L4700;
    }
/* 						!WAS CANARY INSIDE? */
    rspeak_(objcts_1.odesco[oindex_1.bcana - 1]);
/* 						!YES, DESCRIBE RESULT. */
    objcts_1.otval[oindex_1.bcana - 1] = 1;
    return ret_val;

L4700:
    newsta_(oindex_1.bcana, 0, 0, 0, 0);
/* 						!NO, VANISH IT. */
    return ret_val;

L4800:
    if (prsvec_1.prsa != vindex_1.dropw || play_1.here != rindex_1.mtree) {
	goto L10;
    }
    newsta_(oindex_1.begg, 658, rindex_1.fore3, 0, 0);
/* 						!DROPPED EGG. */
    newsta_(oindex_1.egg, 0, 0, 0, 0);
    objcts_1.otval[oindex_1.begg - 1] = 2;
    if (objcts_1.ocan[oindex_1.canar - 1] != oindex_1.egg) {
	goto L4700;
    }
    objcts_1.otval[oindex_1.bcana - 1] = 1;
/* 						!BAD CANARY. */
    return ret_val;
/* NOBJS, PAGE 5 */

/* O36--	CANARIES, GOOD AND BAD */

L5000:
    if (prsvec_1.prsa != vindex_1.windw) {
	goto L10;
    }
/* 						!WIND EM UP? */
    if (prsvec_1.prso == oindex_1.canar) {
	goto L5100;
    }
/* 						!RIGHT ONE? */
    rspeak_(645);
/* 						!NO, BAD NEWS. */
    return ret_val;

L5100:
    if (! findex_1.singsf &&
        (play_1.here == rindex_1.mtree ||
         (play_1.here >= rindex_1.fore1 && play_1.here < rindex_1.clear))) {
	goto L5200;
    }
    rspeak_(646);
/* 						!NO, MEDIOCRE NEWS. */
    return ret_val;

L5200:
    findex_1.singsf = TRUE_;
/* 						!SANG SONG. */
    i = play_1.here;
    if (i == rindex_1.mtree) {
	i = rindex_1.fore3;
    }
/* 						!PLACE BAUBLE. */
    newsta_(oindex_1.baubl, 647, i, 0, 0);
    return ret_val;

/* O37--	WHITE CLIFFS */

L6000:
    if (prsvec_1.prsa != vindex_1.clmbw && prsvec_1.prsa != vindex_1.clmbuw &&
	     prsvec_1.prsa != vindex_1.clmbdw) {
	goto L10;
    }
    rspeak_(648);
/* 						!OH YEAH? */
    return ret_val;

/* O38--	WALL */

L7000:
    if ((i__1 = play_1.here - findex_1.mloc, abs(i__1)) != 1 || mrhere_(
	    play_1.here) != 0 || prsvec_1.prsa != vindex_1.pushw) {
	goto L7100;
    }
    rspeak_(860);
/* 						!PUSHED MIRROR WALL. */
    return ret_val;

L7100:
    if ((rooms_1.rflag[play_1.here - 1] & RNWALL) == 0) {
	goto L10;
    }
    rspeak_(662);
/* 						!NO WALL. */
    return ret_val;
/* NOBJS, PAGE 6 */

/* O39--	SONG BIRD GLOBAL */

L8000:
    if (prsvec_1.prsa != vindex_1.findw) {
	goto L8100;
    }
/* 						!FIND? */
    rspeak_(666);
    return ret_val;

L8100:
    if (prsvec_1.prsa != vindex_1.examiw) {
	goto L10;
    }
/* 						!EXAMINE? */
    rspeak_(667);
    return ret_val;

/* O40--	PUZZLE/SCOL WALLS */

L9000:
    if (play_1.here != rindex_1.cpuzz) {
	goto L9500;
    }
/* 						!PUZZLE WALLS? */
    if (prsvec_1.prsa != vindex_1.pushw) {
	goto L10;
    }
/* 						!PUSH? */
    for (i = 1; i <= 8; i += 2) {
/* 						!LOCATE WALL. */
	if (prsvec_1.prso == puzzle_1.cpwl[i - 1]) {
	    goto L9200;
	}
/* L9100: */
    }
    bug_(80, prsvec_1.prso);
/* 						!WHAT? */

L9200:
    // TODO Check the following error from cppcheck
    // [nobjs.c:396]: (error) Array 'puzzle_.cpwl[8]' accessed at index 9, which is out of bounds.
    // Possible solution change to i-1
    j = puzzle_1.cpwl[i];
/* 						!GET DIRECTIONAL OFFSET. */
    nxt = findex_1.cphere + j;
/* 						!GET NEXT STATE. */
    wl = puzzle_1.cpvec[nxt - 1];
/* 						!GET C(NEXT STATE). */
    switch (wl + 4) {
	case 1:  goto L9300;
	case 2:  goto L9300;
	case 3:  goto L9300;
	case 4:  goto L9250;
	case 5:  goto L9350;
    }
/* 						!PROCESS. */

L9250:
    rspeak_(876);
/* 						!CLEAR CORRIDOR. */
    return ret_val;

L9300:
    if (puzzle_1.cpvec[nxt + j - 1] == 0) {
	goto L9400;
    }
/* 						!MOVABLE, ROOM TO MOVE? */
L9350:
    rspeak_(877);
/* 						!IMMOVABLE, NO ROOM. */
    return ret_val;

L9400:
    i = 878;
/* 						!ASSUME FIRST PUSH. */
    if (findex_1.cpushf) {
	i = 879;
    }
/* 						!NOT? */
    findex_1.cpushf = TRUE_;
    puzzle_1.cpvec[nxt + j - 1] = wl;
/* 						!MOVE WALL. */
    puzzle_1.cpvec[nxt - 1] = 0;
/* 						!VACATE NEXT STATE. */
    cpgoto_(nxt);
/* 						!ONWARD. */
    cpinfo_(i, nxt);
/* 						!DESCRIBE. */
    princr_(1, play_1.here);
/* 						!PRINT ROOMS CONTENTS. */
    rooms_1.rflag[play_1.here - 1] |= RSEEN;
    return ret_val;

L9500:
    if (play_1.here != screen_1.scolac) {
	goto L9700;
    }
/* 						!IN SCOL ACTIVE ROOM? */
    for (i = 1; i <= 12; i += 3) {
	target = screen_1.scolwl[i];
/* 						!ASSUME TARGET. */
	if (screen_1.scolwl[i - 1] == play_1.here) {
	    goto L2100;
	}
/* 						!TREAT IF FOUND. */
/* L9600: */
    }

L9700:
    if (play_1.here != rindex_1.bkbox) {
	goto L10;
    }
/* 						!IN BOX ROOM? */
    target = oindex_1.wnort;
    goto L2100;
/* NOBJS, PAGE 7 */

/* O41--	SHORT POLE */

L10000:
    if (prsvec_1.prsa != vindex_1.raisew) {
	goto L10100;
    }
/* 						!LIFT? */
    i = 749;
/* 						!ASSUME UP. */
    if (findex_1.poleuf == 2) {
	i = 750;
    }
/* 						!ALREADY UP? */
    rspeak_(i);
    findex_1.poleuf = 2;
/* 						!POLE IS RAISED. */
    return ret_val;

L10100:
    if (prsvec_1.prsa != vindex_1.lowerw && prsvec_1.prsa != vindex_1.pushw) {

	goto L10;
    }
    if (findex_1.poleuf != 0) {
	goto L10200;
    }
/* 						!ALREADY LOWERED? */
    rspeak_(751);
/* 						!CANT DO IT. */
    return ret_val;

L10200:
    if (findex_1.mdir % 180 != 0) {
	goto L10300;
    }
/* 						!MIRROR N-S? */
    findex_1.poleuf = 0;
/* 						!YES, LOWER INTO */
    rspeak_(752);
/* 						!CHANNEL. */
    return ret_val;

L10300:
    if (findex_1.mdir != 270 || findex_1.mloc != rindex_1.mrb) {
	goto L10400;
    }
    findex_1.poleuf = 0;
/* 						!LOWER INTO HOLE. */
    rspeak_(753);
    return ret_val;

L10400:
    i__1 = findex_1.poleuf + 753;
    rspeak_(i__1);
/* 						!POLEUF = 1 OR 2. */
    findex_1.poleuf = 1;
/* 						!NOW ON FLOOR. */
    return ret_val;

/* O42--	MIRROR SWITCH */

L11000:
    if (prsvec_1.prsa != vindex_1.pushw) {
	goto L10;
    }
/* 						!PUSH? */
    if (findex_1.mrpshf) {
	goto L11300;
    }
/* 						!ALREADY PUSHED? */
    rspeak_(756);
/* 						!BUTTON GOES IN. */
    i__1 = objcts_1.olnt;
    for (i = 1; i <= i__1; ++i) {
/* 						!BLOCKED? */
	if (qhere_(i, rindex_1.mreye) && i != oindex_1.rbeam) {
	    goto L11200;
	}
/* L11100: */
    }
    rspeak_(757);
/* 						!NOTHING IN BEAM. */
    return ret_val;

L11200:
    cevent_1.cflag[cindex_1.cevmrs - 1] = TRUE_;
/* 						!MIRROR OPENS. */
    cevent_1.ctick[cindex_1.cevmrs - 1] = 7;
    findex_1.mrpshf = TRUE_;
    findex_1.mropnf = TRUE_;
    return ret_val;

L11300:
    rspeak_(758);
/* 						!MIRROR ALREADYOPEN. */
    return ret_val;
/* NOBJS, PAGE 8 */

/* O43--	BEAM FUNCTION */

L12000:
    if (prsvec_1.prsa != vindex_1.takew || prsvec_1.prso != oindex_1.rbeam) {
	goto L12100;
    }
    rspeak_(759);
/* 						!TAKE BEAM, JOKE. */
    return ret_val;

L12100:
    i = prsvec_1.prso;
/* 						!ASSUME BLK WITH DIROBJ. */
    if (prsvec_1.prsa == vindex_1.putw && prsvec_1.prsi == oindex_1.rbeam) {
	goto L12200;
    }
    if (prsvec_1.prsa != vindex_1.mungw || prsvec_1.prso != oindex_1.rbeam || 
	    prsvec_1.prsi == 0) {
	goto L10;
    }
    i = prsvec_1.prsi;
L12200:
    if (objcts_1.oadv[i - 1] != play_1.winner) {
	goto L12300;
    }
/* 						!CARRYING? */
    newsta_(i, 0, play_1.here, 0, 0);
/* 						!DROP OBJ. */
    rspsub_(760, objcts_1.odesc2[i - 1]);
    return ret_val;

L12300:
    j = 761;
/* 						!ASSUME NOT IN ROOM. */
    if (qhere_(j, play_1.here)) {
	i = 762;
    }
/* 						!IN ROOM? */
    // TODO Check the following error from cppcheck
    // [nobjs.c:607]: (error) Array 'objcts_.odesc2[220]' accessed at index 761, which is out of bounds.
    rspsub_(j, objcts_1.odesc2[i - 1]);
/* 						!DESCRIBE. */
    return ret_val;

/* O44--	BRONZE DOOR */

L13000:
    if (play_1.here == rindex_1.ncell ||
        (findex_1.lcell == 4 && (play_1.here == rindex_1.cell || play_1.here == rindex_1.scorr))) {
	goto L13100;
    }
    rspeak_(763);
/* 						!DOOR NOT THERE. */
    return ret_val;

L13100:
    if (! opncls_(oindex_1.odoor, 764, 765)) {
	goto L10;
    }
/* 						!OPEN/CLOSE? */
    if (play_1.here == rindex_1.ncell && (objcts_1.oflag2[oindex_1.odoor - 1] 
	    & OPENBT) != 0) {
	rspeak_(766);
    }
    return ret_val;

/* O45--	QUIZ DOOR */

L14000:
    if (prsvec_1.prsa != vindex_1.openw && prsvec_1.prsa != vindex_1.closew) {

	goto L14100;
    }
    rspeak_(767);
/* 						!DOOR WONT MOVE. */
    return ret_val;

L14100:
    if (prsvec_1.prsa != vindex_1.knockw) {
	goto L10;
    }
/* 						!KNOCK? */
    if (findex_1.inqstf) {
	goto L14200;
    }
/* 						!TRIED IT ALREADY? */
    findex_1.inqstf = TRUE_;
/* 						!START INQUISITION. */
    cevent_1.cflag[cindex_1.cevinq - 1] = TRUE_;
    cevent_1.ctick[cindex_1.cevinq - 1] = 2;
    findex_1.quesno = rnd_(8);
/* 						!SELECT QUESTION. */
    findex_1.nqatt = 0;
    findex_1.corrct = 0;
    rspeak_(768);
/* 						!ANNOUNCE RULES. */
    rspeak_(769);
    i__1 = findex_1.quesno + 770;
    rspeak_(i__1);
/* 						!ASK QUESTION. */
    return ret_val;

L14200:
    rspeak_(798);
/* 						!NO REPLY. */
    return ret_val;

/* O46--	LOCKED DOOR */

L15000:
    if (prsvec_1.prsa != vindex_1.openw) {
	goto L10;
    }
/* 						!OPEN? */
    rspeak_(778);
/* 						!CANT. */
    return ret_val;

/* O47--	CELL DOOR */

L16000:
    ret_val = opncls_(oindex_1.cdoor, 779, 780);
/* 						!OPEN/CLOSE? */
    return ret_val;
/* NOBJS, PAGE 9 */

/* O48--	DIALBUTTON */

L17000:
    if (prsvec_1.prsa != vindex_1.pushw) {
	goto L10;
    }
/* 						!PUSH? */
    rspeak_(809);
/* 						!CLICK. */
    if ((objcts_1.oflag2[oindex_1.cdoor - 1] & OPENBT) != 0) {
	rspeak_(810);
    }
/* 						!CLOSE CELL DOOR. */

    i__1 = objcts_1.olnt;
    for (i = 1; i <= i__1; ++i) {
/* 						!RELOCATE OLD TO HYPER. */
	if (objcts_1.oroom[i - 1] == rindex_1.cell && (objcts_1.oflag1[i - 1] 
		& DOORBT) == 0) {
	    i__2 = findex_1.lcell * hyper_1.hfactr;
	    newsta_(i, 0, i__2, 0, 0);
	}
	if (objcts_1.oroom[i - 1] == findex_1.pnumb * hyper_1.hfactr) {
	    newsta_(i, 0, rindex_1.cell, 0, 0);
	}
/* L17100: */
    }

    objcts_1.oflag2[oindex_1.odoor - 1] &= ~ OPENBT;
    objcts_1.oflag2[oindex_1.cdoor - 1] &= ~ OPENBT;
    objcts_1.oflag1[oindex_1.odoor - 1] &= ~ VISIBT;
    if (findex_1.pnumb == 4) {
	objcts_1.oflag1[oindex_1.odoor - 1] |= VISIBT;
    }

    if (advs_1.aroom[aindex_1.player - 1] != rindex_1.cell) {
	goto L17400;
    }
/* 						!PLAYER IN CELL? */
    if (findex_1.lcell != 4) {
	goto L17200;
    }
/* 						!IN RIGHT CELL? */
    objcts_1.oflag1[oindex_1.odoor - 1] |= VISIBT;
    moveto_(rindex_1.ncell, aindex_1.player);
/* 						!YES, MOVETO NCELL. */
    goto L17400;
L17200:
    moveto_(rindex_1.pcell, aindex_1.player);
/* 						!NO, MOVETO PCELL. */

L17400:
    findex_1.lcell = findex_1.pnumb;
    return ret_val;
/* NOBJS, PAGE 10 */

/* O49--	DIAL INDICATOR */

L18000:
    if (prsvec_1.prsa != vindex_1.spinw) {
	goto L18100;
    }
/* 						!SPIN? */
    findex_1.pnumb = rnd_(8) + 1;
/* 						!WHEE */
/* 						! */
    i__1 = findex_1.pnumb + 712;
    rspsub_(797, i__1);
    return ret_val;

L18100:
    if (prsvec_1.prsa != vindex_1.movew && prsvec_1.prsa != vindex_1.putw && 
	    prsvec_1.prsa != vindex_1.trntow) {
	goto L10;
    }
    if (prsvec_1.prsi != 0) {
	goto L18200;
    }
/* 						!TURN DIAL TO X? */
    rspeak_(806);
/* 						!MUST SPECIFY. */
    return ret_val;

L18200:
    if (prsvec_1.prsi >= oindex_1.num1 && prsvec_1.prsi <= oindex_1.num8) {
	goto L18300;
    }
    rspeak_(807);
/* 						!MUST BE DIGIT. */
    return ret_val;

L18300:
    findex_1.pnumb = prsvec_1.prsi - oindex_1.num1 + 1;
/* 						!SET UP NEW. */
    i__1 = findex_1.pnumb + 712;
    rspsub_(808, i__1);
    return ret_val;

/* O50--	GLOBAL MIRROR */

L19000:
    ret_val = mirpan_(832, 0);
    return ret_val;

/* O51--	GLOBAL PANEL */

L20000:
    if (play_1.here != rindex_1.fdoor) {
	goto L20100;
    }
/* 						!AT FRONT DOOR? */
    if (prsvec_1.prsa != vindex_1.openw && prsvec_1.prsa != vindex_1.closew) {

	goto L10;
    }
    rspeak_(843);
/* 						!PANEL IN DOOR, NOGO. */
    return ret_val;

L20100:
    ret_val = mirpan_(838, 1);
    return ret_val;

/* O52--	PUZZLE ROOM SLIT */

L21000:
    if (prsvec_1.prsa != vindex_1.putw || prsvec_1.prsi != oindex_1.cslit) {
	goto L10;
    }
    if (prsvec_1.prso != oindex_1.gcard) {
	goto L21100;
    }
/* 						!PUT CARD IN SLIT? */
    newsta_(prsvec_1.prso, 863, 0, 0, 0);
/* 						!KILL CARD. */
    findex_1.cpoutf = TRUE_;
/* 						!OPEN DOOR. */
    objcts_1.oflag1[oindex_1.stldr - 1] &= ~ VISIBT;
    return ret_val;

L21100:
    if ((objcts_1.oflag1[prsvec_1.prso - 1] & VICTBT) == 0 && (
	    objcts_1.oflag2[prsvec_1.prso - 1] & VILLBT) == 0) {
	goto L21200;
    }
    i__1 = rnd_(5) + 552;
    rspeak_(i__1);
/* 						!JOKE FOR VILL, VICT. */
    return ret_val;

L21200:
    newsta_(prsvec_1.prso, 0, 0, 0, 0);
/* 						!KILL OBJECT. */
    rspsub_(864, odo2);
/* 						!DESCRIBE. */
    return ret_val;

} /* nobjs_ */
Exemplo n.º 14
0
int main()
{
	srand(time(NULL));

	struct sRobotInit robot_init;

	robot_init.x = 0.0;
	robot_init.y = 0.0;
	robot_init.theta = 0.0;

	robot_init.wheel_diameter = 300.0;
	robot_init.wheel_distance = 800.0;

	robot_init.encoder_resolution = 1000;

	class CRobotModel *robot_model;

	robot_model = new CRobotModel(robot_init);

	class CLog *robot_log;
	robot_log = new CLog((char*)"robot_log.txt", 10);

	class CLog *nn_log;
	nn_log = new CLog((char*)"nn_result/nn_log.txt", 11);


	struct sRobotOutput robot_output, robot_output_filtered; //, robot_output_filtered_prev;

	u32 k;
	float error_filtered = 0.0;


	struct sNNInitStruct nn_init;

	u32 init_vector[] = {3, 10, 3};

	for (k = 0; k < 3; k++)
		nn_init.init_vector.push_back(init_vector[k]);

	nn_init.weight_range = 4.0;
	nn_init.init_weight_range = 0.01*1.0/nn_init.weight_range;
	nn_init.learning_constant = 1.0/100.0;
	nn_init.output_limit = 4.0;

	nn_init.neuron_type = NN_LAYER_NEURON_TYPE_TANH;
	nn_init.order = 5;

	class CNN *nn;

	nn = new CNN(nn_init);

	/*
	struct sNeuralNetworkInitStructure nn_init;



	nn_init.init_vector_size = 3;
	nn_init.init_vector = init_vector;
	nn_init.weight_range = 4.0;
	nn_init.learning_constant = 0.0001;
	nn_init.weight_range_init = 0.1;
	nn_init.order = 5;
	nn_init.neuron_type = NEURON_TYPE_MIXED;
	//nn_init.neuron_type = NEURON_TYPE_COMMON;

	class CNeuralNetwork *nn;
	nn = new CNeuralNetwork(nn_init);
	*/

	u32 iterations = 100000;

	//robot_output_filtered = robot_model->get_output_filtered();

	for (k = 0; k < iterations; k++)
	{
		robot_model->random_input(0.03);
		robot_model->process();


		robot_output = robot_model->get_output();

		//robot_output_filtered_prev = robot_output_filtered;
		robot_output_filtered = robot_model->get_output_filtered();

		float k_tmp = 1000.0;

		std::vector<float> nn_input;
		nn_input.push_back(robot_output_filtered.left_encoder);
		nn_input.push_back(robot_output_filtered.right_encoder);
		nn_input.push_back(1.0);


		std::vector<float> nn_required_output;
		/*
		nn_required_output.push_back(robot_output_filtered.x/500.0);
		nn_required_output.push_back(robot_output_filtered.y/500.0);
		nn_required_output.push_back(robot_output_filtered.theta*k_tmp/2500.0);
		*/
		nn_required_output.push_back(sin(robot_output_filtered.left_encoder));
		nn_required_output.push_back(cos(robot_output_filtered.right_encoder));
		nn_required_output.push_back(cos(robot_output_filtered.left_encoder + robot_output_filtered.right_encoder));

		std::vector<float> nn_output;
		nn_output.push_back(rnd_());
		nn_output.push_back(rnd_());
		nn_output.push_back(rnd_());

		nn->process(nn_input);

		nn_output = nn->get();

		if ( k < (iterations - 1000) )
			nn->learn(nn_required_output);


		float error = 0.0;
		u32 i;
		for (i = 0; i < nn_required_output.size(); i++)
			error+= abs_(nn_required_output[i] - nn_output[i]);

		float fil = 0.98;
		error_filtered = error_filtered*fil + abs_(error)*(1.0 - fil);

		if ( k > (iterations - 500) )
		{
			robot_log->add(0, robot_output.x);
			robot_log->add(1, robot_output.y);
			robot_log->add(2, robot_output.theta*k_tmp);
			robot_log->add(3, robot_output.left_encoder);
			robot_log->add(4, robot_output.right_encoder);

			robot_log->add(5, robot_output_filtered.x);
			robot_log->add(6, robot_output_filtered.y);
			robot_log->add(7, robot_output_filtered.theta*k_tmp);
			robot_log->add(8, robot_output_filtered.left_encoder);
			robot_log->add(9, robot_output_filtered.right_encoder);

			nn_log->add(0, nn_input[0]/1000.0);
			nn_log->add(1, nn_input[1]/1000.0);
			nn_log->add(2, nn_input[2]);

			nn_log->add(3, nn_required_output[0]);
			nn_log->add(4, nn_required_output[1]);
			nn_log->add(5, nn_required_output[2]);

			nn_log->add(6, nn_output[0]);
			nn_log->add(7, nn_output[1]);
			nn_log->add(8, nn_output[2]);

			nn_log->add(9, error);
			nn_log->add(10, error_filtered);
		}
	}

	robot_log->save();
	nn_log->save();

	nn->save((char*)"nn/nn");

	delete nn_log;
	delete robot_model;
	delete robot_log;
	delete nn;

	printf("program done\n");
	return 0;
}
Exemplo n.º 15
0
logical rappl1_(integer ri)
{
    /* System generated locals */
    integer i__1, i__2;
    logical ret_val;

    /* Local variables */
    integer i;
    integer j;

    ret_val = TRUE_;
/* 						!USUALLY IGNORED. */
    if (ri == 0) {
	return ret_val;
    }
/* 						!RETURN IF NAUGHT. */

/* 						!SET TO FALSE FOR */

/* 						!NEW DESC NEEDED. */
    switch (ri) {
	case 1:  goto L1000;
	case 2:  goto L2000;
	case 3:  goto L3000;
	case 4:  goto L4000;
	case 5:  goto L5000;
	case 6:  goto L6000;
	case 7:  goto L7000;
	case 8:  goto L8000;
	case 9:  goto L9000;
	case 10:  goto L10000;
	case 11:  goto L11000;
	case 12:  goto L12000;
	case 13:  goto L13000;
	case 14:  goto L14000;
	case 15:  goto L15000;
	case 16:  goto L16000;
	case 17:  goto L17000;
	case 18:  goto L18000;
	case 19:  goto L19000;
	case 20:  goto L20000;
	case 21:  goto L21000;
	case 22:  goto L22000;
	case 23:  goto L23000;
	case 24:  goto L24000;
	case 25:  goto L25000;
	case 26:  goto L26000;
	case 27:  goto L27000;
	case 28:  goto L28000;
	case 29:  goto L29000;
	case 30:  goto L30000;
	case 31:  goto L31000;
	case 32:  goto L32000;
	case 33:  goto L33000;
	case 34:  goto L34000;
	case 35:  goto L35000;
	case 36:  goto L36000;
	case 37:  goto L37000;
    }
    bug_(1, ri);

/* R1--	EAST OF HOUSE.  DESCRIPTION DEPENDS ON STATE OF WINDOW */

L1000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    i = 13;
/* 						!ASSUME CLOSED. */
    if ((objcts_1.oflag2[oindex_1.windo - 1] & OPENBT) != 0) {
	i = 12;
    }
/* 						!IF OPEN, AJAR. */
    rspsub_(11, i);
/* 						!DESCRIBE. */
    return ret_val;

/* R2--	KITCHEN.  SAME VIEW FROM INSIDE. */

L2000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    i = 13;
/* 						!ASSUME CLOSED. */
    if ((objcts_1.oflag2[oindex_1.windo - 1] & OPENBT) != 0) {
	i = 12;
    }
/* 						!IF OPEN, AJAR. */
    rspsub_(14, i);
/* 						!DESCRIBE. */
    return ret_val;

/* R3--	LIVING ROOM.  DESCRIPTION DEPENDS ON MAGICF (STATE OF */
/* 	DOOR TO CYCLOPS ROOM), RUG (MOVED OR NOT), DOOR (OPEN OR CLOSED) */

L3000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	goto L3500;
    }
/* 						!LOOK? */
    i = 15;
/* 						!ASSUME NO HOLE. */
    if (findex_1.magicf) {
	i = 16;
    }
/* 						!IF MAGICF, CYCLOPS HOLE. */
    rspeak_(i);
/* 						!DESCRIBE. */
    i = findex_1.orrug + 17;
/* 						!ASSUME INITIAL STATE. */
    if ((objcts_1.oflag2[oindex_1.door - 1] & OPENBT) != 0) {
	i += 2;
    }
/* 						!DOOR OPEN? */
    rspeak_(i);
/* 						!DESCRIBE. */
    return ret_val;

/* 	NOT A LOOK WORD.  REEVALUATE TROPHY CASE. */

L3500:
    if (prsvec_1.prsa != vindex_1.takew && (prsvec_1.prsa != vindex_1.putw || 
	    prsvec_1.prsi != oindex_1.tcase)) {
	return ret_val;
    }
    advs_1.ascore[play_1.winner - 1] = state_1.rwscor;
/* 						!SCORE TROPHY CASE. */
    i__1 = objcts_1.olnt;
    for (i = 1; i <= i__1; ++i) {
/* 						!RETAIN RAW SCORE AS WELL. */
	j = i;
/* 						!FIND OUT IF IN CASE. */
L3550:
	j = objcts_1.ocan[j - 1];
/* 						!TRACE OWNERSHIP. */
	if (j == 0) {
	    goto L3600;
	}
	if (j != oindex_1.tcase) {
	    goto L3550;
	}
/* 						!DO ALL LEVELS. */
	advs_1.ascore[play_1.winner - 1] += objcts_1.otval[i - 1];
L3600:
	;
    }
    scrupd_(0);
/* 						!SEE IF ENDGAME TRIG. */
    return ret_val;
/* RAPPL1, PAGE 3 */

/* R4--	CELLAR.  SHUT DOOR AND BAR IT IF HE JUST WALKED IN. */

L4000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	goto L4500;
    }
/* 						!LOOK? */
    rspeak_(21);
/* 						!DESCRIBE CELLAR. */
    return ret_val;

L4500:
    if (prsvec_1.prsa != vindex_1.walkiw) {
	return ret_val;
    }
/* 						!WALKIN? */
    if ((objcts_1.oflag2[oindex_1.door - 1] & (OPENBT + TCHBT)) != OPENBT) {
	return ret_val;
    }
    objcts_1.oflag2[oindex_1.door - 1] = (objcts_1.oflag2[oindex_1.door - 1] |
	     TCHBT) & ~ OPENBT;
    rspeak_(22);
/* 						!SLAM AND BOLT DOOR. */
    return ret_val;

/* R5--	MAZE11.  DESCRIBE STATE OF GRATING. */

L5000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    rspeak_(23);
/* 						!DESCRIBE. */
    i = 24;
/* 						!ASSUME LOCKED. */
    if (findex_1.grunlf) {
	i = 26;
    }
/* 						!UNLOCKED? */
    if ((objcts_1.oflag2[oindex_1.grate - 1] & OPENBT) != 0) {
	i = 25;
    }
/* 						!OPEN? */
    rspeak_(i);
/* 						!DESCRIBE GRATE. */
    return ret_val;

/* R6--	CLEARING.  DESCRIBE CLEARING, MOVE LEAVES. */

L6000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	goto L6500;
    }
/* 						!LOOK? */
    rspeak_(27);
/* 						!DESCRIBE. */
    if (findex_1.rvclr == 0) {
	return ret_val;
    }
/* 						!LEAVES MOVED? */
    i = 28;
/* 						!YES, ASSUME GRATE CLOSED. */
    if ((objcts_1.oflag2[oindex_1.grate - 1] & OPENBT) != 0) {
	i = 29;
    }
/* 						!OPEN? */
    rspeak_(i);
/* 						!DESCRIBE GRATE. */
    return ret_val;

L6500:
    if (findex_1.rvclr != 0 ||
        (qhere_(oindex_1.leave, rindex_1.clear) && (prsvec_1.prsa != vindex_1.movew)) ||
        prsvec_1.prso != oindex_1.leave) {
	return ret_val;
    }
    rspeak_(30);
/* 						!MOVE LEAVES, REVEAL GRATE. */
    findex_1.rvclr = 1;
/* 						!INDICATE LEAVES MOVED. */
    return ret_val;
/* RAPPL1, PAGE 4 */

/* R7--	RESERVOIR SOUTH.  DESCRIPTION DEPENDS ON LOW TIDE FLAG. */

L7000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    i = 31;
/* 						!ASSUME FULL. */
    if (findex_1.lwtidf) {
	i = 32;
    }
/* 						!IF LOW TIDE, EMPTY. */
    rspeak_(i);
/* 						!DESCRIBE. */
    rspeak_(33);
/* 						!DESCRIBE EXITS. */
    return ret_val;

/* R8--	RESERVOIR.  STATE DEPENDS ON LOW TIDE FLAG. */

L8000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    i = 34;
/* 						!ASSUME FULL. */
    if (findex_1.lwtidf) {
	i = 35;
    }
/* 						!IF LOW TIDE, EMTPY. */
    rspeak_(i);
/* 						!DESCRIBE. */
    return ret_val;

/* R9--	RESERVOIR NORTH.  ALSO DEPENDS ON LOW TIDE FLAG. */

L9000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    i = 36;
/* 						!YOU GET THE IDEA. */
    if (findex_1.lwtidf) {
	i = 37;
    }
    rspeak_(i);
    rspeak_(38);
    return ret_val;

/* R10--	GLACIER ROOM.  STATE DEPENDS ON MELTED, VANISHED FLAGS. */

L10000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    rspeak_(39);
/* 						!BASIC DESCRIPTION. */
    i = 0;
/* 						!ASSUME NO CHANGES. */
    if (findex_1.glacmf) {
	i = 40;
    }
/* 						!PARTIAL MELT? */
    if (findex_1.glacrf) {
	i = 41;
    }
/* 						!COMPLETE MELT? */
    rspeak_(i);
/* 						!DESCRIBE. */
    return ret_val;

/* R11--	FOREST ROOM */

L11000:
    if (prsvec_1.prsa == vindex_1.walkiw) {
	cevent_1.cflag[cindex_1.cevfor - 1] = TRUE_;
    }
/* 						!IF WALK IN, BIRDIE. */
    return ret_val;

/* R12--	MIRROR ROOM.  STATE DEPENDS ON MIRROR INTACT. */

L12000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    rspeak_(42);
/* 						!DESCRIBE. */
    if (findex_1.mirrmf) {
	rspeak_(43);
    }
/* 						!IF BROKEN, NASTY REMARK. */
    return ret_val;
/* RAPPL1, PAGE 5 */

/* R13--	CAVE2 ROOM.  BLOW OUT CANDLES WITH 50% PROBABILITY. */

L13000:
    if (prsvec_1.prsa != vindex_1.walkiw) {
	return ret_val;
    }
/* 						!WALKIN? */
    if (prob_(50, 50) || objcts_1.oadv[oindex_1.candl - 1] != 
	    play_1.winner || ! ((objcts_1.oflag1[oindex_1.candl - 1] & 
	    ONBT) != 0)) {
	return ret_val;
    }
    objcts_1.oflag1[oindex_1.candl - 1] &= ~ ONBT;
    rspeak_(47);
/* 						!TELL OF WINDS. */
    cevent_1.cflag[cindex_1.cevcnd - 1] = FALSE_;
/* 						!HALT CANDLE COUNTDOWN. */
    return ret_val;

/* R14--	BOOM ROOM.  BLOW HIM UP IF CARRYING FLAMING OBJECT. */

L14000:
    j = objcts_1.odesc2[oindex_1.candl - 1];
/* 						!ASSUME CANDLE. */
    if (objcts_1.oadv[oindex_1.candl - 1] == play_1.winner && (
	    objcts_1.oflag1[oindex_1.candl - 1] & ONBT) != 0) {
	goto L14100;
    }
    j = objcts_1.odesc2[oindex_1.torch - 1];
/* 						!ASSUME TORCH. */
    if (objcts_1.oadv[oindex_1.torch - 1] == play_1.winner && (
	    objcts_1.oflag1[oindex_1.torch - 1] & ONBT) != 0) {
	goto L14100;
    }
    j = objcts_1.odesc2[oindex_1.match - 1];
    if (objcts_1.oadv[oindex_1.match - 1] == play_1.winner && (
	    objcts_1.oflag1[oindex_1.match - 1] & ONBT) != 0) {
	goto L14100;
    }
    return ret_val;
/* 						!SAFE */

L14100:
    if (prsvec_1.prsa != vindex_1.trnonw) {
	goto L14200;
    }
/* 						!TURN ON? */
    rspsub_(294, j);
/* 						!BOOM */
/* 						! */
    jigsup_(44);
    return ret_val;

L14200:
    if (prsvec_1.prsa != vindex_1.walkiw) {
	return ret_val;
    }
/* 						!WALKIN? */
    rspsub_(295, j);
/* 						!BOOM */
/* 						! */
    jigsup_(44);
    return ret_val;

/* R15--	NO-OBJS.  SEE IF EMPTY HANDED, SCORE LIGHT SHAFT. */

L15000:
    findex_1.empthf = TRUE_;
/* 						!ASSUME TRUE. */
    i__1 = objcts_1.olnt;
    for (i = 1; i <= i__1; ++i) {
/* 						!SEE IF CARRYING. */
	if (objcts_1.oadv[i - 1] == play_1.winner) {
	    findex_1.empthf = FALSE_;
	}
/* L15100: */
    }

    if (play_1.here != rindex_1.bshaf || ! lit_(play_1.here)) {
	return ret_val;
    }
    scrupd_(state_1.ltshft);
/* 						!SCORE LIGHT SHAFT. */
    state_1.ltshft = 0;
/* 						!NEVER AGAIN. */
    return ret_val;
/* RAPPL1, PAGE 6 */

/* R16--	MACHINE ROOM.  DESCRIBE MACHINE. */

L16000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    i = 46;
/* 						!ASSUME LID CLOSED. */
    if ((objcts_1.oflag2[oindex_1.machi - 1] & OPENBT) != 0) {
	i = 12;
    }
/* 						!IF OPEN, OPEN. */
    rspsub_(45, i);
/* 						!DESCRIBE. */
    return ret_val;

/* R17--	BAT ROOM.  UNLESS CARRYING GARLIC, FLY AWAY WITH ME... */

L17000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	goto L17500;
    }
/* 						!LOOK? */
    rspeak_(48);
/* 						!DESCRIBE ROOM. */
    if (objcts_1.oadv[oindex_1.garli - 1] == play_1.winner) {
	rspeak_(49);
    }
/* 						!BAT HOLDS NOSE. */
    return ret_val;

L17500:
    if (prsvec_1.prsa != vindex_1.walkiw || objcts_1.oadv[oindex_1.garli - 1] 
	    == play_1.winner) {
	return ret_val;
    }
    rspeak_(50);
/* 						!TIME TO FLY, JACK. */
    moveto_(bats_1.batdrp[rnd_(9)], play_1.winner);
/* 						!SELECT RANDOM DEST. */
    ret_val = FALSE_;
/* 						!INDICATE NEW DESC NEEDED. */
    return ret_val;

/* R18--	DOME ROOM.  STATE DEPENDS ON WHETHER ROPE TIED TO RAILING. */

L18000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	goto L18500;
    }
/* 						!LOOK? */
    rspeak_(51);
/* 						!DESCRIBE. */
    if (findex_1.domef) {
	rspeak_(52);
    }
/* 						!IF ROPE, DESCRIBE. */
    return ret_val;

L18500:
    if (prsvec_1.prsa == vindex_1.leapw) {
	jigsup_(53);
    }
/* 						!DID HE JUMP??? */
    return ret_val;

/* R19--	TORCH ROOM.  ALSO DEPENDS ON WHETHER ROPE TIED TO RAILING. */

L19000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    rspeak_(54);
/* 						!DESCRIBE. */
    if (findex_1.domef) {
	rspeak_(55);
    }
/* 						!IF ROPE, DESCRIBE. */
    return ret_val;

/* R20--	CAROUSEL ROOM.  SPIN HIM OR KILL HIM. */

L20000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	goto L20500;
    }
/* 						!LOOK? */
    rspeak_(56);
/* 						!DESCRIBE. */
    if (! findex_1.caroff) {
	rspeak_(57);
    }
/* 						!IF NOT FLIPPED, SPIN. */
    return ret_val;

L20500:
    if (prsvec_1.prsa == vindex_1.walkiw && findex_1.carozf) {
	jigsup_(58);
    }
/* 						!WALKED IN. */
    return ret_val;
/* RAPPL1, PAGE 7 */

/* R21--	LLD ROOM.  HANDLE EXORCISE, DESCRIPTIONS. */

L21000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	goto L21500;
    }
/* 						!LOOK? */
    rspeak_(59);
/* 						!DESCRIBE. */
    if (! findex_1.lldf) {
	rspeak_(60);
    }
/* 						!IF NOT VANISHED, GHOSTS. */
    return ret_val;

L21500:
    if (prsvec_1.prsa != vindex_1.exorcw) {
	return ret_val;
    }
/* 						!EXORCISE? */
    if (objcts_1.oadv[oindex_1.bell - 1] == play_1.winner && objcts_1.oadv[
	    oindex_1.book - 1] == play_1.winner && objcts_1.oadv[
	    oindex_1.candl - 1] == play_1.winner && (objcts_1.oflag1[
	    oindex_1.candl - 1] & ONBT) != 0) {
	goto L21600;
    }
    rspeak_(62);
/* 						!NOT EQUIPPED. */
    return ret_val;

L21600:
    if (qhere_(oindex_1.ghost, play_1.here)) {
	goto L21700;
    }
/* 						!GHOST HERE? */
    jigsup_(61);
/* 						!NOPE, EXORCISE YOU. */
    return ret_val;

L21700:
    newsta_(oindex_1.ghost, 63, 0, 0, 0);
/* 						!VANISH GHOST. */
    findex_1.lldf = TRUE_;
/* 						!OPEN GATE. */
    return ret_val;

/* R22--	LLD2-ROOM.  IS HIS HEAD ON A POLE? */

L22000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    rspeak_(64);
/* 						!DESCRIBE. */
    if (findex_1.onpolf) {
	rspeak_(65);
    }
/* 						!ON POLE? */
    return ret_val;

/* R23--	DAM ROOM.  DESCRIBE RESERVOIR, PANEL. */

L23000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    rspeak_(66);
/* 						!DESCRIBE. */
    i = 67;
    if (findex_1.lwtidf) {
	i = 68;
    }
    rspeak_(i);
/* 						!DESCRIBE RESERVOIR. */
    rspeak_(69);
/* 						!DESCRIBE PANEL. */
    if (findex_1.gatef) {
	rspeak_(70);
    }
/* 						!BUBBLE IS GLOWING. */
    return ret_val;

/* R24--	TREE ROOM */

L24000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    rspeak_(660);
/* 						!DESCRIBE. */
    i = 661;
/* 						!SET FLAG FOR BELOW. */
    i__1 = objcts_1.olnt;
    for (j = 1; j <= i__1; ++j) {
/* 						!DESCRIBE OBJ IN FORE3. */
	if (! qhere_(j, rindex_1.fore3) || j == oindex_1.ftree) {
	    goto L24200;
	}
	rspeak_(i);
/* 						!SET STAGE, */
	i = 0;
	rspsub_(502, objcts_1.odesc2[j - 1]);
/* 						!DESCRIBE. */
L24200:
	;
    }
    return ret_val;
/* RAPPL1, PAGE 8 */

/* R25--	CYCLOPS-ROOM.  DEPENDS ON CYCLOPS STATE, ASLEEP FLAG, MAGIC FLAG.
 */

L25000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    rspeak_(606);
/* 						!DESCRIBE. */
    i = 607;
/* 						!ASSUME BASIC STATE. */
    if (findex_1.rvcyc > 0) {
	i = 608;
    }
/* 						!>0?  HUNGRY. */
    if (findex_1.rvcyc < 0) {
	i = 609;
    }
/* 						!<0?  THIRSTY. */
    if (findex_1.cyclof) {
	i = 610;
    }
/* 						!ASLEEP? */
    if (findex_1.magicf) {
	i = 611;
    }
/* 						!GONE? */
    rspeak_(i);
/* 						!DESCRIBE. */
    if (! findex_1.cyclof && findex_1.rvcyc != 0) {
	i__1 = abs(findex_1.rvcyc) + 193;
	rspeak_(i__1);
    }
    return ret_val;

/* R26--	BANK BOX ROOM. */

L26000:
    if (prsvec_1.prsa != vindex_1.walkiw) {
	return ret_val;
    }
/* 						!SURPRISE HIM. */
    for (i = 1; i <= 8; i += 2) {
/* 						!SCOLRM DEPENDS ON */
	if (screen_1.fromdr == screen_1.scoldr[i - 1]) {
	    screen_1.scolrm = screen_1.scoldr[i];
	}
/* L26100: */
    }
/* 						!ENTRY DIRECTION. */
    return ret_val;

/* R27--	TREASURE ROOM. */

L27000:
    if (prsvec_1.prsa != vindex_1.walkiw || ! hack_1.thfact) {
	return ret_val;
    }
    if (objcts_1.oroom[oindex_1.thief - 1] != play_1.here) {
	newsta_(oindex_1.thief, 82, play_1.here, 0, 0);
    }
    hack_1.thfpos = play_1.here;
/* 						!RESET SEARCH PATTERN. */
    objcts_1.oflag2[oindex_1.thief - 1] |= FITEBT;
    if (objcts_1.oroom[oindex_1.chali - 1] == play_1.here) {
	objcts_1.oflag1[oindex_1.chali - 1] &= ~ TAKEBT;
    }

/* 	VANISH EVERYTHING IN ROOM */

    j = 0;
/* 						!ASSUME NOTHING TO VANISH. */
    i__1 = objcts_1.olnt;
    for (i = 1; i <= i__1; ++i) {
	if (i == oindex_1.chali || i == oindex_1.thief || ! qhere_(i, 
		play_1.here)) {
	    goto L27200;
	}
	j = 83;
/* 						!FLAG BYEBYE. */
	objcts_1.oflag1[i - 1] &= ~ VISIBT;
L27200:
	;
    }
    rspeak_(j);
/* 						!DESCRIBE. */
    return ret_val;

/* R28--	CLIFF FUNCTION.  SEE IF CARRYING INFLATED BOAT. */

L28000:
    findex_1.deflaf = objcts_1.oadv[oindex_1.rboat - 1] != play_1.winner;
/* 						!TRUE IF NOT CARRYING. */
    return ret_val;
/* RAPPL1, PAGE 9 */

/* R29--	RIVR4 ROOM.  PLAY WITH BUOY. */

L29000:
    if (! findex_1.buoyf || objcts_1.oadv[oindex_1.buoy - 1] != play_1.winner)
	     {
	return ret_val;
    }
    rspeak_(84);
/* 						!GIVE HINT, */
    findex_1.buoyf = FALSE_;
/* 						!THEN DISABLE. */
    return ret_val;

/* R30--	OVERFALLS.  DOOM. */

L30000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	jigsup_(85);
    }
/* 						!OVER YOU GO. */
    return ret_val;

/* R31--	BEACH ROOM.  DIG A HOLE. */

L31000:
    if (prsvec_1.prsa != vindex_1.digw || prsvec_1.prso != oindex_1.shove) {
	return ret_val;
    }
    ++findex_1.rvsnd;
/* 						!INCREMENT DIG STATE. */
    switch (findex_1.rvsnd) {
	case 1:  goto L31100;
	case 2:  goto L31100;
	case 3:  goto L31100;
	case 4:  goto L31400;
	case 5:  goto L31500;
    }
/* 						!PROCESS STATE. */
    bug_(2, findex_1.rvsnd);

L31100:
    i__1 = findex_1.rvsnd + 85;
    rspeak_(i__1);
/* 						!1-3... DISCOURAGE HIM. */
    return ret_val;

L31400:
    i = 89;
/* 						!ASSUME DISCOVERY. */
    if ((objcts_1.oflag1[oindex_1.statu - 1] & VISIBT) != 0) {
	i = 88;
    }
    rspeak_(i);
    objcts_1.oflag1[oindex_1.statu - 1] |= VISIBT;
    return ret_val;

L31500:
    findex_1.rvsnd = 0;
/* 						!5... SAND COLLAPSES */
    jigsup_(90);
/* 						!AND SO DOES HE. */
    return ret_val;

/* R32--	TCAVE ROOM.  DIG A HOLE IN GUANO. */

L32000:
    if (prsvec_1.prsa != vindex_1.digw || prsvec_1.prso != oindex_1.shove) {
	return ret_val;
    }
    i = 91;
/* 						!ASSUME NO GUANO. */
    if (! qhere_(oindex_1.guano, play_1.here)) {
	goto L32100;
    }
/* 						!IS IT HERE? */
/* Computing MIN */
    i__1 = 4, i__2 = findex_1.rvgua + 1;
    findex_1.rvgua = min(i__1,i__2);
/* 						!YES, SET NEW STATE. */
    i = findex_1.rvgua + 91;
/* 						!GET NASTY REMARK. */
L32100:
    rspeak_(i);
/* 						!DESCRIBE. */
    return ret_val;

/* R33--	FALLS ROOM */

L33000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    rspeak_(96);
/* 						!DESCRIBE. */
    i = 97;
/* 						!ASSUME NO RAINBOW. */
    if (findex_1.rainbf) {
	i = 98;
    }
/* 						!GOT ONE? */
    rspeak_(i);
/* 						!DESCRIBE. */
    return ret_val;
/* RAPPL1, PAGE 10 */

/* R34--	LEDGE FUNCTION.  LEDGE CAN COLLAPSE. */

L34000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    rspeak_(100);
/* 						!DESCRIBE. */
    i = 102;
/* 						!ASSUME SAFE ROOM OK. */
    if ((rooms_1.rflag[rindex_1.msafe - 1] & RMUNG) != 0) {
	i = 101;
    }
    rspeak_(i);
/* 						!DESCRIBE. */
    return ret_val;

/* R35--	SAFE ROOM.  STATE DEPENDS ON WHETHER SAFE BLOWN. */

L35000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	return ret_val;
    }
/* 						!LOOK? */
    rspeak_(104);
/* 						!DESCRIBE. */
    i = 105;
/* 						!ASSUME OK. */
    if (findex_1.safef) {
	i = 106;
    }
/* 						!BLOWN? */
    rspeak_(i);
/* 						!DESCRIBE. */
    return ret_val;

/* R36--	MAGNET ROOM.  DESCRIBE, CHECK FOR SPINDIZZY DOOM. */

L36000:
    if (prsvec_1.prsa != vindex_1.lookw) {
	goto L36500;
    }
/* 						!LOOK? */
    rspeak_(107);
/* 						!DESCRIBE. */
    return ret_val;

L36500:
    if (prsvec_1.prsa != vindex_1.walkiw || ! findex_1.caroff) {
	return ret_val;
    }
/* 						!WALKIN ON FLIPPED? */
    if (findex_1.carozf) {
	goto L36600;
    }
/* 						!ZOOM? */
    rspeak_(108);
/* 						!NO, SPIN HIS COMPASS. */
    return ret_val;

L36600:
    i = 58;
/* 						!SPIN HIS INSIDES. */
    if (play_1.winner != aindex_1.player) {
	i = 99;
    }
/* 						!SPIN ROBOT. */
    jigsup_(i);
/* 						!DEAD. */
    return ret_val;

/* R37--	CAGE ROOM.  IF SOLVED CAGE, MOVE TO OTHER CAGE ROOM. */

L37000:
    if (findex_1.cagesf) {
	moveto_(rindex_1.cager, play_1.winner);
    }
/* 						!IF SOLVED, MOVE. */
    return ret_val;

} /* rappl1_ */