Ejemplo n.º 1
0
NGSAlignment::NGSAlignment(int nstate, string &seq1, string &seq2) {
    num_states = nstate;
    ncategory = 1;
    pair_freq = new double[nstate*nstate];
    memset(pair_freq, 0, sizeof(double)*nstate*nstate);
    assert(seq1.length() == seq2.length());
    int len = seq1.length();
    int i;
    for (i = 0; i < len; i++) {
        int state1 = convertState(seq1[i], SEQ_DNA);
        int state2 = convertState(seq2[i], SEQ_DNA);
        if (state1 < num_states && state2 < num_states)
            pair_freq[state1*num_states+state2] += 1;
    }
}
Ejemplo n.º 2
0
/*------------------------------------------------------------------------------
|    OpenMAXILPlayerControl::state
+-----------------------------------------------------------------------------*/
QMediaPlayer::State OpenMAXILPlayerControl::state() const
{
   log_debug_func;

   assert(m_mediaProcessor);
   return convertState(m_mediaProcessor->state());
}
Ejemplo n.º 3
0
/*------------------------------------------------------------------------------
|    OpenMAXILPlayerControl::state
+-----------------------------------------------------------------------------*/
QMediaPlayer::State OpenMAXILPlayerControl::state() const
{
   LOG_DEBUG(LOG_TAG, "%s", Q_FUNC_INFO);

   assert(m_mediaProcessor);
   return convertState(m_mediaProcessor->state());
}
Ejemplo n.º 4
0
void QompQtMultimediaPlayer::playerStateChanged(QMediaPlayer::State _state)
{
#ifdef DEBUG_OUTPUT
	qDebug() << "QompQtMultimediaPlayer::stateChanged()  " << _state;
#endif
//	if(state == QMediaPlayer::StoppedState && position() == currentTuneTotalTime())
//		emit mediaFinished();

	emit stateChanged(convertState(_state));
}
Ejemplo n.º 5
0
void S60AudioMediaRecorderControl::updateState(S60AudioCaptureSession::TAudioCaptureState aState)
{
    QMediaRecorder::State newState = convertState(aState);
    if (m_state != newState) {
        m_state = newState;
        TRACE("S60AudioMediaRecorderControl::stateChanged" << qtThisPtr()
              << "state" << m_state);
        emit stateChanged(m_state);
    }
}
Ejemplo n.º 6
0
/**
 *	@brief		search 3x4 -> 3x3
 *	@param[in]	ac_InitState		state on start
 *	@param[out]	ac_MidState			state on first search end
 *	@param[in]	ac_MoveLog			space moved log
 */
