当前位置: 首页>>代码示例>>C++>>正文


C++ MoveList::getNextMove方法代码示例

本文整理汇总了C++中MoveList::getNextMove方法的典型用法代码示例。如果您正苦于以下问题:C++ MoveList::getNextMove方法的具体用法?C++ MoveList::getNextMove怎么用?C++ MoveList::getNextMove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MoveList的用法示例。


在下文中一共展示了MoveList::getNextMove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: play


//.........这里部分代码省略.........
							if (delay >= 50)
								::Sleep(150);
							else
								::Sleep(150-(50-delay)*2);
						}
					}
				}

				board->clearLines(bestPiece.getY(), bestPiece.getHeight());
			}
		}

		cntPieces++;
		totalPieces++;
		
		if (bestMove > 0)
			totalSlided += bestMove->isSlided();

		// Log the moves
		if (wGameFile.isOpen())
		{
			wGameFile.writeShort(length);											// # Number of legal moves.
			wGameFile.writeByte(bestPiece.getV());						// # V
			wGameFile.writeShort(bestPiece.getX());						// # X
			wGameFile.writeShort(bestPiece.getY());						// # Y

			move = moveList->getFirstMove();

			while (move != 0)
			{																									// Move:
				wGameFile.writeByte(move->getV());							// # V
				wGameFile.writeShort(move->getX());							// # X
				wGameFile.writeShort(move->getY());							// # Y

				for (int i=preview; i<=level; i++)							// Equity (e.g):
					wGameFile.writeFloat(move->getEquity(i));			// L2, L3, L4

				move = moveList->getNextMove();
			}
		}

		if (preview > 1)
			pieces[0] = pieces[1];

  	int clearedLines = bestPiece.getClearedLines();

  	if (bestMove == 0) 
		{
  		games++;
  		
			linesPerGame = totalLines/games;
		}
		else
		{
			cntLines += clearedLines;
			totalLines += clearedLines;

			cntBlock += 4 - clearedLines * board->getWidth();

			if (DEBUG == 0)
			{
				int xxx = cntBlock/4;
				if (xxx < maxCntblockstat)
					cntblockstat[xxx]++;
			}
		}

  	if (cntLines > maxLines)
  		maxLines = cntLines;

		if (bestMove == 0)
		{
  		if (cntLines < minLines || minLines==-1)
  			minLines = cntLines;
			
			cntBlock = 0;
			cntPieces = 0;
  		cntLines = 0;
		  board->clear();
			pieces[0] = random.getRandomP();
		}
	}

	delete board;
	delete player;

	if (wGameFile.isOpen())
	{
		wGameFile.writeByte(END_PIECE);				// # Piece
		wGameFile.close();
	}

	if (rGameFile.isOpen() && strlen(gameSettings->getWhtmlFilename()) > 0)
	{
		readGame(maxp, size);
		rGameFile.close();
	}

	gameSettings->setExit(2);
}
开发者ID:tengstrand,项目名称:tetrisanalyzer,代码行数:101,代码来源:Game.cpp

示例2: readGame


//.........这里部分代码省略.........

		while (length-- > 0)
		{
			int v = rGameFile.readByte();				// # V
			int x = rGameFile.readShort();			// # X
			int y = rGameFile.readShort();			// # Y

			Move *move = moveList->getMove();
			moveList->add(v, x, y);

			for (int i=preview; i<=level; i++)	// Equity (e.g):
			{
				double equity = rGameFile.readFloat();		// L2, L3, L4

				move->setEquity(i, equity);
			}
		}

		moveList->sort();

		int movecnt = 0;
		Move *move = moveList->getFirstMove();

		int first[MAX_LEVELS+1];
		float bestEquity[MAX_LEVELS+1];

		if (move != 0)
		{
			for (int i=preview; i<=level; i++)
			{
				first[i] = 1;
				bestEquity[i] = (float)moveList->getBestEquity(i);
			}
		}

		// 2. Equity list list
		while (move != 0)
		{
			movecnt++;

			if (movecnt > height/2)
				break;

			int v = move->getV();
			int x = move->getX();
			int y = move->getY();

			wHtml << "          <tr>\n"
				    << "            <td align=right><font face=Arial size=1>"
						<< movecnt << ".</font></td>\n"
						<< "            <td align=right><font face=Arial size=1>"
						<< v << x << "</font></td>\n";

			for (int i=level; i>=preview; i--)	// Equity (e.g):
			{
				char equityBuf[20];
				float equity = move->getEquity(i);

				if (equity == 0)
					strcpy(equityBuf, "-");
				else
				{
					if (equity == bestEquity[i] && first[i])
					{
						first[i] = 0;
						sprintf(equityBuf, "%.3f", equity);
					}
					else
						sprintf(equityBuf, "+%.3f", equity-bestEquity[i]);
				}

				wHtml << "            <td align=right><font face=Arial size=1>" << equityBuf << "</font></td>\n";
			}

			wHtml << "          </tr>\n";

			move = moveList->getNextMove();
		}

		wHtml	<< "        </table>\n"
		    	<< "      </td>\n"
		    	<< "    </tr>\n";

		piece.setPiece(pieceV, pieceX, pieceY);
		
		board.clearLines(pieceY, piece.getHeight());
		htmlBoard.copyWithWalls(&board, preview-1);

		piece1 = piece2;
		piece2 = rGameFile.readByte();				// # Piece (byte)
		cntmove++;

		if (maxp > 0 && cntmove >= maxp)
			break;
	}

	wHtml	<< "  </table>\n"
				<< "</body>\n"
				<< "</html>\n";
}
开发者ID:tengstrand,项目名称:tetrisanalyzer,代码行数:101,代码来源:Game.cpp


注:本文中的MoveList::getNextMove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。