-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Utility function for distance to stones and GTP command to show distance
git-svn-id: svn://svn.code.sf.net/p/fuego/code/trunk@2003 2e953b5c-c64d-0410-be54-f773e93e544c
- Loading branch information
mmueller65
committed
Aug 16, 2015
1 parent
2535474
commit a16d52f
Showing
5 changed files
with
145 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//---------------------------------------------------------------------------- | ||
/** @file GoInfluenceTest.cpp | ||
Unit tests for GoInfluence. */ | ||
//---------------------------------------------------------------------------- | ||
|
||
#include "SgSystem.h" | ||
|
||
#include <boost/test/auto_unit_test.hpp> | ||
#include "GoInfluence.h" | ||
|
||
#include "GoSetupUtil.h" | ||
|
||
using SgPointUtil::Pt; | ||
|
||
//---------------------------------------------------------------------------- | ||
|
||
namespace { | ||
|
||
//---------------------------------------------------------------------------- | ||
|
||
BOOST_AUTO_TEST_CASE(GoInfluenceTest_Distance_Black) | ||
{ | ||
std::string s(". . . .\n" | ||
". . . .\n" | ||
". . X .\n" | ||
". . . .\n"); | ||
int boardSize; | ||
GoSetup setup = GoSetupUtil::CreateSetupFromString(s, boardSize); | ||
GoBoard bd(boardSize, setup); | ||
SgPointArray<int> distance; | ||
GoInfluence::FindDistanceToStones(bd, SG_BLACK, distance); | ||
BOOST_CHECK_EQUAL(distance[Pt(3, 2)], 0); | ||
BOOST_CHECK_EQUAL(distance[Pt(2, 2)], 1); | ||
BOOST_CHECK_EQUAL(distance[Pt(3, 1)], 1); | ||
BOOST_CHECK_EQUAL(distance[Pt(3, 3)], 1); | ||
BOOST_CHECK_EQUAL(distance[Pt(1, 3)], 3); | ||
BOOST_CHECK_EQUAL(distance[Pt(1, 4)], 4); | ||
BOOST_CHECK_EQUAL(distance[Pt(4, 3)], 2); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(GoInfluenceTest_Distance_White) | ||
{ | ||
std::string s(". . . .\n" | ||
". . . .\n" | ||
". . . .\n" | ||
". . . O\n"); | ||
int boardSize; | ||
GoSetup setup = GoSetupUtil::CreateSetupFromString(s, boardSize); | ||
GoBoard bd(boardSize, setup); | ||
SgPointArray<int> distance; | ||
GoInfluence::FindDistanceToStones(bd, SG_WHITE, distance); | ||
BOOST_CHECK_EQUAL(distance[Pt(4, 1)], 0); | ||
BOOST_CHECK_EQUAL(distance[Pt(4, 2)], 1); | ||
BOOST_CHECK_EQUAL(distance[Pt(3, 1)], 1); | ||
BOOST_CHECK_EQUAL(distance[Pt(3, 2)], 2); | ||
BOOST_CHECK_EQUAL(distance[Pt(1, 3)], 5); | ||
BOOST_CHECK_EQUAL(distance[Pt(1, 4)], 6); | ||
BOOST_CHECK_EQUAL(distance[Pt(4, 3)], 2); | ||
} | ||
|
||
//---------------------------------------------------------------------------- | ||
|
||
} // namespace |