void	search3x4(char* ac_InitState, char* ac_MidState, char* ac_MoveLog)
{
    char	ac_MoveState[FIELD_SIZE];

    printState((char(*)[FIELD_WIDTH])ac_InitState);

    moveState(ac_MoveState, ac_InitState, ac_MoveLog);

    printf("moved :\n");
    printState((char(*)[FIELD_WIDTH])ac_MoveState);

    convertState(ac_MidState, ac_MoveState);

    printf("converted :\n");
    printState((char(*)[FIELD_WIDTH])ac_MidState);
}
Ejemplo n.º 7
0
Qomp::State QompQtMultimediaPlayer::state() const
{
	return convertState(player_->state());
}
Ejemplo n.º 8
0
/*------------------------------------------------------------------------------
|    OpenMAXILPlayerControl::onStateChanged
+-----------------------------------------------------------------------------*/
void OpenMAXILPlayerControl::onStateChanged(OMX_MediaProcessor::OMX_MediaProcessorState state)
{
   LOG_DEBUG(LOG_TAG, "State changed...");
   emit stateChanged(convertState(state));
}
bool ObeyGameManager::run(BEHAVIOR_PARAMS) {
  MotionCommand & motionCommand = command.getMotionCommand();
  SoundCommand  & soundCommand  = command.getSoundCommand();
  LEDCommand    & ledCommand    = command.getLEDCommand();

  GameState::StateOfGame stateOfGame = gameState.getStateOfGame();

  // Only allow text-to-speech of other behaviors when playing
  if (stateOfGame != GameState::playing) {
    soundCommand.clear();
  }

  try {
    fsm.startLoop(log.getTimestamp());
    while(fsm.isRunning()) {

      if (fsm.inState(Uninitialized)) {
        wasIBlue      = gameState.isOurColorBlue();
        wasOurKickoff = gameState.isOurKickoff();

        fsm.trans(convertState(stateOfGame), "Initialized");
        continue;
      }

      else if (fsm.inState(Initial)) {
        State state = convertState(stateOfGame);
        if (state != Initial) {
          fsm.trans(state, "Game state changed");
          continue;
        }

        ledCommand.setChest(INITIAL_CHEST_COLOR);

        // Go to stand neutral position
        motionCommand.standNeutral();
        // Look straight ahead
        motionCommand.headAngles(0, 0, HEAD_SPEED);

        fsm.endLoop();
        continue;
      }

      else if (fsm.inState(Ready)) {
        State state = convertState(stateOfGame);
        if (state != Ready) {
          fsm.trans(state, "Game state changed");
          continue;
        }

        if (fsm.isNewState()) {
          soundCommand.say(READY_SPEECH);
        }

        ledCommand.setChest(READY_CHEST_COLOR);

        // Stand neutral
        //motionCommand.standNeutral();

        fsm.endLoop();
        continue;
      }

      else if (fsm.inState(Set)) {
        State state = convertState(stateOfGame);
        if (state != Set) {
          fsm.trans(state, "Game state changed");
          continue;
        }

        if (fsm.isNewState()) {
          soundCommand.say(SET_SPEECH);
        }

        ledCommand.setChest(SET_CHEST_COLOR);

        // Stand neutral
        motionCommand.standNeutral();

        fsm.endLoop();
        continue;
      }

      else if (fsm.inState(Playing)) {
        State state = convertState(stateOfGame);
        if (state != Playing) {
          fsm.trans(state, "Game state changed");
          continue;
        }

        if (gameState.amIPenalized()) {
          fsm.trans(Penalized, "Penalized");
          continue;
        }

        if (fsm.isNewState()) {
          if (!wasIPenalized) {
            soundCommand.say(PLAYING_SPEECH);
          }
          else {
            wasIPenalized = false;
            soundCommand.say(BACK_FROM_PENALTY_SPEECH);
          }
        }

        ledCommand.setChest(PLAYING_CHEST_COLOR);

        fsm.endLoop();
        continue;
      }

      else if (fsm.inState(Penalized)) {
        State state = convertState(stateOfGame);
        if (state != Playing) {
          fsm.trans(state, "Game state changed");
          continue;
        }

        if (!gameState.amIPenalized()) {
          fsm.trans(BackFromPenalty, "No longer penalized");
          continue;
        }

        if (fsm.isNewState()) {
          wasIPenalized = true;
          soundCommand.say(PENALIZED_SPEECH);
        }

        ledCommand.setChest(PENALIZED_CHEST_COLOR);
        // Go to stand neutral position
        motionCommand.standNeutral();
        // Look straight ahead
        motionCommand.headAngles(0, 0, HEAD_SPEED);

        fsm.endLoop();
        continue;
      }

      else if (fsm.inState(BackFromPenalty)) {
        State state = convertState(stateOfGame);
        if (state != Playing) {
          fsm.trans(state, "Game state changed");
          continue;
        }

        if (gameState.amIPenalized()) {
          fsm.trans(Penalized, "Penalized again");
          continue;
        }

        // No checking for now
        fsm.trans(Playing, "No checks for now");
        continue;
      }

      else if (fsm.inState(Finished)) {
        State state = convertState(stateOfGame);
        if (state != Finished) {
          fsm.trans(state, "Game state changed");
          continue;
        }

        ledCommand.setChest(FINISHED_CHEST_COLOR);
        // Go to stand neutral position
        motionCommand.standNeutral();
        // Look straight ahead
        motionCommand.headAngles(0, 0, HEAD_SPEED);

        fsm.endLoop();
        continue;
      }

      else {
        fsm.trans(Uninitialized, "Invalid state");
        continue;
      }

    }
  }
  catch (int e) {
    if (fsm.isRunning()) {
      fsm.endLoop();
    }
  }
  fsm.printTransitions();

  switch (stateOfGame) {
  case GameState::initial:
  case GameState::ready:
  case GameState::set:
    if (gameState.isOurColorBlue()) {
      ledCommand.setLeftFoot(BLUE_TEAM_FOOT_COLOR);
    }
    else {
      ledCommand.setLeftFoot(RED_TEAM_FOOT_COLOR);
    }
    if (gameState.isOurKickoff()) {
      ledCommand.setRightFoot(KICKOFF_FOOT_COLOR);
    }
    else {
      ledCommand.setRightFoot(NO_KICKOFF_FOOT_COLOR);
    }
    break;
  default:
    if (gameState.isOurColorBlue()) {
      ledCommand.setLeftFoot(BLUE_TEAM_FOOT_COLOR);
      ledCommand.setRightFoot(BLUE_TEAM_FOOT_COLOR);
    }
    else {
      ledCommand.setLeftFoot(RED_TEAM_FOOT_COLOR);
      ledCommand.setRightFoot(RED_TEAM_FOOT_COLOR);
    }
  }

  if (wasOurKickoff != gameState.isOurKickoff()) {
    wasOurKickoff = gameState.isOurKickoff();
    if (wasOurKickoff) {
      soundCommand.say(KICKOFF_SPEECH);
    }
    else {
      soundCommand.say(NO_KICKOFF_SPEECH);
    }
  }
  if (wasIBlue != gameState.isOurColorBlue()) {
    wasIBlue = gameState.isOurColorBlue();
    if (wasIBlue) {
      soundCommand.say(BLUE_TEAM_SPEECH);
    }
    else {
      soundCommand.say(RED_TEAM_SPEECH);
    }
  }

  return false;
}
Ejemplo n.º 10
0
/*------------------------------------------------------------------------------
|    OpenMAXILPlayerControl::onStateChanged
+-----------------------------------------------------------------------------*/
void OpenMAXILPlayerControl::onStateChanged(OMX_MediaProcessor::OMX_MediaProcessorState state)
{
   emit stateChanged(convertState(state));
}
Ejemplo n.º 11
0
/**
 *	@brief		search 3x4 -> 3x3
 *	@param[in]	ac_InitState		state on start
 *	@param[in]	ac_MidState			state on first search end
 *	@param[in]	ac_MoveLog			space moved log
 */
