Exemplo n.º 1
0
cypher()
{
	register int n;
	int junk;
	int lflag = -1;
	char buffer[10];

	while (wordtype[wordnumber] == ADJS)
		wordnumber++;
	while (wordnumber <= wordcount) {
		switch(wordvalue[wordnumber]) {

			case UP:
				if (location[position].access || wiz || tempwiz) {
					if (!location[position].access)
						puts("Zap!  A gust of wind lifts you up.");
					if (!move(location[position].up, AHEAD))
						return(-1);
				} else {
					puts("There is no way up");
					return(-1);
				}
				lflag = 0;
				break;

			 case DOWN:
				if (!move(location[position].down, AHEAD))
					return(-1);
				lflag = 0;
				break;

			 case LEFT:
				if (!move(left, LEFT))
					return(-1);
				lflag = 0;
				break;

			 case RIGHT:
				if (!move(right, RIGHT))
					return(-1);
				lflag = 0;
				break;
			 
			 case AHEAD:
				if (!move(ahead, AHEAD))
					return(-1);
				lflag = 0;
				break;
			 
			 case BACK:
				if (!move(back, BACK))
					return(-1);
				lflag = 0;
				break;
			 
			 case SHOOT:
				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(location[position].objects,n) && *objsht[n]){
							wordvalue[wordnumber+1] = n;
							wordnumber = shoot();
						}
				wordnumber++;
				wordnumber++;
				}
				else 
					shoot();
				break;

			 case TAKE:
				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(location[position].objects,n) && *objsht[n]){
							wordvalue[wordnumber+1] = n;
							wordnumber = take(location[position].objects);
						}
				wordnumber++;
				wordnumber++;
				}
				else 
					take(location[position].objects);
				break;

			 case DROP:

				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(inven,n)){
							wordvalue[wordnumber+1] = n;
							wordnumber = drop("Dropped");
						}
				wordnumber++;
				wordnumber++;
				}
				else 
					drop("Dropped");
				break;


			 case KICK:
			 case THROW:
				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(inven,n) ||
						  testbit(location[position].objects, n) && *objsht[n]){
							wordvalue[wordnumber+1] = n;
							wordnumber = throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
						}
					wordnumber += 2;
				} else 
					throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
				break;

			 case TAKEOFF:
				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(wear,n)){
							wordvalue[wordnumber+1] = n;
							wordnumber = takeoff();
						}
					wordnumber += 2;
				}
				else 
					takeoff();
				break;


			 case DRAW:

				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(wear,n)){
							wordvalue[wordnumber+1] = n;
							wordnumber = draw();
						}
					wordnumber += 2;
				}
				else 
					draw();
				break;


			 case PUTON:

				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(location[position].objects,n) && *objsht[n]){
							wordvalue[wordnumber+1] = n;
							wordnumber = puton();
						}
					wordnumber += 2;
				}
				else 
					puton();
				break;

			 case WEARIT:

				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(inven,n)){
							wordvalue[wordnumber+1] = n;
							wordnumber = wearit();
						}
					wordnumber += 2;
				}
				else 
					wearit();
				break;


			 case EAT:

				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(inven,n)){
							wordvalue[wordnumber+1] = n;
							wordnumber = eat();
						}
					wordnumber += 2;
				}
				else 
					eat();
				break;


			case PUT:
				put();
				break;


			case INVEN:
				if (ucard(inven)){
					puts("You are holding:\n");
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(inven,n))
							printf("\t%s\n", objsht[n]);
					printf("\n= %d kilogram%s (%d%%)\n", carrying, (carrying == 1 ? "." : "s."),(WEIGHT ? carrying*100/WEIGHT : -1));
					printf("Your arms are %d%% full.\n",encumber*100/CUMBER);
				}
				else
					puts("You aren't carrying anything.");
					
				if (ucard(wear)){
					puts("\nYou are wearing:\n");
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(wear,n))
							printf("\t%s\n", objsht[n]);
				}
				else
					puts("\nYou are stark naked.");
				if (card(injuries,NUMOFINJURIES)){
					puts("\nYou have suffered:\n");
					for (n=0; n < NUMOFINJURIES; n++)
						if (injuries[n])
							printf("\t%s\n",ouch[n]);
					printf("\nYou can still carry up to %d kilogram%s\n",WEIGHT,(WEIGHT == 1 ? "." : "s."));
				}
				else
					puts("\nYou are in perfect health.");
				break;

			case USE:
				lflag = use();
				break;

			case LOOK:
				if (!notes[CANTSEE] || testbit(inven,LAMPON) || testbit(location[position].objects,LAMPON) || matchlight){
					beenthere[position] = 2;
					writedes();
					printobjs();
					if (matchlight){
						puts("\nYour match splutters out.");
						matchlight = 0;
					}
				} else 
					puts("I can't see anything.");
				return(-1);
				break;

			 case SU:
			 if (wiz || tempwiz){
				printf("\nRoom (was %d) = ", position);
				fgets(buffer,10,stdin);
				if (*buffer != '\n')
					sscanf(buffer,"%d", &position);
				printf("Time (was %d) = ",time);
				fgets(buffer,10,stdin);
				if (*buffer != '\n')
					sscanf(buffer,"%d", &time);
				printf("Fuel (was %d) = ",fuel);
				fgets(buffer,10,stdin);
				if (*buffer != '\n')
					sscanf(buffer,"%d", &fuel);
				printf("Torps (was %d) = ",torps);
				fgets(buffer,10,stdin);
				if (*buffer != '\n')
					sscanf(buffer,"%d", &torps);
				printf("CUMBER (was %d) = ",CUMBER);
				fgets(buffer,10,stdin);
				if (*buffer != '\n')
					sscanf(buffer,"%d", &CUMBER);
				printf("WEIGHT (was %d) = ",WEIGHT);
				fgets(buffer,10,stdin);
				if (*buffer != '\n')
					sscanf(buffer,"%d",&WEIGHT);
				printf("Clock (was %d) = ",clock);
				fgets(buffer,10,stdin);
				if (*buffer != '\n')
					sscanf(buffer,"%d",&clock);
				printf("Wizard (was %d, %d) = ",wiz, tempwiz);
				fgets(buffer,10,stdin);
				if (*buffer != '\n'){
					sscanf(buffer,"%d",&junk);
					if (!junk)
						tempwiz = wiz = 0;
				}
				printf("\nDONE.\n");
				return(0);
			 }
			 else
				 puts("You aren't a wizard.");
			 break;
				
			 case SCORE:
				printf("\tPLEASURE\tPOWER\t\tEGO\n");
				printf("\t%3d\t\t%3d\t\t%3d\n\n",pleasure,power,ego);
				printf("This gives you the rating of %s in %d turns.\n",rate(),time);
				printf("You have visited %d out of %d rooms this run (%d%%).\n",card(beenthere,NUMOFROOMS),NUMOFROOMS,card(beenthere,NUMOFROOMS)*100/NUMOFROOMS);
				break;

			 case KNIFE:
			 case KILL:
				murder();
				break;

			 case UNDRESS:
			 case RAVAGE:
				ravage();
				break;

			 case SAVE:
				save();
				break;

			 case FOLLOW:
				lflag = follow();
				break;

			 case GIVE:
				give();
				break;

			 case KISS:
				kiss();
				break;

			 case LOVE:
				 love();
				 break;

			 case RIDE:
				lflag = ride();
				break;

			 case DRIVE:
				lflag = drive();
				break;

			 case LIGHT:
				 light();
				 break;

			 case LAUNCH:
				if (!launch())
					return(-1);
				else 
					lflag = 0;
				break;

			case LANDIT:
				if (!land())
					return(-1);
				else
					lflag = 0;
				break;

			case TIME:
				chime();
				break;

			 case SLEEP:
				zzz();
				break;

			 case DIG:
				dig();
				break;

			 case JUMP:
				lflag = jump();
				break;

			 case BURY:
				bury();
				break;

			 case SWIM:
				puts("Surf's up!");
				break;

			 case DRINK:
				drink();
				break;

			 case QUIT:
				die();

			 default:
				puts("How's that?");
				return(-1);
				break;

			 
		}
		if (wordnumber < wordcount && *words[wordnumber++] == ',')
			continue;
		else return(lflag);
       }
       return(lflag);
}
Exemplo n.º 2
0
void KeyboardCharacterMover::move(sf::RenderWindow &window, Character &character, Collisions &collisions, TilesMap &tilesMap, Camera &camera, Background &background, sf::Time elapsedTime)
{
// Check if we`re flying
    m_testRect = character.m_characterRect;
    m_testRect.top++;
    m_result = collisions.collidedY(m_testRect, character.m_digPower, tilesMap, m_blockPos);
    if(m_result == Collisions::NoCollision)
        m_flying = true;
    else
        m_flying = false;

// If a direction is true, add or delete 13 to the velocity (x or y) to be able to move in that direction
    if(m_north)
        character.m_velocityY -= 13.0f;

    if(m_south)
        character.m_velocityY += 3.0f; // Only add 3 if m_south is true (because we'll add the gravity

    if(m_east)
        character.m_velocityX += 13.0f;

    if(m_west)
        character.m_velocityX -= 13.0f;

// Add gravity (only if we're flying)
    if(m_flying)
        m_physic.addGravity(character.m_velocityY);

// If east or west are false et their velocity is not equal to 0
    if(!m_east && character.m_velocityX > 0)
    {
        character.m_velocityX = character.m_velocityX*97/100; // Reduce the velocity
            if(character.m_velocityX <= 15) // If the velocity is less than 15 set the velocity to 0
                character.m_velocityX = 0;
    }

    if(!m_west && character.m_velocityX < 0)
    {
        character.m_velocityX = character.m_velocityX*97/100; // Reduce the velocity
            if(character.m_velocityX >= -15) // If the velocity is more than -15, set the velocity to 0
                character.m_velocityX = 0;
    }

// Check if the velocity are higher than the max
    if(character.m_velocityX > character.m_maxVelocity)
        character.m_velocityX = character.m_maxVelocity;

    if(character.m_velocityX < -character.m_maxVelocity)
        character.m_velocityX = -character.m_maxVelocity;

    if(character.m_velocityY < -character.m_maxVelocity)
        character.m_velocityY = -character.m_maxVelocity;

    if(character.m_velocityY > 2000)
        character.m_velocityY = 2000;

// Check for collisions, if everything is ok: move the character. Else, check if we can dig
    m_testRect = character.m_characterRect;

    // Collisions in x axis
        m_testRect.left += elapsedTime.asSeconds()* character.m_velocityX; // Add x movement
        m_result = collisions.collidedX(m_testRect, character.m_digPower, tilesMap, m_blockPos); // Test

        // If there're no collision
            if(m_result == Collisions::NoCollision)
            {
                character.m_characterRect.left = m_testRect.left; // Move the character position
                camera.moveX(character.m_characterRect, tilesMap.getWorldSize()); // Move the camera position
            }
        // If we can dig
            else if(m_result == Collisions::Diggable)
            {
                // Only dig if we are not flying and if the the key is pressed
                    if(m_blockPos.x < character.m_characterRect.left && m_west && !m_flying)
                    {
                        dig(window, character, tilesMap, camera, background, m_blockPos, KeyboardCharacterMover::WEST);
                        return;
                    }
                    if(m_blockPos.x > character.m_characterRect.left && m_east && !m_flying)
                    {
                        dig(window, character, tilesMap, camera, background, m_blockPos, KeyboardCharacterMover::EAST);
                        return;
                    }
            }
            else
            {
                character.m_velocityX = 0;
            }

    // Collisions in y axis
        m_testRect.left = character.m_characterRect.left; // Because we don't care about the movement in x axis
        m_testRect.top += elapsedTime.asSeconds()* character.m_velocityY; // Add y movement
        m_result = collisions.collidedY(m_testRect, character.m_digPower, tilesMap, m_blockPos); // Test

        // If there's no collision
            if(m_result == Collisions::NoCollision)
            {
                character.m_characterRect.top = m_testRect.top; // Move the character position
                camera.moveY(character.m_characterRect, tilesMap.getWorldSize()); // Move the camera position
            }

        // If we can dig
            else if(m_result == Collisions::Diggable)
            {
                // Only dig if the the key is pressed, the block is under the character and the velocity in Y isn't too high
                    if(m_blockPos.y > character.m_characterRect.top && m_south && character.m_velocityY <= 500)
                    {
                        m_flying = false;
                        dig(window, character, tilesMap, camera, background, m_blockPos, KeyboardCharacterMover::SOUTH);
                    }

                    else if(m_blockPos.y > character.m_characterRect.top)
                    {
                        impact(character);
                    }
                    else
                    {
                        character.m_velocityY = 0;
                    }
            }

        // If we collided but we can't dig
            else if(m_result == Collisions::BlockCollision && m_blockPos.y > character.m_characterRect.top)
            {
                impact(character);
            }

        // If we collided with the top or the end of the world (in which case we need to lose life)
            else if(m_result == Collisions::Collision)
            {
                if(!impact(character))
                    character.m_velocityY = 0;
            }

            else
            {
                // Set the velocity to 0 if we hit
                    character.m_velocityY = 0;
            }

// Set the image of the character
    if(character.m_velocityX > 0)
    {
        if(m_flying)
            character.setCharacterTexture("flyRight.png");
        else
            character.setCharacterTexture("vehiculeRight.png");

        if(!ServiceLocator::GetAudio()->isSoundPlaying("normal.ogg") && !m_flying)
        {
            ServiceLocator::GetAudio()->stopSounds();
            ServiceLocator::GetAudio()->playSound("normal.ogg", 60, true);
        }
        else if(!ServiceLocator::GetAudio()->isSoundPlaying("fly.ogg") && m_flying)
        {
            ServiceLocator::GetAudio()->stopSounds();
            ServiceLocator::GetAudio()->playSound("fly.ogg", 60, true);
        }
    }

    else if(character.m_velocityX < 0)
    {
        if(m_flying)
            character.setCharacterTexture("flyLeft.png");
        else
            character.setCharacterTexture("vehiculeLeft.png");

        if(!ServiceLocator::GetAudio()->isSoundPlaying("normal.ogg") && !m_flying)
        {
            ServiceLocator::GetAudio()->stopSounds();
            ServiceLocator::GetAudio()->playSound("normal.ogg", 60, true);
        }
        else if(!ServiceLocator::GetAudio()->isSoundPlaying("fly.ogg") && m_flying)
        {
            ServiceLocator::GetAudio()->stopSounds();
            ServiceLocator::GetAudio()->playSound("fly.ogg", 60, true);
        }
    }

    else if(character.m_velocityX == 0 && m_flying)
    {
        if(character.m_characterTextureName == "vehiculeLeft.png")
            character.setCharacterTexture("flyLeft.png");
        else if(character.m_characterTextureName == "vehiculeRight.png")
            character.setCharacterTexture("flyRight.png");

        if(!ServiceLocator::GetAudio()->isSoundPlaying("fly.ogg"))
        {
            ServiceLocator::GetAudio()->stopSounds();
            ServiceLocator::GetAudio()->playSound("fly.ogg", 60, true);
        }
    }

    else if(character.m_velocityX == 0 && !m_flying)
    {
        if(character.m_characterTextureName == "flyLeft.png")
            character.setCharacterTexture("vehiculeLeft.png");
        else if(character.m_characterTextureName == "flyRight.png")
            character.setCharacterTexture("vehiculeRight.png");

        if(!ServiceLocator::GetAudio()->isSoundPlaying("normal.ogg"))
        {
            ServiceLocator::GetAudio()->stopSounds();
            ServiceLocator::GetAudio()->playSound("normal.ogg", 60, true);
        }
    }
}
Exemplo n.º 3
0
void foo() {
   panama obj;
   obj = dig(); // { dg-error "" }  // ERROR -
}
Exemplo n.º 4
0
void
winloop()
{
	int x, y, c, marked, t0, inited;
	char buf[100];
	x = 10;
	y = 8;
	inited = 0;
	marked = 0;
	clearbuf();
	t0 = time(0);
	while (1) {
		c = egetch();
		if (c == 257 && y > 1)
			y--;
		if (c == 258 && y < 16)
			y++;
		if (c == 260 && x > 1)
			x--;
		if (c == 259 && x < 30)
			x++;
		move(0, 20);
		sprintf(buf, "ʱ¼ä: %d ", (int) (time(0) - t0));
		prints(buf);
		move(40, 20);
		sprintf(buf, "񈬀: %d ", marked);
		prints(buf);
		move(0, 22);
		sprintf(buf, "×ø±ê: %3d, %3d", x, y);
		prints(buf);
		move(x * 2 - 2, y - 1);
		if (c == 'h' || c == 'H')
			winhelp();
		if (c == 'd' || c == 'D')
			winrefresh();
		if (c == 'a' || c == 'A') {
			if (!inited) {
				wininit(x, y);
				inited = 1;
			}
			dig(x, y);
		}
		if ((c == 83 || c == 115) && !o[x][y]) {
			if (m[x][y]) {
				m[x][y] = 0;
				marked--;
			} else {
				m[x][y] = 1;
				marked++;
			}
			winsh(x, y);
		}
		if (checkwin() == 1) {
			move(0, 22);
			prints("×£ºØÄ㣡Äã³É¹¦ÁË£¡                    ");
			{
				char buf[100];
				sprintf(buf, "finished in %d s.",
					(int) (time(0) - t0));
				win_checkrec(time(0) - t0);
				winminelog(buf);
			}
			gameover = 0;
			return;
		}
		if (gameover) {
			move(0, 22);
			prints("ºÜÒź¶£¬Äãʧ°ÜÁË... ÔÙÀ´Ò»´Î°É£¡    ");
			{
				char buf[100];
				sprintf(buf, "failed in %d s.",
					(int) (time(0) - t0));
				winminelog(buf);
			}
			gameover = 0;
			return;
		}
		move(x * 2 - 2, y - 1);
		refresh();
	}
}
 void dig(TreeNode *root,int deep) {
     deepMax = max(deep, deepMax);
     if (root->left != nullptr) dig(root->left,deep+1); 
     if (root->right != nullptr) dig(root->right,deep+1);
 }
