Example #1
0
std::string DecoratedMoveList::print() const {
	std::stringstream ss;
	std::string str("moves:");

	ss << "scores:";

	for (std::vector<DecoratedPosition *>::const_iterator it = begin(), end = this->end(); it != end; ++it) {
		str.append(" " + *(*it)->move_str());

		ss << " " << (*it)->score();
	}

	str.append("\n" + ss.str() + "\n" + move_stats() + "\n");

	return str;
}
Example #2
0
void AgentMCTS::search(double time, uint64_t max_runs, int verbose){
	Side toplay = rootboard.toplay();

	if(rootboard.won() >= Outcome::DRAW || (time <= 0 && max_runs == 0))
		return;

	Time starttime;

	pool.pause();

	if(runs)
		logerr("Pondered " + to_str(runs) + " runs\n");

	runs = 0;
	maxruns = max_runs;
	pool.reset();

	//let them run!
	pool.resume();

	pool.wait_pause(time);

	double time_used = Time() - starttime;


	if(verbose){
		DepthStats gamelen, treelen;
		double times[4] = {0,0,0,0};
		for(auto & t : pool){
			gamelen += t->gamelen;
			treelen += t->treelen;

			for(int a = 0; a < 4; a++)
				times[a] += t->times[a];
		}

		logerr("Finished:    " + to_str(runs) + " runs in " + to_str(time_used*1000, 0) + " msec: " + to_str(runs/time_used, 0) + " Games/s\n");
		if(runs > 0){
			logerr("Game length: " + gamelen.to_s() + "\n");
			logerr("Tree depth:  " + treelen.to_s() + "\n");
			if(profile)
				logerr("Times:       " + to_str(times[0], 3) + ", " + to_str(times[1], 3) + ", " + to_str(times[2], 3) + ", " + to_str(times[3], 3) + "\n");
		}

		if(root.outcome != Outcome::UNKNOWN)
			logerr("Solved as a " + root.outcome.to_s_rel(toplay) + "\n");

		std::string pvstr;
		for(auto m : get_pv())
			pvstr += " " + m.to_s();
		logerr("PV:         " + pvstr + "\n");

		if(verbose >= 3 && !root.children.empty())
			logerr("Move stats:\n" + move_stats(vecmove()));
	}

	pool.reset();
	runs = 0;


	if(ponder && root.outcome < Outcome::DRAW)
		pool.resume();
}