Beispiel #1
0
void GraphicalReporter::reportGame(const Quackle::Game &game, Quackle::ComputerPlayer *computerPlayer)
{
	reportHeader(game);

	for (Quackle::PositionList::const_iterator it = game.history().begin(); it != game.history().end(); ++it)
	{
		reportPosition(*it, computerPlayer);
	}
}
Beispiel #2
0
void testEndgame(Quackle::Game &game)
{
	// dataManager.setEvaluator(new Quackle::CatchallEvaluator());

	const int playahead = 20;
	for (int i = 0; i < playahead; ++i)
	{
		if (game.currentPosition().gameOver())
			break;
		Quackle::Move compMove(game.haveComputerPlay());
	}
}
Beispiel #3
0
void testAdvanceToEnd(Quackle::Game &game)
{
	UVcout << "now advancing to end..." << endl;

	game.advanceToNoncomputerPlayer();

	UVcout << game.currentPosition();

	Quackle::PlayerList winners(game.currentPosition().leadingPlayers());
	for (Quackle::PlayerList::const_iterator it = winners.begin(); it != winners.end(); ++it)
		UVcout << *it << " wins!!" << endl;
}
Beispiel #4
0
void testSimulation(Quackle::Game &game)
{
	const int kibitzLength = 3;
	game.currentPosition().kibitz(kibitzLength);

	//UVcout << game.currentPosition() << endl;
	UVcout << game.currentPosition().moves() << endl;

	Quackle::Simulator simulator;
	simulator.setLogfile("quackletest.simulation", false);
	simulator.setPosition(game.currentPosition());

	simulator.simulate(20, 5);
	UVcout << simulator.simmedMoves() << endl;
	UVcout << "after " << simulator.iterations() << " iterations pruning to those within five points" << endl;

	simulator.pruneTo(5, kibitzLength);

	int iterationStep = 1;
	int iterationsToRun = 2;

	const bool longSim = true;
	if (longSim)
	{
		iterationStep = 10;
		iterationsToRun = 50;
	}

	const int plies = 2;

	simulator.setIgnoreOppos(false);

	for (int iterations = 0; iterations < iterationsToRun; iterations += iterationStep)
	{
		simulator.simulate(plies, iterationStep);
		UVcout << "sim results after " << iterations + iterationStep << " iterations: " << endl;

		const Quackle::SimmedMoveList &moves = simulator.simmedMoves();

		for (Quackle::SimmedMoveList::const_iterator it = moves.begin(); it != moves.end(); ++it)
		{
			UVcout << *it << endl;
		}

		UVcout << endl;
	}
}
Beispiel #5
0
void testValidator(Quackle::Game &game)
{
	game.commitMove(Quackle::Move::createPlaceMove(MARK_UV("8d"), QUACKLE_ALPHABET_PARAMETERS->encode(MARK_UV("MANIA"))));
	game.commitMove(Quackle::Move::createPlaceMove(MARK_UV("7c"), QUACKLE_ALPHABET_PARAMETERS->encode(MARK_UV("RANI"))));
	game.commitMove(Quackle::Move::createPlaceMove(MARK_UV("f6"), QUACKLE_ALPHABET_PARAMETERS->encode(MARK_UV("P..ION"))));
	game.commitMove(Quackle::Move::createPlaceMove(MARK_UV("10b"), QUACKLE_ALPHABET_PARAMETERS->encode(MARK_UV("STAT.R"))));
	game.currentPosition().setCurrentPlayerRack(Quackle::Rack(QUACKLE_ALPHABET_PARAMETERS->encode(MARK_UV("AIAIAIAI"))));

	UVcout << game.currentPosition().board().allWordsFormedBy(Quackle::Move::createPlaceMove(MARK_UV("9c"), QUACKLE_ALPHABET_PARAMETERS->encode(MARK_UV("AI"))));
}
Beispiel #6
0
void testBag(Quackle::Game &game)
{
	UVcout << "BAG TEST" << endl;
	UVcout << "current player rack: " << game.currentPosition().currentPlayer().rack() << endl;
	game.currentPosition().setCurrentPlayerRack(Quackle::Rack(QUACKLE_ALPHABET_PARAMETERS->encode(MARK_UV("AAAAAAA"))));
	UVcout << "current player rack set to: " << game.currentPosition().currentPlayer().rack() << endl;
	UVcout << "current bag now " << game.currentPosition().bag() << endl;
	game.commitMove(Quackle::Move::createPlaceMove(MARK_UV("8d"), QUACKLE_ALPHABET_PARAMETERS->encode(MARK_UV("PEAFOwL"))));
	UVcout << "current bag after PEAFOwL " << game.currentPosition().bag() << endl;
}
Beispiel #7
0
void testGame()
{
	Quackle::Game game;

	Quackle::PlayerList players;

	Quackle::Player bogowinA(MARK_UV("BogowinA"), Quackle::Player::ComputerPlayerType, 110);
	bogowinA.setComputerPlayer(new Quackle::SmartBogowin());
	players.push_back(bogowinA);
	
	Quackle::Player bogowinB(MARK_UV("BogowinB"), Quackle::Player::ComputerPlayerType, 110);
	bogowinB.setComputerPlayer(new Quackle::SmartBogowin());
	players.push_back(bogowinB);

	game.setPlayers(players);
	game.associateKnownComputerPlayers();

	game.addPosition();

	//testValidator(game);

	const bool setupRetroPosition = false;

	if (setupRetroPosition)
	{
		game.commitMove(Quackle::Move::createPlaceMove(MARK_UV("8c"), QUACKLE_ALPHABET_PARAMETERS->encode(MARK_UV("AMNION"))));
		game.currentPosition().setCurrentPlayerRack(Quackle::Rack(QUACKLE_ALPHABET_PARAMETERS->encode(MARK_UV("L"))));
		UVcout << "current rack: " << game.currentPosition().currentPlayer().rack() << endl;
		game.currentPosition().kibitz(10);
		UVcout << "moves: " << endl << game.currentPosition().moves() << endl;
	}

	const int playahead = 50;

	for (int i = 0; i < playahead; ++i)
	{
		if (game.currentPosition().gameOver())
		{
			UVcout << "GAME OVER" << endl;
			break;
		}

		const Quackle::Player player(game.currentPosition().currentPlayer());
		Quackle::Move compMove(game.haveComputerPlay());
		UVcout << "with " << player.rack() << ", " << player.name() << " commits to " << compMove << endl;
	}

	UVcout << game.currentPosition() << endl;

	testGameReport(game);

	// insert test...() calls here
	// testSimulation(game);
	
	//UVcout << "History:" << endl << game.history() << endl;
}
Beispiel #8
0
void GraphicalReporter::reportHeader(const Quackle::Game &game)
{
	openIndex();
	m_indexStream << kHtmlHeader;
	m_indexStream << QuackleIO::Util::uvStringToQString(game.currentPosition().board().htmlKey());
}