Exemplo n.º 6
0
// Takes user input to redraw map with moved character
void input()
{
	levelBridge();
    bool loop = true;
    int c;
    
    while(loop)
    {
        
        // Take keyboard input and assigns its value to c
        c = getch();
        
    
        
        // Switch containing all the possible actions pertaining to each key
        // Now with dig functionality. Should put digon within a structure for different...
        // ... actions so that we can have more than one and don't need to add if ...
        // ... statements up the yin yang. 
        
        
        switch (c) {
            case KEY_UP:
                if(digon == 'n')
                {
                	movmt(0, -movement);
                }
                if(digon == 'y')
                {
                	dig(0, -movement);
                }
                break;
                
            case KEY_DOWN:
            	if(digon == 'n')
            	{
                	movmt(0, movement);
                }
                if(digon == 'y')
                {
                	dig(0, movement);
                	}
                break;
                
            case KEY_LEFT: 
         		if(digon == 'n')
            	{
                	movmt(-movement, 0);
                }
                if(digon == 'y')
                {
                	dig(-movement, 0);
                	}
                break;
                
            case KEY_RIGHT:
                if(digon == 'n')
            	{
                	movmt(movement, 0);
                }
                if(digon == 'y')
                {
                	dig(movement, 0);
                	}
                break;
                
            case 'd':
            	switch(digon){
            	case 'y':
            		digon = 'n';
            		break;
            	case 'n':
            		digon = 'y';
            		break;
            		}
                break;
            case 'Q':
                loop = false;
                
            default:
                break;
                
        }
       
        
        
    
    }
    draw();
}
Exemplo n.º 7
0
int winloop()
{
    int x, y, c, marked, t0, inited;
    char buf[100];
    x= 10;
    y= 8;
    inited= 0; 
    marked= 0; 
    clearbuf();
    t0= time(0);
    while(1) {
        c= egetch();
        if((c==257||c=='k')&&y>1) y--;
        if((c==258||c=='j')&&y<16) y++;
        if((c==260||c=='h')&&x>1) x--;
        if((c==259||c=='l')&&x<30) x++;
        move(0, 20);
        //% sprintf(buf, "时间: %ld ", time(0)-t0);
        sprintf(buf, "\xca\xb1\xbc\xe4: %ld ", time(0)-t0);
        prints(buf);
        move(40, 20);
        //% sprintf(buf, "标记: %d ", marked);
        sprintf(buf, "\xb1\xea\xbc\xc7: %d ", marked);
        prints(buf);
        move(0, 21);
        //% sprintf(buf, "坐标: %3d, %3d", x, y);
        sprintf(buf, "\xd7\xf8\xb1\xea: %3d, %3d", x, y);
        prints(buf);
        move(x*2-2, y-1);
        if(c=='H') winhelp();
        if(c=='d'|| c=='D') winrefresh();
        if(c=='f'|| c=='F'){
             if(!inited) {
                  wininit(x, y);
                  inited= 1;
             } 
             dig(x, y);      
        } 
        if((c==83|| c==115)&&!o[x][y]) {
             if(m[x][y]){
                  m[x][y]=0;
                  marked--;
             } else {
                  m[x][y]=1;
                  marked++;
             }
             winsh(x, y);
        }
        if(checkwin()==1) {
            move(0, 22);
            //% prints("祝贺你!你成功了!                    ");
            prints("\xd7\xa3\xba\xd8\xc4\xe3\xa3\xa1\xc4\xe3\xb3\xc9\xb9\xa6\xc1\xcb\xa3\xa1                    ");
            {  char buf[100];
               sprintf(buf, "finished in %ld s.", time(0)-t0);
               syslog(buf);
            }
            gameover= 0;
 	    win_checkrec(time(0)-t0);/* added by soff 进行排行检查 */
            return;
        }
        if(gameover) {
            move(0, 22);
            //% prints("很遗憾,你失败了... 再来一次吧!                                 ");
            prints("\xba\xdc\xd2\xc5\xba\xb6\xa3\xac\xc4\xe3\xca\xa7\xb0\xdc\xc1\xcb... \xd4\xd9\xc0\xb4\xd2\xbb\xb4\xce\xb0\xc9\xa3\xa1                                 ");
            {  char buf[100];
               sprintf(buf, "failed in %ld s.", time(0)-t0);
               syslog(buf);
            }
            gameover= 0;
            return;
        }
        move(x*2-2, y-1);
        refresh();
    }
}
Exemplo n.º 8
0
void foo() {
   panama obj;
   obj = dig(); // { dg-error "rvalue" }
}
Exemplo n.º 9
0
Arquivo: a.cpp Projeto: hphp/Algorithm
std::vector<int> deal(char s[])
{
    std::vector<int> r;
    int sz = strlen(s);
    int flag = 2 , sign = 1;//0 digit,-1 flag, 1
    int sum = 0;
    for(int i=0; i<sz; i++)
    {
        if(flag == 1 || flag == -1)
        {
            sign = flag;
            sum = 0;
            if(dig(s[i]))
            {
                sum *= 10;
                sum += (sign*(s[i]-'0'));
//				printf("%d\n",sum);
                flag = 0;
            }
            else
            {
                if(flag == 1)
                {
                    r.push_back('+');
                }
                else r.push_back('-');
                if(s[i] == '+')
                    flag = 1;
                else if(s[i] == '-')
                    flag = -1;
                else
                {
                    flag = 2;
                    r.push_back(tran(s[i]));
                }
            }
        }
        else if(flag == 0)
        {
            if(dig(s[i]))
            {
                sum *= 10;
                sum += (sign*(s[i]-'0'));
                flag = 0;
            }
            else if(ltr(s[i]))
            {
                sum -= MAX;
                r.push_back(sum);
                sum = 0;
                sign = 1;
                flag = 2;
                r.push_back(tran(s[i]));
            }
            else if(s[i] == '+')
            {
                flag = 2;
                sum -= MAX;
                r.push_back(sum);
                sum = 0;
                sign = 1;
                r.push_back('+');
            }
            else if(s[i] == '-')
            {
                flag = 2;
                r.push_back(sum);
                sum =0;
                sign = 1;
                //printf("%d\n",'-');
                r.push_back('-');
            }
        }
        else if(flag == 2)
        {
            sum = 0;
            if(dig(s[i]))
            {
                sign = 1;
                sum *= 10;
                sum += (sign*(s[i]-'0'));
//				printf("%dhi",sum);
                flag = 0;
            }
            else if(ltr(s[i]))
            {
                r.push_back(tran(s[i]));
                flag = 2;
            }
            else
            {
                if(s[i] == '+')
                {
                    flag = 1;
                }
                else if(s[i] == '-')
                {
                    flag = -1;
                }
                sum = 0;
            }
            sign
                = 1;
        }
    }
//	printf("%d %d\n",flag,sum);
    if(flag == 0)
    {
        /*	printf("hello");
        	for(int k=0;k<r.size();k++)
        		printf("hello kk %d\n",r[k]);
        	printf("\n");*/
        sum -= MAX;
        r.push_back(sum);
    }
    else if(flag == 1 || flag == -1)
    {
        if(flag == 1)
            r.push_back('+');
        else r.push_back('-');
    }
    return r;
}
Exemplo n.º 10
0
bool GameMap::initWithLevel( int mainLevel, int viceLevel )
{
	Return_False_If(!Node::init());

	this->makeMap(mainLevel, viceLevel);

	const int order = m_objects.size()*m_objects[0].size();
	const Size size = this->getContentSize();
	float x = 0;
	float up_height = 0;
	while (x<size.width)
	{
		Sprite* sp = Sprite::create("bound_up.png");
		sp->setPosition(x, size.height);
		sp->setAnchorPoint(Point(0,0));
		addChild(sp, order);

		x += sp->getContentSize().width;

		up_height = sp->getContentSize().height;
	}
	x = 0;
	float bottom_height = 0;
	while (x<size.width)
	{
		Sprite* sp = Sprite::create("bound_bottom.png");
		sp->setPosition(x, 0);
		sp->setAnchorPoint(Point(0,1));
		addChild(sp, order+1);

		x += sp->getContentSize().width;

		bottom_height = sp->getContentSize().height;
	}

	float y = -bottom_height;
	float left_width = 0;
	while (y<size.height)
	{
		Sprite* sp = Sprite::create("bound_left.png");
		sp->setPosition(0, y);
		sp->setAnchorPoint(Point(1,0));
		addChild(sp, order);

		left_width = sp->getContentSize().width;

		sp = Sprite::create("bound_left.png");
		sp->setAnchorPoint(Point(0,0));
		sp->setRotation(180);
		sp->setPosition(size.width+left_width, y+sp->getContentSize().height);
		addChild(sp, order);

		y += sp->getContentSize().height;
	}

	//init display number
	for (int r=0; r<m_objects.size(); ++r)
	{
		for (int c=0; c<m_objects[r].size(); ++c)
		{
			int mine_count = 0;
			for (auto&x : getSurrounding(Index2(r,c)))
			{
				if (m_objects[x.first][x.second]->isMine())
				{
					++mine_count;
				}
			}
			m_objects[ r ][ c ]->setSurroundMineCount(mine_count);
		}
	}

	CCAssert(NULL!=m_pPlayer, "");
	dig(pointToIndex2(m_pPlayer->getPosition()));

// 	Size size = this->getContentSize(); 
// 	-m_border.width, -m_border.height, size.width+m_border.width*2, size.height+m_border.height*2
	const float tool = toolbar->getContentSize().height*4/5;
	this->runAction( Follow::create(m_pPlayer, Rect(-left_width, -bottom_height-tool, size.width+left_width*2, size.height+up_height+bottom_height+tool)));
	return true;
}
Exemplo n.º 11
0
// Mesh are not committed yet
int offline_regrid(Mesh &srcmesh, Mesh &dstmesh, Mesh &dstmeshcpy,
             int *regridConserve, int *regridMethod, 
             int *regridPoleType, int *regridPoleNPnts,
             char *srcGridFile, char *dstGridFile, char *wghtFile) {

  // Conflict management
  int regridScheme = ESMC_REGRID_SCHEME_FULL3D;
  int unmappedaction = ESMC_UNMAPPEDACTION_ERROR;

  IWeights wts;
  MEField<> *src_iwts, *dst_iwts, *dst_iwtscpy;

    switch (*regridConserve) {

    // Conservative regridding
    case (ESMC_REGRID_CONSERVE_ON): {

      // Add fields to mesh
      Context ctxt; ctxt.flip();
      src_iwts = srcmesh.RegisterField("iwts",
        MEFamilyStd::instance(), MeshObj::ELEMENT, ctxt, 1, true);

      dst_iwts = dstmesh.RegisterField("iwts",
        MEFamilyStd::instance(), MeshObj::ELEMENT, ctxt, 1, true);

      // generate integration weights on the copy
      // TODO: remove this (and the dstcpy mesh passed in) when the 
      //       write bug with pole assimilation is fixed.
      dst_iwtscpy = dstmeshcpy.RegisterField("iwts",
        MEFamilyStd::instance(), MeshObj::ELEMENT, ctxt, 1, true);
      dstmeshcpy.Commit();
      Integrate dig(dstmeshcpy);
      dig.clearWeights(dst_iwtscpy);
      if (regridScheme == ESMC_REGRID_SCHEME_FULL3D) {
        for (UInt i = 1; i <= 7; ++i)
          dig.AddPoleWeights(dstmeshcpy,i,dst_iwtscpy);
      }
      dig.intWeights(dst_iwtscpy);

      // Commit the meshes
      srcmesh.Commit();
      dstmesh.Commit();

      if (!csrv(srcmesh, dstmesh, wts, src_iwts, dst_iwts, regridMethod, &regridScheme,
                regridPoleType, regridPoleNPnts, &unmappedaction))
        Throw() << "Conservative regridding error" << std::endl;
    } break;

    // NON Conservative regridding
    case (ESMC_REGRID_CONSERVE_OFF): {

      // Commit the meshes
      srcmesh.Commit();
      dstmesh.Commit();
      dstmeshcpy.Commit();

      if (!regrid(srcmesh, dstmesh, wts, regridMethod, &regridScheme,
                  regridPoleType, regridPoleNPnts, &unmappedaction))
        Throw() << "Regridding error" << std::endl;

      // the mask
      MEField<> *mask = dstmesh.GetField("MASK_IO");
      ThrowRequire(mask);
      wts.Prune(dstmesh, mask);

    } break;

    default:
      Throw() << "Regridding method:" << *regridConserve << " is not implemented";
    }

    // Redistribute weights in an IO friendly decomposition
    if (Par::Rank() == 0) std::cout << "Writing weights to " << wghtFile << std::endl;
    GatherForWrite(wts);

    // Write the weights
    WriteNCMatFilePar(srcGridFile, dstGridFile, wghtFile,
                      wts, srcmesh, dstmesh, dstmeshcpy,
                      regridConserve, regridMethod, NCMATPAR_ORDER_SEQ);

  return 1;

}
Exemplo n.º 12
0
  // csrv - Args are NON-COMMITTED meshes
  int csrv(Mesh &srcmesh, Mesh &dstmesh, IWeights &wts,
           MEField<> *src_iwts, MEField<> *dst_iwts,
           int *regridMethod, int *regridScheme, 
           int *regridPoleType, int *regridPoleNPnts, 
           int *unmappedaction) {


    // generate integration weights before pole, so 
    // they are distributed across non-pole nodes
    // (the node is factored out in the end)
    Integrate sig(srcmesh), dig(dstmesh);

    // Clear weights
    sig.clearWeights(src_iwts);
    dig.clearWeights(dst_iwts);

    // Add weights to meshes before poles
    // so all the weights are on user data points
    if (*regridScheme == ESMC_REGRID_SCHEME_FULL3D) {
        for (UInt i = 1; i <= 7; ++i) {
       	  sig.AddPoleWeights(srcmesh,i,src_iwts);
       	  dig.AddPoleWeights(dstmesh,i,dst_iwts);
        }
    }

    // Add in other none-pole weights
    // (and do cross processor sum)
    sig.intWeights(src_iwts);
    dig.intWeights(dst_iwts);



#if 0
  // print out info of the iwts
  Mesh::iterator sni=srcmesh.node_begin(), sne=srcmesh.node_end();
  Mesh::iterator dni=dstmesh.node_begin(), dne=dstmesh.node_end();

  double ssum=0.0;
  for (; sni != sne; ++sni) {
    double *Sdata = src_iwts->data(*sni);
    ssum += *Sdata;
  }
  
  double dsum=0.0;
 for (; dni != dne; ++dni) {
    double *Ddata = dst_iwts->data(*dni);

    dsum += *Ddata;
  }

    printf("SW Sum=%20.17f \n",ssum);
    printf("DW Sum=%20.17f \n",dsum);
#endif


    // Pole constraints
    IWeights pole_constraints, stw;
    UInt constraint_id = dstmesh.DefineContext("pole_constraints");

    if (*regridScheme == ESMC_REGRID_SCHEME_FULL3D) {
      if (*regridPoleType == ESMC_REGRID_POLETYPE_ALL) {
        for (UInt i = 1; i <= 7; ++i)
          MeshAddPole(dstmesh, i, constraint_id, pole_constraints);
      } else if (*regridPoleType == ESMC_REGRID_POLETYPE_NPNT) {
        for (UInt i = 1; i <= 7; ++i)
          MeshAddPoleNPnts(dstmesh, *regridPoleNPnts, i, constraint_id, pole_constraints);
      } else if (*regridPoleType == ESMC_REGRID_POLETYPE_TEETH) {
        for (UInt i = 1; i <= 7; ++i)
          MeshAddPoleTeeth(dstmesh, i, constraint_id, pole_constraints);
      }
    }


    // Get coordinate fields
    MEField<> &scoord = *srcmesh.GetCoordField();
    MEField<> &dcoord = *dstmesh.GetCoordField();

    // Create a layer of ghost elements since the patch method needs
    // a larger stencil.
    if (*regridMethod == ESMC_REGRID_METHOD_PATCH) {
      int num_snd=0;
      MEField<> *snd[3],*rcv[3];

      // Load coord field
      MEField<> *pdc = &dcoord;
      snd[num_snd]=pdc;
      rcv[num_snd]=pdc;
      num_snd++;

      // Load mask field
      MEField<> *pdm = dstmesh.GetField("mask");
      if (pdm != NULL) {
        snd[num_snd]=pdm;
        rcv[num_snd]=pdm;
        num_snd++;
      }

      // Load iwts field
      MEField<> *pdw = dstmesh.GetField("iwts");
      if (pdw != NULL) {
        snd[num_snd]=pdw;
        rcv[num_snd]=pdw;
        num_snd++;
      }

      dstmesh.CreateGhost();
      dstmesh.GhostComm().SendFields(num_snd, snd, rcv);
    }

    // make the field pairs for interpolation
    std::vector<Interp::FieldPair> fpairs;
    if (*regridMethod == ESMC_REGRID_METHOD_BILINEAR)
      fpairs.push_back(Interp::FieldPair(&dcoord, &scoord, Interp::INTERP_STD));
    else if (*regridMethod == ESMC_REGRID_METHOD_PATCH)
      fpairs.push_back(Interp::FieldPair(&dcoord, &scoord, Interp::INTERP_PATCH));

    // Build the rendezvous grids
    Interp interp(dstmesh, srcmesh, fpairs, *unmappedaction);

    // Generate the backwards interpolation matrix
    interp(0, stw);


     // Factor out poles if they exist
     if (*regridScheme == ESMC_REGRID_SCHEME_FULL3D) {
       if (*regridPoleType == ESMC_REGRID_POLETYPE_ALL) {
         stw.GatherToCol(pole_constraints);
         stw.AssimilateConstraints(pole_constraints);
       } else if (*regridPoleType == ESMC_REGRID_POLETYPE_NPNT) {
         stw.GatherToRowSrc(pole_constraints);
         stw.AssimilateConstraintsNPnts(pole_constraints);
       }
    }


    // L2 projection conservative interpolation
    interp.interpL2csrvM(stw, &wts, src_iwts, dst_iwts);


/*
  // print out info of the iwts
  Mesh::iterator sni=srcmesh.node_begin(), sne=srcmesh.node_end();
  Mesh::iterator dni=dstmesh.node_begin(), dne=dstmesh.node_end();

  int snegcount = 0;
  int stotalcount = 0;
  for (; sni != sne; ++sni) {
    double *Sdata = src_iwts->data(*sni);
    stotalcount++;
    if (*Sdata < 0) ++snegcount;
  }

  int dnegcount = 0;
  int dtotalcount = 0;
  for (; dni != dne; ++dni) {
    double *Ddata = dst_iwts->data(*dni);
    dtotalcount++;
    if (*Ddata < 0) ++dnegcount;
  }

  // print out info of weight matrix
  int negcount = 0;
  int rowsum = 0;
  int rowsumcount = 0;
  int totalcount = 0;
  int gt1count = 0;
  double max = 0;
  double min = 0;
double badcolid = 0;
double badrowid = 0;

  IWeights::WeightMap::iterator wit = wts.begin_row(), wet = wts.end_row();
  //IWeights::WeightMap::iterator wit = stw.begin_row(), wet = stw.end_row();
  for (; wit != wet; ++wit) {
    const IWeights::Entry &_row = wit->first;
    const std::vector<IWeights::Entry> &_col = wit->second;

    std::cout<<Par::Rank()<<"  "<<_row.id<<"    ";
    rowsum = 0;
    for (UInt c = 0; c < _col.size(); ++c) {
      double value = _col[c].value;
      if (value < 0) negcount++;
      if (value > max) {
        max = value;
        badcolid = _col[c].id;
        badrowid = _row.id;
      }
      if (value < min) min = value;
      if (value > 1) gt1count++;
      rowsum += value;

      std::cout<<std::setprecision(3)<<_col[c].value<<"  ";
    }
    if (rowsum > 1.01 || rowsum < .99) rowsumcount++;
    totalcount++;
    std::cout<<std::endl;
    for (UInt c = 0; c < _col.size(); ++c) {
      double value = _col[c].value;
      
    }
  }
  std::cout<<std::endl<<"Negative weights count = "<<negcount
           <<std::endl<<"Greater than 1 count = "<<gt1count
           <<std::endl<<"Row sum not 1 count = "<<rowsumcount
           <<std::endl<<"Total row count = "<<totalcount<<std::endl
           <<std::endl<<"Max weight  = "<<max
           <<std::endl<<"Min weight = "<<min<<std::endl;

  std::cout<<std::setprecision(4)<<std::endl<<"Bad weight ["<<badrowid<<","<<badcolid<<"]"<<std::endl<<std::endl;

  std::cout<<std::endl<<"Source iwts total count = "<<stotalcount
                      <<"  and negcount = "<<snegcount<<std::endl;
  std::cout<<std::endl<<"Destination iwts total count = "<<dtotalcount
                      <<"  and negcount = "<<dnegcount<<std::endl<<std::endl;
*/

    return 1;
  }
