Esempio n. 1
0
//象
void CMoveGenerator::Gen_ElephantMove(BYTE position[10][9],int i,int j,int nPly)
{
    int x,y;
    
    //插入右下方的有效走法
    x=j+2;
    y=i+2;
    if(x<9 && y<10 && IsValidMove(position,j,i,x,y,m_nUserChessColor))
        AddMove(j,i,x,y,nPly,position[i][j]);
    
    //插入右上方的有效走法
    x=j+2;
    y=i-2;
    if(x<9 && y>=0 && IsValidMove(position,j,i,x,y,m_nUserChessColor))
        AddMove(j,i,x,y,nPly,position[i][j]);
    
    //插入左下方的有效走法
    x=j-2;
    y=i+2;
    if(x>=0 && y<10 && IsValidMove(position,j,i,x,y,m_nUserChessColor))
        AddMove(j,i,x,y,nPly,position[i][j]);
    
    //插入左上方的有效走法
    x=j-2;
    y=i-2;
    if(x>=0 && y>=0 && IsValidMove(position,j,i,x,y,m_nUserChessColor))
        AddMove(j,i,x,y,nPly,position[i][j]);
}
//---------------------------------------------------------------------------
void TFormMain::CheckTwoOther(int& xMove,int& yMove) const
{
  assert(xMove == -1 && yMove == -1);
  const std::vector<GameMove> moves1(GetTwoHorizontalOtherMoves());
  const std::vector<GameMove> moves2(GetTwoVerticalOtherMoves());
  const std::vector<GameMove> moves(Concatenate(moves1,moves2));
  assert(moves.size() == moves1.size() + moves2.size());

  const int nMoves = moves.size();
  if (nMoves==0) return;

  { //Get moves anti-player
    std::vector<GameMove> antiPlayerMoves;
    for (int i=0; i<nMoves; ++i)
    {
      assert(IsValidMove(moves[i]));
      if (IsRobot(moves[i].anti) == false) antiPlayerMoves.push_back(moves[i]);
    }
    //If there are anti-player moves, choose one at random
    if (antiPlayerMoves.empty()==false)
    {
      const int nAntiPlayerMoves = antiPlayerMoves.size();
      const int index = std::rand() % nAntiPlayerMoves;
      xMove = antiPlayerMoves[index].x;
      yMove = antiPlayerMoves[index].y;
      assert(IsValidMove(xMove,yMove));
      return;
    }
  }
  { //Get moves anti-next-player
    std::vector<GameMove> antiNextPlayerMoves;
    for (int i=0; i<nMoves; ++i)
    {
      if (GetNextPlayer(mPlayer) == moves[i].anti) antiNextPlayerMoves.push_back(moves[i]);
    }
    //If there are anti-next-player moves, choose one at random
    if (antiNextPlayerMoves.empty()==false)
    {
      const int nAntiNextPlayerMoves = antiNextPlayerMoves.size();
      const int index = std::rand() % nAntiNextPlayerMoves;
      xMove = antiNextPlayerMoves[index].x;
      yMove = antiNextPlayerMoves[index].y;
      assert(IsValidMove(xMove,yMove));
      return;
    }
  }
  //Choose a move at random
  {
    const int index = std::rand() % nMoves;
    xMove = moves[index].x;
    yMove = moves[index].y;
    assert(IsValidMove(xMove,yMove));
  }
}
Esempio n. 3
0
void CMoveGenerator::Gen_KingMove(BYTE position[10][9],int i,int j,int nPly)
{
    int x,y;
    
    for(y=0;y<3;y++)
        for(x=3;x<6;x++)
            if(IsValidMove(position,j,i,x,y,m_nUserChessColor))
                AddMove(j,i,x,y,nPly,position[i][j]);

    for(y=7;y<10;y++)
        for(x=3;x<6;x++)
            if(IsValidMove(position,j,i,x,y,m_nUserChessColor))
                AddMove(j,i,x,y,nPly,position[i][j]);
}
void __fastcall TFormMain::TimerThinkerTimer(TObject *Sender)
{
  //Check if moves already have been calculated
  if (mNextRobotMove.x!=-1) return;
  if (mNextRobotMove.y!=-1) return;
  if (IsRobot(mPlayer)==false)
  {
    OutputDebugString("Hey, I ain't a player!");
    return;
  }
  int xMove = -1;
  int yMove = -1;
  //Make a non-random move
  if (xMove == -1 && yMove == -1) CheckTwoHorizontalOwn(xMove,yMove);
  if (xMove == -1 && yMove == -1) CheckTwoVerticalOwn(xMove,yMove);
  if (xMove == -1 && yMove == -1) CheckTwoOther(xMove,yMove);
  if (xMove == -1 && yMove == -1) CheckTwoDiagonally(xMove,yMove);
  if (xMove == -1 && yMove == -1) CheckOneOther(xMove,yMove);
  if (xMove == -1 && yMove == -1) MakeRandomMove(xMove,yMove);
  assert(IsValidMove(xMove,yMove));
  //Do it then...
  mNextRobotMove.x = xMove;
  mNextRobotMove.y = yMove;
  //Click it on the playfield virtually
  //This will be done by TimerDoer
}
//---------------------------------------------------------------------------
const std::vector<GameMove> TFormMain::GetTwoHorizontalOtherMoves() const
{
  std::vector<GameMove> moves;
  for (int y=0; y!=mMaxy; ++y)
  {
    for (int x=0; x!=mMaxx-1; ++x) //-1 to prevent out of range
    {
      //Check consequtive
      if (mBlocks[x][y]!=NoPlayer && mBlocks[x][y] == mBlocks[x+1][y])
      {
        //Check A X B
        if (x > 0 && mBlocks[x-1][y] == NoPlayer)
        {
          //xMove = x-1; yMove = y;
          GameMove move;
          move.x = x-1;
          move.y = y;
          move.anti = mBlocks[x][y];
          assert(IsValidMove(move));
          moves.push_back(move);
        }
        //Check X B C
        if (x < mMaxx-2 && mBlocks[x+2][y] == NoPlayer)
        {
          GameMove move;
          move.x = x+2;
          move.y = y;
          move.anti = mBlocks[x][y];
          assert(IsValidMove(move));
          moves.push_back(move);
        }
      }
      //Check gap, also X B C
      if (mBlocks[x][y] != NoPlayer && x + 2 < mMaxx && mBlocks[x+1][y] == NoPlayer && mBlocks[x][y] == mBlocks[x+2][y])
      {
        GameMove move;
        move.x = x+1;
        move.y = y;
        move.anti = mBlocks[x][y];
        assert(IsValidMove(move));
        moves.push_back(move);
      }

    }
  }
  return moves;
}
//---------------------------------------------------------------------------
//A X B C (x is focus of for loop)
const std::vector<GameMove> TFormMain::GetTwoVerticalOtherMoves() const
{
  std::vector<GameMove> moves;
  for (int y=0; y!=mMaxy-1; ++y) //-1 to prevent out of range
  {
    for (int x=0; x!=mMaxx; ++x)
    {
      //Check consequtive
      if (mBlocks[x][y] != NoPlayer && mBlocks[x][y] == mBlocks[x][y+1])
      {
        //Check A X B
        if (y > 0 && mBlocks[x][y-1] == NoPlayer)
        {
          GameMove move;
          move.x = x;
          move.y = y-1;
          move.anti = mBlocks[x][y];
          assert(IsValidMove(move));
          moves.push_back(move);
        }
        //Check X B C
        if (y < mMaxy-2 && mBlocks[x][y+2] == NoPlayer)
        {
          GameMove move;
          move.x = x;
          move.y = y+2;
          move.anti = mBlocks[x][y];
          assert(IsValidMove(move));
          moves.push_back(move);
        }
      }
      //Check gap, also X B C
      if (mBlocks[x][y] != NoPlayer && y < mMaxy && mBlocks[x][y+1] == NoPlayer && mBlocks[x][y] == mBlocks[x][y+2])
      {
        GameMove move;
        move.x = x;
        move.y = y+1;
        move.anti = mBlocks[x][y];
        assert(IsValidMove(move));
        moves.push_back(move);
      }
    }
  }
  return moves;
}
Esempio n. 7
0
/**
 * Gives the possible moves for a given position.
 *
 * @return
 *  The possible moves, in a boolean array
 */
