コード例 #1
0
ファイル: util.cpp プロジェクト: Botyto/ai_project
	//Gives the first border that can be placed on the given cell
	border_names first_border(const board & board, const point & idx)
	{
		//Return the first free border
		auto bb = board.borders(idx);
		for (int i = borders_first; i < borders_count; ++i)
			if (!bb[i]) return (border_names)i;

		//No such border
		return none;
	}
コード例 #2
0
ファイル: util.cpp プロジェクト: Botyto/ai_project
	//Gives the first border that can close the given cell
	border_names closing_border(const board & board, const point & idx)
	{
		//Setup
		auto bb = board.borders(idx);
		border_names result = none;
		int closed_cnt = 0;

		//Count closed borders and find free borders
		for (int i = borders_first; i < borders_count; ++i)
			if (bb[i]) ++closed_cnt;
			else result = (border_names)i;

			//There must be 3 closed borders
			if (closed_cnt != 3)
				return none;

			return result;
	}
コード例 #3
0
ファイル: util.cpp プロジェクト: Botyto/ai_project
	//Get borders count
	int border_count(const board & board, const point & idx)
	{
		return border_count(board.borders(idx));
	}