Exemplo n.º 13
0
void hmpid_raw()
{
    printf("*** RAW HMPID ***");
    
  const Char_t *name[] = { "HMPID0", "HMPID1", "HMPID2", "HMPID3",
			   "HMPID4", "HMPID5", "HMPID6" };

  AliRawReader *rawReader = AliEveEventManager::AssertRawReader();
  AliHMPIDRawStream stream(rawReader);    

  TEveElementList* list = new TEveElementList("HMPID Raw");
  gEve->AddElement(list);

  gStyle->SetPalette(1, 0);

  TEveRGBAPalette *pal = new TEveRGBAPalette(0, 3000);
  pal->SetMax(1000);
  TEveFrameBox    *box = new TEveFrameBox();
  box->SetAAQuadXY(0, 0, 0, 144, 121);
  box->SetFrameColor(kGray);

  TEveQuadSet* ms[7];
  for (Int_t iCh = 0; iCh < 7; ++iCh)
  {
    ms[iCh] = new TEveQuadSet(Form("Chamber %d", iCh));

    TEveQuadSet* q = ms[iCh];
    q->SetOwnIds(kTRUE);
    q->SetPalette(pal);
    q->SetFrame(box);
    q->SetAntiFlick(kTRUE);
    q->SetPickable(kTRUE);

    q->Reset(TEveQuadSet::kQT_RectangleXYFixedDimZ, kFALSE, 64);
    q->SetDefCoord(0);
    q->SetDefHeight(0.84f);
    q->SetDefWidth(0.8f);
  }

  while (stream.Next())
  {
    Int_t ch = AliHMPIDParam::DDL2C(stream.GetDDLNumber());
    TEveQuadSet* q = ms[ch];

    for (Int_t iPad = 0; iPad < stream.GetNPads(); ++iPad)
    {
      AliHMPIDDigit dig(stream.GetPadArray()[iPad],stream.GetChargeArray()[iPad]);

      q->AddQuad(dig.PadChX()*0.8f,  dig.PadChY()*0.84f);
      q->QuadValue(TMath::Nint(dig.Q()));
      q->QuadId(new AliHMPIDDigit(dig));
    }
  }

  for (Int_t iCh = 0; iCh < 7; ++iCh)
  {
    TEveQuadSet* q = ms[iCh];

    q->RefitPlex();

    TGeoHMatrix mat;
    AliHMPIDv3::IdealPosition(iCh, &mat);
    q->RefMainTrans().SetFrom(mat);
    q->RefMainTrans().Move3LF(-0.5*144, -0.5*121, 0);

    list->AddElement(q);
  }

  gEve->Redraw3D();
}
Exemplo n.º 14
0
/* returns 0 if error or no more commands to do,
 *         1 if there are more commands remaining on the current input line
 */