void	search3x4(char* ac_InitState, char* ac_MidState, char* ac_MoveLog)
{
	char		ac_CurrState[FIELD_SIZE],
				ac_CurrMoveLog[SUM_MOVE_MAX],
				c_CurrSpcPos	= searchSpace(ac_InitState, FIELD_SIZE);
	AVAIL_STATE	ac_AvailState[AVAIL_STATE_NUM];
	const UINT	ui_GoalScore	= ANSWER_PLACE;
	UINT		ui_MaxScore		= checkScore(ac_InitState);

	memcpy(ac_CurrState, ac_InitState, FIELD_SIZE);

	while(ui_MaxScore != ui_GoalScore) {
		AVAIL_STATE	*p_NowState,
					*p_NextState;
		UINT	ui_SpcPos,
				ui_AdjaPos;
		UINT	ui_Score	= 0,
				ui_Anum		= 0,
				uii;
		char	ac_Move[2]	= {'\0', '\0'};

		ui_Score	= 0;
		ui_Anum		= 0;

		memset(ac_AvailState, 0, sizeof(ac_AvailState));
		memcpy(ac_AvailState[ui_Anum].ac_Array, ac_CurrState, FIELD_SIZE);
		ac_AvailState[ui_Anum].c_SpcPos		= c_CurrSpcPos;
		ac_AvailState[ui_Anum].c_PrevPos	= 0x7F;

		for(ui_Anum = 0; ui_Anum < (AVAIL_STATE_NUM - 3); ui_Anum += uii) {
			ui_SpcPos	= ac_AvailState[ui_Anum].c_SpcPos;

			for(uii = 0;
				(ui_AdjaPos = (UINT)ac_Adjacent[ui_SpcPos][uii]) != -1;
				uii++) {
				if((ac_AvailState[ui_Anum].ac_Array[ui_AdjaPos] == ac_AvailState[ui_Anum].c_PrevPos) ||
				   (ac_AvailState[ui_Anum].ac_Array[ui_AdjaPos] == '=')) {
					continue;
				}

				p_NowState	= &ac_AvailState[ui_Anum];
				p_NextState	= &ac_AvailState[ui_Anum + 1];

				/* 状態をコピー */
				memcpy(p_NextState->ac_Array,
					   p_NowState->ac_Array,
					   FIELD_SIZE);

				/* 移動 */
				p_NextState->ac_Array[ui_SpcPos]	= p_NextState->ac_Array[ui_AdjaPos];
				p_NextState->ac_Array[ui_AdjaPos]	= 0;
				p_NextState->c_SpcPos				= (char)ui_AdjaPos;
				p_NextState->c_PrevPos				= p_NowState->c_SpcPos;

				ac_Move[0]	= getMoveDirection(p_NowState->c_SpcPos, p_NextState->c_SpcPos);
				strcat(p_NextState->ac_mMoveLog, ac_Move);

				ui_Score	= checkScore(p_NextState->ac_Array);
				if(ui_Score > ui_MaxScore) {
					ui_MaxScore	= ui_Score;

					memcpy(ac_CurrState, p_NextState->ac_Array, FIELD_SIZE);
					c_CurrSpcPos	= p_NextState->c_SpcPos;
					strcat(ac_CurrMoveLog, p_NextState->ac_mMoveLog);

					ui_Anum	= AVAIL_STATE_NUM;		/* break */
					break;
				}
			}
		}
	}

	printf("3x4 clear !\n");
	printState((char(*)[FIELD_WIDTH])ac_CurrState);

	convertState(ac_MidState, ac_CurrState);
	strcat(ac_MoveLog, ac_CurrMoveLog);
}