From 196b54fea3a0264b1fc9ad952e55a9e20d93ceb3 Mon Sep 17 00:00:00 2001 From: Jeffrey Sander Date: Fri, 23 Feb 2018 15:53:53 -0500 Subject: [PATCH 1/6] go-counting: Add single-territory function to README All implementing tracks have this function, but it is never mentioned. https://github.com/exercism/problem-specifications/pull/1195 --- exercises/go-counting/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/exercises/go-counting/README.md b/exercises/go-counting/README.md index 3b8f64733..a72381033 100644 --- a/exercises/go-counting/README.md +++ b/exercises/go-counting/README.md @@ -11,6 +11,8 @@ Write a function that determines the territory of each player. You may assume that any stones that have been stranded in enemy territory have already been taken off the board. +Write a function that determines the territory which includes a specified coordinate. + Multiple empty intersections may be encircled at once and for encircling only horizontal and vertical neighbours count. In the following diagram the stones which matter are marked "O" and the stones that don't are From e4893da351cc0f9f7b19a04a1b98ab25ae191210 Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Sun, 18 Mar 2018 20:25:00 +0000 Subject: [PATCH 2/6] go-counting 1.0.0.3: Remove 9x9 board I did not consider this to provide any additional value. I asked for this to be removed in https://github.com/exercism/problem-specifications/pull/1195#discussion_r170791157 --- exercises/go-counting/test/Tests.hs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/exercises/go-counting/test/Tests.hs b/exercises/go-counting/test/Tests.hs index 299d96153..266fab224 100644 --- a/exercises/go-counting/test/Tests.hs +++ b/exercises/go-counting/test/Tests.hs @@ -19,16 +19,6 @@ specs = do , " W W " , " W " ] - board9x9 = [ " B B " - , "B B B" - , "WBBBWBBBW" - , "W W W W W" - , " " - , " W W W W " - , "B B B B" - , " W BBB W " - , " B B " ] - shouldHaveTerritories = shouldMatchList . map (first toAscList) . territories @@ -81,6 +71,3 @@ specs = do it "5x5 non-territory (too high coordinate)" $ territoryIn board5x5 (2, 6) `shouldBe` Nothing - it "9x9 score" $ - board9x9 `shouldScore` [ (Nothing , 33) - , (Just Black, 14) ] From a2e8443ab23a0564260744da8224b388787e2fab Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Sun, 18 Mar 2018 20:26:02 +0000 Subject: [PATCH 3/6] go-counting 1.0.0.3: Test two territories of same player I requested this be added in https://github.com/exercism/problem-specifications/pull/1195#pullrequestreview-99526421 There was an implicit test of this in the 5x5 board, but we'll start small. Note that this track deliberately does not change `territories` to be a map mapping a player to all of their territories, instead keeping it an array of all separate contiguous regions. This is because I (as the track maintainer) believe that keeping it an array provides better fidelity of the board and helps ensure that implementations are doing the right thing. --- exercises/go-counting/test/Tests.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/exercises/go-counting/test/Tests.hs b/exercises/go-counting/test/Tests.hs index 266fab224..239fd65bd 100644 --- a/exercises/go-counting/test/Tests.hs +++ b/exercises/go-counting/test/Tests.hs @@ -44,6 +44,10 @@ specs = do , ([ (4, 1) , (4, 2) ], Just White) ] + it "two territories of same player, rectangular board" $ + [ " B " ] `shouldHaveTerritories` [ ([ (1, 1) ], Just Black) + , ([ (3, 1) ], Just Black) ] + it "5x5 score" $ board5x5 `shouldScore` [ (Nothing , 9) , (Just Black, 6) From acbc64f3b36b2fe70f58a535b17a7abb252ef582 Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Sun, 18 Mar 2018 20:27:38 +0000 Subject: [PATCH 4/6] go-counting 1.0.0.3: Describe tests that do/do not border edge This seemed a significant distinction, so I requested it in https://github.com/exercism/problem-specifications/pull/1195#discussion_r170316193 --- exercises/go-counting/test/Tests.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/go-counting/test/Tests.hs b/exercises/go-counting/test/Tests.hs index 239fd65bd..e6f59af82 100644 --- a/exercises/go-counting/test/Tests.hs +++ b/exercises/go-counting/test/Tests.hs @@ -53,15 +53,15 @@ specs = do , (Just Black, 6) , (Just White, 1) ] - it "5x5 territory for black" $ + it "5x5 territory for black bordering edge" $ territoryIn board5x5 (1, 2) `shouldBe` Just ([ (1, 1) , (1, 2) , (2, 1) ], Just Black) - it "5x5 territory for white" $ + it "5x5 territory for white not bordering edge" $ territoryIn board5x5 (3, 4) `shouldBe` Just ([ (3, 4) ], Just White) - it "5x5 open territory" $ + it "5x5 open territory bordering edge" $ territoryIn board5x5 (2, 5) `shouldBe` Just ([ (1, 4) , (1, 5) , (2, 5) ], Nothing) From 333cd00f94c836e0404bd99af4d9be06a989abb0 Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Sun, 18 Mar 2018 20:28:45 +0000 Subject: [PATCH 5/6] go-counting 1.0.0.3: Test all (X, Y) too (high, low) This was requested in https://github.com/exercism/problem-specifications/commit/fa454689236c5bc25534cd6b4b7d7e66a18ed577#r27822802 --- exercises/go-counting/test/Tests.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/exercises/go-counting/test/Tests.hs b/exercises/go-counting/test/Tests.hs index e6f59af82..ed13b1a9a 100644 --- a/exercises/go-counting/test/Tests.hs +++ b/exercises/go-counting/test/Tests.hs @@ -69,9 +69,14 @@ specs = do it "5x5 non-territory (stone)" $ territoryIn board5x5 (2, 2) `shouldBe` Nothing - it "5x5 non-territory (too low coordinate)" $ + it "5x5 non-territory (X too low)" $ territoryIn board5x5 (0, 2) `shouldBe` Nothing - it "5x5 non-territory (too high coordinate)" $ - territoryIn board5x5 (2, 6) `shouldBe` Nothing + it "5x5 non-territory (X too high)" $ + territoryIn board5x5 (6, 2) `shouldBe` Nothing + + it "5x5 non-territory (Y too low)" $ + territoryIn board5x5 (2, 0) `shouldBe` Nothing + it "5x5 non-territory (Y too high)" $ + territoryIn board5x5 (2, 6) `shouldBe` Nothing From 05f95051e9cadf05543fb56fed7e07e8426ac1b9 Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Sun, 18 Mar 2018 20:31:37 +0000 Subject: [PATCH 6/6] go-counting 1.0.0.3 https://github.com/exercism/problem-specifications/pull/1195 Note that this track deliberately does not change `territories` to be a map mapping a player to all of their territories, instead keeping it an array of all separate contiguous regions. This is because I (as the track maintainer) believe that keeping it an array provides better fidelity of the board and helps ensure that implementations are doing the right thing. --- exercises/go-counting/package.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/go-counting/package.yaml b/exercises/go-counting/package.yaml index 32757375b..bdde4c926 100644 --- a/exercises/go-counting/package.yaml +++ b/exercises/go-counting/package.yaml @@ -1,5 +1,5 @@ name: go-counting -version: 0.1.0.2 +version: 1.0.0.3 dependencies: - base