int
cypher(void)
{
	int     n;
	int     junk;
	int     lflag = -1;
	char   *filename, *rfilename;
	size_t  filename_len;

	while (wordnumber <= wordcount) {
		if (wordtype[wordnumber] != VERB &&
		    !(wordtype[wordnumber] == OBJECT &&
		    wordvalue[wordnumber] == KNIFE)) {
			printf("%s: How's that?\n",
			    (wordnumber == wordcount) ? words[wordnumber - 1] : words[wordnumber]);
			return (0);
		}

		switch (wordvalue[wordnumber]) {

		case AUXVERB:
			/* Take the following word as the verb */
			wordnumber++;
			return(cypher());
			break;

		case UP:
			if (location[position].access || wiz || tempwiz) {
				if (!location[position].access)
					puts("Zap!  A gust of wind lifts you up.");
				if (!moveplayer(location[position].up, AHEAD))
					return (0);
			} else {
				puts("There is no way up.");
				return (0);
			}
			lflag = 0;
			break;

		case DOWN:
			if (!moveplayer(location[position].down, AHEAD))
				return (0);
			lflag = 0;
			break;

		case LEFT:
			if (!moveplayer(left, LEFT))
				return (0);
			lflag = 0;
			break;

		case RIGHT:
			if (!moveplayer(right, RIGHT))
				return (0);
			lflag = 0;
			break;

		case AHEAD:
			if (!moveplayer(ahead, AHEAD))
				return (0);
			lflag = 0;
			break;

		case BACK:
			if (!moveplayer(back, BACK))
				return (0);
			lflag = 0;
			break;

		case SHOOT:
			verb_with_all(location[position].objects, OBJ_PERSON,
			    shoot, "shoot at");
			break;

		case TAKE:
			if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
				int things;
				things = 0;
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (TestBit(location[position].objects, n) && objsht[n]) {
						things++;
						wordvalue[wordnumber + 1] = n;
/* Some objects (type NOUNS) have special treatment in take().  For these
 * we must set the type to NOUNS.  However for SWORD and BODY all it does
 * is find which of many objects is meant, so we need do nothing here.
 * BATHGOD must become NORMGOD as well.  NOUNS with no special case must be
 * included here to get the right error.  DOOR cannot occur as an object so
 * need not be included.
 */
						switch (n) {
						case BATHGOD:
							wordvalue[wordnumber + 1] = NORMGOD;
							/* FALLTHROUGH */
						case NORMGOD:
						case AMULET:
						case MEDALION:
						case TALISMAN:
						case MAN:
						case TIMER:
						case NATIVE:
							wordtype[wordnumber + 1] = NOUNS;
							break;
						default:
							wordtype[wordnumber + 1] = OBJECT;
						}
						wordnumber = take(location[position].objects);
						wordnumber += 2;
					}
				if (!things)
					puts("Nothing to take!");
			} else
				take(location[position].objects);
			break;

		case DROP:
			if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
				int things;
				things = 0;
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (TestBit(inven, n)) {
						things++;
						wordvalue[wordnumber + 1] = n;
						wordnumber = drop("Dropped");
					}
				wordnumber++;
				wordnumber++;
				if (!things)
					puts("Nothing to drop!");
			} else
				drop("Dropped");
			break;


		case KICK:
		case THROW:
			if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
				int things, wv;
				things = 0;
				wv = wordvalue[wordnumber];
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (TestBit(inven, n) ||
					  (TestBit(location[position].objects, n) && objsht[n])) {
						things++;
						wordvalue[wordnumber + 1] = n;
						wordnumber = throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
					}
				wordnumber += 2;
				if (!things)
					printf("Nothing to %s!\n", wv == KICK ? "kick" : "throw");
			} else
				throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
			break;

		case TAKEOFF:
			verb_with_all(wear, 0, takeoff, "take off");
			break;

		case DRAW:
			verb_with_all(wear, 0, draw, "draw");
			break;

		case PUTON:
			verb_with_all(location[position].objects, 0, puton, "put on");
			break;

		case WEARIT:
			verb_with_all(inven, 0, wearit, "wear");
			break;

		case EAT:
			verb_with_all(inven, 0, eat, "eat");
			break;

		case PUT:
			put();
			break;

		case INVEN:
			if (ucard(inven)) {
				puts("You are holding:\n");
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (TestBit(inven, n))
						printf("\t%s\n", objsht[n]);
				printf("\n= %d kilogram%s ", carrying,
				    (carrying == 1 ?  "." : "s."));
				if (WEIGHT)
					printf("(%d%%)\n", carrying * 100 / WEIGHT);
				else
					printf("(can't lift any weight%s)\n",
					    (carrying ? " or move with what you have" : ""));
				if (CUMBER)
					printf("Your arms are %d%% full.\n",
					    encumber * 100 / CUMBER);
				else
					printf("You can't pick anything up.\n");
			} else
				puts("You aren't carrying anything.");

			if (ucard(wear)) {
				puts("\nYou are wearing:\n");
				for (n = 0; n < NUMOFOBJECTS; n++)
					if (TestBit(wear, n))
						printf("\t%s\n", objsht[n]);
			} else
				puts("\nYou are stark naked.");
			if (card(injuries, NUMOFINJURIES)) {
				puts("\nYou have suffered:\n");
				for (n = 0; n < NUMOFINJURIES; n++)
					if (injuries[n])
						printf("\t%s\n", ouch[n]);
				printf("\nYou can still carry up to %d kilogram%s\n", WEIGHT, (WEIGHT == 1 ? "." : "s."));
			} else
				puts("\nYou are in perfect health.");
			break;

		case USE:
			lflag = use();
			break;

		case OPEN:
			dooropen();
			break;

		case LOOK:
			if (!notes[CANTSEE] || TestBit(inven, LAMPON) ||
			    TestBit(location[position].objects, LAMPON)
			    || matchlight) {
				beenthere[position] = 2;
				writedes();
				printobjs();
				if (matchlight) {
					puts("\nYour match splutters out.");
					matchlight = 0;
				}
			} else
				puts("I can't see anything.");
			return (0);	/* No commands after a look */
			break;

		case SU:
			if (wiz || tempwiz) {
				getnum(&position, "\nRoom (was %d) = ", position);
				getnum(&ourtime, "Time (was %d) = ", ourtime);
				getnum(&fuel, "Fuel (was %d) = ", fuel);
				getnum(&torps, "Torps (was %d) = ", torps);
				getnum(&CUMBER, "CUMBER (was %d) = ", CUMBER);
				getnum(&WEIGHT, "WEIGHT (was %d) = ", WEIGHT);
				getnum(&ourclock, "Clock (was %d) = ", ourclock);
				if (getnum(&junk, "Wizard (was %d, %d) = ", wiz, tempwiz) != -1 && !junk)
					tempwiz = wiz = 0;
				printf("\nDONE.\n");
				return (0);	/* No commands after a SU */
			} else
				puts("You aren't a wizard.");
			break;

		case SCORE:
			printf("\tPLEASURE\tPOWER\t\tEGO\n");
			printf("\t%3d\t\t%3d\t\t%3d\n\n", pleasure, power, ego);
			printf("This gives you the rating of %s in %d turns.\n", rate(), ourtime);
			printf("You have visited %d out of %d rooms this run (%d%%).\n", card(beenthere, NUMOFROOMS), NUMOFROOMS, card(beenthere, NUMOFROOMS) * 100 / NUMOFROOMS);
			break;

		/* case KNIFE: */
		case KILL:
			murder();
			break;

		case UNDRESS:
			undress();
			break;

		case RAVAGE:
			ravage();
			break;

		case SAVE:
			printf("\nSave file name (default %s):  ",
			    DEFAULT_SAVE_FILE);
			filename = fgetln(stdin, &filename_len);
			if (filename_len == 0
			    || (filename_len == 1 && filename[0] == '\n'))
				rfilename = save_file_name(DEFAULT_SAVE_FILE,
				    strlen(DEFAULT_SAVE_FILE));
			else {
				if (filename[filename_len - 1] == '\n')
					filename_len--;
				rfilename = save_file_name(filename,
				    filename_len);
			}
			save(rfilename);
			free(rfilename);
			break;

		case VERBOSE:
			verbose = 1;
			printf("[Maximum verbosity]\n");
			break;

		case BRIEF:
			verbose = 0;
			printf("[Standard verbosity]\n");
			break;

		case FOLLOW:
			lflag = follow();
			break;

		case GIVE:
			give();
			break;

		case KISS:
			kiss();
			break;

		case LOVE:
			love();
			break;

		case RIDE:
			lflag = ride();
			break;

		case DRIVE:
			lflag = drive();
			break;

		case LIGHT:
			light();
			break;

		case LAUNCH:
			if (!launch())
				return (0);
			else
				lflag = 0;
			break;

		case LANDIT:
			if (!land())
				return (0);
			else
				lflag = 0;
			break;

		case TIME:
			chime();
			break;

		case SLEEP:
			zzz();
			break;

		case DIG:
			dig();
			break;

		case JUMP:
			lflag = jump();
			break;

		case BURY:
			bury();
			break;

		case SWIM:
			puts("Surf's up!");
			break;

		case DRINK:
			drink();
			break;

		case QUIT:
			die(0);

		default:
			puts("How's that?");
			return (0);
			break;

		}
		if (!lflag)
			newlocation();
		if (wordnumber < wordcount && !stop_cypher &&
		    (*words[wordnumber] == ',' || *words[wordnumber] == '.')) {
			wordnumber++;
			return (1);
		} else
			return (0);
	}
	return (0);
}