bool* Board::GetPossibleMoves(int x, int y) const {
    bool* output = new bool[10];

    output[0] = 0;
    for (int i = 1; i < 10; i++)
        output[i] = IsValidMove(x, y, i);

    return output;
}
//---------------------------------------------------------------------------
void TFormMain::CheckTwoVerticalOwn(int& xMove,int& yMove) const
{
  assert(xMove == -1 && yMove == -1);
  for (int y=0; y!=mMaxy-1; ++y) //-1 to prevent out of range
  {
    for (int x=0; x!=mMaxx; ++x)
    {
      //Two consequtive selfs?
      if (mBlocks[x][y] == mPlayer && mBlocks[x][y+1] == mPlayer)
      {
        if (y >= 1)
        {
          if (mBlocks[x][y-1] == NoPlayer)
          {
            xMove = x; yMove = y-1;
            assert(IsValidMove(xMove,yMove));
            return;
          }
        }
        if (y < mMaxy-2)
        {
          if (mBlocks[x][y+2] == NoPlayer)
          {
            xMove = x; yMove = y+2;
            assert(IsValidMove(xMove,yMove));
            return;
          }
        }
      }
      //Perhaps a gap?
      if (y < mMaxy-2)
      {
        if (mBlocks[x][y] == mPlayer && mBlocks[x][y+1] == NoPlayer && mBlocks[x][y+2] == mPlayer)
        {
            xMove = x; yMove = y+1;
            assert(IsValidMove(xMove,yMove));
            return;
        }
      }

    }
  }
}
Esempio n. 9
0
//马
void CMoveGenerator::Gen_HorseMove(BYTE position[10][9], int i, int j, int nPly)
{
    int x, y;
    
    //插入右下方的有效走法
    x=j+2;//右2
    y=i+1;//下1
    if((x<9 && y<10) && IsValidMove(position,j,i,x,y,m_nUserChessColor))
        AddMove(j,i,x,y,nPly,position[i][j]);
    
    //插入右上方的有效走法
    x=j+2;//右2
    y=i-1;//上1
    if((x<9 && y>=0) && IsValidMove(position,j,i,x,y,m_nUserChessColor))
        AddMove(j,i,x,y,nPly,position[i][j]);
    
    //插入左下方的有效走法
    x=j-2;//左2
    y=i+1;//下1
    if((x>=0 && y<10) && IsValidMove(position,j,i,x,y,m_nUserChessColor))
        AddMove(j,i,x,y,nPly,position[i][j]);

    //插入左上方的有效走法
    x=j-2;//左2
    y=i-1;//上1
    if((x>=0 && y>=0) && IsValidMove(position,j,i,x,y,m_nUserChessColor))
        AddMove(j,i,x,y,nPly,position[i][j]);
    
    //插入右下方的有效走法
    x=j+1;//右1
    y=i+2;//下2 
    if((x<9 && y<10) && IsValidMove(position,j,i,x,y,m_nUserChessColor))
        AddMove(j,i,x,y,nPly,position[i][j]);

    //插入左下方的有效走法
    x=j-1;//左1
    y=i+2;//下2
    if((x>=0 && y<10) && IsValidMove(position,j,i,x,y,m_nUserChessColor))
        AddMove(j,i,x,y,nPly,position[i][j]);    
    
    //插入右上方的有效走法
    x=j+1;//右1
    y=i-2;//上2
    if((x<9 && y >=0) && IsValidMove(position,j,i,x,y,m_nUserChessColor))
        AddMove(j,i,x,y,nPly,position[i][j]);

    //插入左上方的有效走法
    x=j-1;//左1
    y=i-2;//上2
    if((x>=0 && y>=0) && IsValidMove(position,j,i,x,y,m_nUserChessColor))
        AddMove(j,i,x,y,nPly,position[i][j]);
}
Esempio n. 10
0
void main(){
	char nice='y';
	while(nice == 'y'){
		char winner = 'N';
		bool turn=true, validty;
		int move, counter=1, i, m=49;
		char board[9];
		for (i=0; i<9; i++){
			board[i] = m;
			m++;
		}
		PrintBoard(board);
		while (winner == 'N'){
			printf("Where do you want to go? Pick an available number: ");
			scanf("%d", &move);
			validty = IsValidMove(board, move-1);
			while (validty==false || board[move-1]=='X' || board[move-1]=='O'){
				printf("INVALID MOVE. PICK AGAIN.\n");
				printf("Where do you want to go? Pick an available number: ");
				scanf("%d", &move);
				validty = IsValidMove(board, move-1);
			}
			if (turn)
				board[move-1] = 'X';
			else
				board[move-1] = 'O';
			PrintBoard(board);
			winner = WinnerIfAny(board);
			if (counter==9 && winner=='N')
				winner = 'S';
			turn = !turn;
			counter++;
		}
		if(winner != 'S')
			printf("CONGRATULATIONS PLAYER %c!!! YOU WON!!!\n", winner);
		else
			printf("STAKENATE!!!\n");
		printf("Would you like to play another game?(y/n):");
		flushall();
		scanf("%c", &nice);
	}
}
//---------------------------------------------------------------------------
void TFormMain::CheckTwoHorizontalOwn(int& xMove,int& yMove) const
{
  assert(xMove == -1 && yMove == -1);
  for (int y=0; y!=mMaxy; ++y)
  {
    for (int x=0; x!=mMaxx-1; ++x) //-1 to prevent out of range
    {
      //Two consequtive selfs
      if (mBlocks[x][y] == mPlayer && mBlocks[x+1][y] == mPlayer)
      {
        if (x >= 1)
        {
          if (mBlocks[x-1][y] == NoPlayer)
          {
            xMove = x-1; yMove = y;
            assert(IsValidMove(xMove,yMove));
            return;
          }
        }
        if (x < mMaxx-2 && mBlocks[x+2][y] == NoPlayer)
        {
          xMove = x+2; yMove = y;
          assert(IsValidMove(xMove,yMove));
          return;
        }
      }
      //Perhaps a gap?
      if (x < mMaxx-2)
      {
        if (mBlocks[x][y] == mPlayer && mBlocks[x+1][y] == NoPlayer && mBlocks[x+2][y] == mPlayer)
        {
            xMove = x+1; yMove = y;
            assert(IsValidMove(xMove,yMove));
            return;
        }
      }
    }
  }
}
void TFormMain::MakeRandomMove(int& xMove,int& yMove) const
{
  assert(xMove == -1 && yMove == -1);
  while(1)
  {
    xMove = std::rand() % mMaxx;
    yMove = std::rand() % mMaxy;
    if (mBlocks[xMove][yMove] == NoPlayer)
    {
      assert(IsValidMove(xMove,yMove));
      return;
    }
  }
}
//---------------------------------------------------------------------------
void TFormMain::CheckTwoDiagonally(int& xMove,int& yMove) const
{
  assert(xMove == -1 && yMove == -1);
  std::vector<GameMove> moves;

  for (int y=0; y!=mMaxy-1; ++y) //-1 To prevent out of range
  {
    for (int x=0; x!=mMaxx-1; ++x) //-1 to prevent out of range
    {
      if (mBlocks[x][y] == mPlayer && mBlocks[x+1][y+1] == mPlayer)
      {
        if (mBlocks[x+1][y] == NoPlayer)
        {
          GameMove move;
          move.x = x+1;
          move.y = y;
          assert(IsValidMove(move));
          moves.push_back(move);
        }
        if (mBlocks[x][y+1] == NoPlayer)
        {
          GameMove move;
          move.x = x;
          move.y = y+1;
          assert(IsValidMove(move));
          moves.push_back(move);
        }
      }
    }
  }
  const int nMoves = moves.size();
  if (nMoves == 0) return;
  const int index = std::rand() % nMoves;
  xMove = moves[index].x;
  yMove = moves[index].y;
  assert(IsValidMove(xMove,yMove));
}
Esempio n. 14
0
inline void Board::PlayLegal (const Move& move) {
	ASSERT(IsValidMove(move));
	uint pos = move.GetLocation().GetPos();
	if (move.GetPlayer() == Player::First()) {
		_board[pos] = pos;
		MakeUnion(pos);
	} else {
		_board[pos] = -1;
	}
	uint fast_map_pos = _reverse_fast_field_map[pos];
	uint replace_pos = _fast_field_map[--_moves_left];
	_fast_field_map[fast_map_pos] = replace_pos;
	_reverse_fast_field_map[replace_pos] = fast_map_pos;
	_current = _current.Opponent();
}
Esempio n. 15
0
File: Mv.c Progetto: alt0174/edk2
/**
  function to take a list of files to move and a destination location and do
  the verification and moving of those files to that location.  This function
  will report any errors to the user and continue to move the rest of the files.

  @param[in] FileList           A LIST_ENTRY* based list of files to move
  @param[out] Resp              pointer to response from question.  Pass back on looped calling
  @param[in] DestParameter      the originally specified destination location

  @retval SHELL_SUCCESS             the files were all moved.
  @retval SHELL_INVALID_PARAMETER   a parameter was invalid
  @retval SHELL_SECURITY_VIOLATION  a security violation ocurred
  @retval SHELL_WRITE_PROTECTED     the destination was write protected
  @retval SHELL_OUT_OF_RESOURCES    a memory allocation failed
**/
SHELL_STATUS
EFIAPI
ValidateAndMoveFiles(
  IN EFI_SHELL_FILE_INFO        *FileList,
  OUT VOID                      **Resp,
  IN CONST CHAR16               *DestParameter
  )
{
  EFI_STATUS                Status;
  CHAR16                    *HiiOutput;
  CHAR16                    *HiiResultOk;
  CHAR16                    *DestPath;
  CHAR16                    *FullDestPath;
  CONST CHAR16              *Cwd;
  CHAR16                    *FullCwd;
  SHELL_STATUS              ShellStatus;
  EFI_SHELL_FILE_INFO       *Node;
  VOID                      *Response;
  UINT64                    Attr;
  CHAR16                    *CleanFilePathStr;

  ASSERT(FileList != NULL);
  ASSERT(DestParameter  != NULL);

  DestPath          = NULL;
  FullDestPath      = NULL;
  Cwd               = ShellGetCurrentDir(NULL);
  Response          = *Resp;
  Attr              = 0;
  CleanFilePathStr  = NULL;
  FullCwd           = NULL;

  if (Cwd != NULL) {
    FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16));
    if (FullCwd == NULL) {
      return SHELL_OUT_OF_RESOURCES;
    } else {
      StrCpyS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, Cwd);
      StrCatS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, L"\\");
    }
  } 

  Status = ShellLevel2StripQuotes (DestParameter, &CleanFilePathStr);
  if (EFI_ERROR (Status)) {
    SHELL_FREE_NON_NULL(FullCwd);
    if (Status == EFI_OUT_OF_RESOURCES) {
      return SHELL_OUT_OF_RESOURCES;
    } else {
      return SHELL_INVALID_PARAMETER;
    }
  }

  ASSERT (CleanFilePathStr != NULL);

  //
  // Get and validate the destination location
  //
  ShellStatus = GetDestinationLocation(CleanFilePathStr, &DestPath, FullCwd, (BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);
  FreePool (CleanFilePathStr);

  if (ShellStatus != SHELL_SUCCESS) {
    SHELL_FREE_NON_NULL (FullCwd);
    return (ShellStatus);
  }
  DestPath = PathCleanUpDirectories(DestPath);
  if (DestPath == NULL) {
    FreePool (FullCwd);
    return (SHELL_OUT_OF_RESOURCES);
  }

  HiiOutput   = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MV_OUTPUT), NULL);
  HiiResultOk = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_GEN_RES_OK), NULL);
  if (HiiOutput == NULL || HiiResultOk == NULL) {
    SHELL_FREE_NON_NULL(DestPath);
    SHELL_FREE_NON_NULL(HiiOutput);
    SHELL_FREE_NON_NULL(HiiResultOk);
    SHELL_FREE_NON_NULL(FullCwd);
    return (SHELL_OUT_OF_RESOURCES);
  }

  //
  // Go through the list of files and directories to move...
  //
  for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link)
    ;  !IsNull(&FileList->Link, &Node->Link)
    ;  Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Node->Link)
   ){
    if (ShellGetExecutionBreakFlag()) {
      break;
    }

    //
    // These should never be NULL
    //
    ASSERT(Node->FileName != NULL);
    ASSERT(Node->FullName != NULL);
    ASSERT(Node->Info     != NULL);

    //
    // skip the directory traversing stuff...
    //
    if (StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0) {
      continue;
    }

    SHELL_FREE_NON_NULL(FullDestPath);
    FullDestPath = NULL;
    if (ShellIsDirectory(DestPath)==EFI_SUCCESS) {
      CreateFullDestPath((CONST CHAR16 **)&DestPath, &FullDestPath, Node->FileName);
    }

    //
    // Validate that the move is valid
    //
    if (!IsValidMove(Node->FullName, FullCwd, FullDestPath!=NULL? FullDestPath:DestPath, Node->Info->Attribute, Attr, Node->Status)) {
      ShellStatus = SHELL_INVALID_PARAMETER;
      continue;
    }

    ShellPrintEx(-1, -1, HiiOutput, Node->FullName, FullDestPath!=NULL? FullDestPath:DestPath);

    //
    // See if destination exists
    //
    if (!EFI_ERROR(ShellFileExists(FullDestPath!=NULL? FullDestPath:DestPath))) {
      if (Response == NULL) {
        ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);
      }
      switch (*(SHELL_PROMPT_RESPONSE*)Response) {
        case ShellPromptResponseNo:
          FreePool(Response);
          Response = NULL;
          continue;
        case ShellPromptResponseCancel:
          *Resp = Response;
          //
          // indicate to stop everything
          //
          SHELL_FREE_NON_NULL(FullCwd);
          return (SHELL_ABORTED);
        case ShellPromptResponseAll:
          *Resp = Response;
          break;
        case ShellPromptResponseYes:
          FreePool(Response);
          Response = NULL;
          break;
        default:
          FreePool(Response);
          SHELL_FREE_NON_NULL(FullCwd);
          return SHELL_ABORTED;
      }
      Status = ShellDeleteFileByName(FullDestPath!=NULL? FullDestPath:DestPath);
    }

    if (IsBetweenFileSystem(Node->FullName, FullCwd, DestPath)) {
      while (FullDestPath == NULL && DestPath != NULL && DestPath[0] != CHAR_NULL && DestPath[StrLen(DestPath) - 1] == L'\\') {
        DestPath[StrLen(DestPath) - 1] = CHAR_NULL;
      }
      Status = MoveBetweenFileSystems(Node, FullDestPath!=NULL? FullDestPath:DestPath, &Response);
    } else {
      Status = MoveWithinFileSystems(Node, DestPath, &Response);
      //
      // Display error status
      //
      if (EFI_ERROR(Status)) {
        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"mv", Status);
      }
    }

    //
    // Check our result
    //
    if (EFI_ERROR(Status)) {
      ShellStatus = SHELL_INVALID_PARAMETER;
      if (Status == EFI_SECURITY_VIOLATION) {
        ShellStatus = SHELL_SECURITY_VIOLATION;
      } else if (Status == EFI_WRITE_PROTECTED) {
        ShellStatus = SHELL_WRITE_PROTECTED;
      } else if (Status == EFI_OUT_OF_RESOURCES) {
        ShellStatus = SHELL_OUT_OF_RESOURCES;
      } else if (Status == EFI_DEVICE_ERROR) {
        ShellStatus = SHELL_DEVICE_ERROR;
      } else if (Status == EFI_ACCESS_DENIED) {
        ShellStatus = SHELL_ACCESS_DENIED;
      }
    } else {
      ShellPrintEx(-1, -1, L"%s", HiiResultOk);
    }

  } // main for loop

  SHELL_FREE_NON_NULL(FullDestPath);
  SHELL_FREE_NON_NULL(DestPath);
  SHELL_FREE_NON_NULL(HiiOutput);
  SHELL_FREE_NON_NULL(HiiResultOk);
  SHELL_FREE_NON_NULL(FullCwd);
  return (ShellStatus);
}
//---------------------------------------------------------------------------
const bool TFormMain::IsValidMove(const GameMove& move) const
{
  return IsValidMove(move.x,move.y);
}
//---------------------------------------------------------------------------
void TFormMain::CheckOneOther(int& xMove,int& yMove) const
{
  assert(xMove == -1 && yMove == -1);
  std::vector<GameMove> moves;

  for (int y=0; y!=mMaxy; ++y)
  {
    for (int x=0; x!=mMaxx; ++x)
    {
      if (mBlocks[x][y] != NoPlayer)
      {
        if (y >= 1)
        {
          if (mBlocks[x][y-1] == NoPlayer)
          {
            GameMove move;
            move.x = x;
            move.y = y-1;
            move.anti = mBlocks[x][y];
            assert(IsValidMove(move));
            moves.push_back(move);
          }
        }
        if (y < mMaxy-1)
        {
          if (mBlocks[x][y+1] == NoPlayer)
          {
            GameMove move;
            move.x = x;
            move.y = y+1;
            move.anti = mBlocks[x][y];
            assert(IsValidMove(move));
            moves.push_back(move);
          }
        }
        if (x >= 1)
        {
          if (mBlocks[x-1][y] == NoPlayer)
          {
            GameMove move;
            move.x = x-1;
            move.y = y;
            move.anti = mBlocks[x][y];
            assert(IsValidMove(move));
            moves.push_back(move);
          }
        }
        if (x < mMaxx-1)
        {
          if (mBlocks[x+1][y] == NoPlayer)
          {
            GameMove move;
            move.x = x+1;
            move.y = y;
            move.anti = mBlocks[x][y];
            assert(IsValidMove(move));
            moves.push_back(move);
          }
        }
      }
    }
  }
  const int nMoves = moves.size();
  if (nMoves == 0) return;

  { //Get moves anti-player
    std::vector<GameMove> antiPlayerMoves;
    for (int i=0; i<nMoves; ++i)
    {
      if (IsRobot(moves[i].anti) == false) antiPlayerMoves.push_back(moves[i]);
    }
    //If there are anti-player moves, choose one at random
    if (antiPlayerMoves.empty()==false)
    {
      const int nAntiPlayerMoves = antiPlayerMoves.size();
      const int index = std::rand() % nAntiPlayerMoves;
      xMove = antiPlayerMoves[index].x;
      yMove = antiPlayerMoves[index].y;
      assert(IsValidMove(antiPlayerMoves[index]));
      return;
    }
  }
  { //Get moves anti-next-player
    std::vector<GameMove> antiNextPlayerMoves;
    for (int i=0; i<nMoves; ++i)
    {
      if (GetNextPlayer(mPlayer) == moves[i].anti) antiNextPlayerMoves.push_back(moves[i]);
    }
    //If there are anti-next-player moves, choose one at random
    if (antiNextPlayerMoves.empty()==false)
    {
      const int nAntiNextPlayerMoves = antiNextPlayerMoves.size();
      const int index = std::rand() % nAntiNextPlayerMoves;
      xMove = antiNextPlayerMoves[index].x;
      yMove = antiNextPlayerMoves[index].y;
      assert(IsValidMove(antiNextPlayerMoves[index]));
      return;
    }
  }
  //Choose a move at random
  {
    const int index = std::rand() % nMoves;
    xMove = moves[index].x;
    yMove = moves[index].y;
    assert(IsValidMove(xMove,yMove));
  }

}