---
title: "Stoned and Board"
url: "https://courses.osherove.com/courses/tdd-pairing-sessions-building-a-go-game/stoned-and-board.md"
canonical: "https://courses.osherove.com/courses/tdd-pairing-sessions-building-a-go-game/stoned-and-board/"
tags: []
author: "Roy Osherove"
description: "Lesson 3 of 11 in TDD Pairing Sessions - Building a Go Game (The Sessions), 30:14. Free video by Roy Osherove."
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Stoned and Board

1. [Courses](https://courses.osherove.com/#courses)
2. [TDD Pairing Sessions - Building a Go Game](https://courses.osherove.com/courses/tdd-pairing-sessions-building-a-go-game/)
3. The Sessions

Lesson 3 of 11

Duration: 30:14 [Watch on YouTube](https://www.youtube.com/watch?v=AIcaF7KahL0)

## In this lesson

The pair look for the [simplest test](https://osherove.com/blog/2010/1/6/tdd-4-questions-that-will-help-you-create-the-simplest-thing.html "TDD: 4 questions that will help you create the simplest thing that could possibly work (osherove.com)") that proves black can win, and the Excel file explains scoring: points for territory, a point lost per removed stone. They consider an event log for calculating the score, but choose a test that adds stones so black owns at least one cell. The laziest code, where the last stone added wins, passes, so a new test has white play last while black still wins.

## Transcript

3,414 words

[\[00:09\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=9s) Oh, well, it should fail first. >> Oh, fail. Okay. >> Okay. Alt R. Run all the tests. Let's see what happens. Okay. Failed. >> Now you can you can close this window with shift escape. This >> shift escape. >> Yeah, it closes tool windows. >> Nice. >> Okay. Okay, now let's make it pass. [Simplest way possible](https://osherove.com/blog/2010/1/6/tdd-4-questions-that-will-help-you-create-the-simplest-thing.html "TDD: 4 questions that will help you create the simplest thing that could possibly work (osherove.com)").

[\[00:40\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=40s) Okay, awesome. Obviously, that's good enough. We can move on, right? >> Right. >> No. What? >> No. >> I mean, would you leave the code this way, dude? >> no. >> No. Okay. I mean, it works assuming assumptions, right? The assumption we're making right now is that there are no moves, right? So, now we have to break that assumption. We can we need to say you can't assume there were no moves.

[\[01:13\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=73s) White will not always be the winner, right? >> Mhm. Great. >> So, now we have to basically say we have to prove that it's a bug that it always returns white. So now we have to make the simplest test that proves that there can be a black winner. >> Okay. >> Mhm. >> so how would you do that? >> the simplest way there's two ways. One is making a territory for black.

[\[01:45\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=105s) I think the other simplest way would be to remove a white stone like pretend it's captured and then basically that would be a minus one point for white. So, so I'm trying to understand can you put the Excel file again and and explain that to me? >> Okay. So if

[\[02:16\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=136s) One scenario would be basically if the komi for white is 0.5 >> but then white stones remove equals one. Then the white points the score for white equals0.5 where black would be

[\[02:53\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=173s) Black to remove is always zero. Well, if we set it up for where we just remove one white stone, but we did not remove any black stone. >> No, but somewhere in the middle of the game, I remove a black stone. >> It's still zero for the black. >> No. Yeah. I mean, if >> So, this is all just for the initial move. >> Yeah, that's what I meant. Just to get just to get black to be the winner. >> Initial points, right? That's what it this means. Well, we there's no real initial move like I mean to the the way a player can actually make this happen is surrounding a white stone.

[\[03:38\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=218s) The scenario would be black like if there's a white then when there's a black that's how we get how >> so the only way to get any points is to surround someone and the only way to lose point to lose points is to be surrounded that's the only way >> you don't get points >> the other way is the amount of territories but that is calculated at the end of the game >> right So the the territories would be for black would be one.

[\[04:09\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=249s) So it's also >> so I'm just trying to understand because this is interesting. This would be one black territory. >> Well, it's actually a little bit more complicated than that because of the the boundaries. If there was boundaries then the sides would be I mean if we consider it more like there's a white stone outside the boundary. >> Yeah. Then only only inside here would be black territory and that would be 1 one.

[\[04:42\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=282s) >> Might be easier if I >> draw a boundary >> because what I'm trying to say is that we can we can write this test this initial test from three different angles. Right. >> Right. We can have a test that says white we can have a test that says black surrounds white, >> right? >> And then black is the winner.

[\[05:13\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=313s) We can have another test. We probably need to have each one of them anyway, right? >> Another test that says white stone removed. Can we just have a test that says white stone removed and not black stone surrounded? >> I mean, you don't do you get positive points or do you always get just negative points? That's what I'm saying. >> So, the positive points is so the basic example would be if I had black at this corner and like let's say there's white stones outside.

[\[05:48\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=348s) This right here would be considered a black would be part of black. >> Okay. So just let's Yeah. No, that would be a black like this actually. >> Yeah, right. >> And is there a white territory here somewhere? >> Sean, >> is there white territory as well here? >> Well, no, because there's no established boundaries. But actually, maybe a better one then would be white.

[\[06:18\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=378s) White. So this is white and then everything else is neutral. So let's make this gray. Oh, that's not very good color. Let's call it green. What's a neutral color? Ah, that's a neutral color. Okay, that would be neutral. This would be white. Let's give it What's >> Just use white. It makes sense. >> All right. If that makes sense.

[\[06:49\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=409s) So, this would be white. >> Mhm. So this would be a one point for white, one point for black. >> So there is a way to get the positive points. Okay. So now just to make sure we have ways to get points and lose points. >> So point plus point plus point for each

[\[07:21\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=441s) Established >> territory. >> Territory. Okay. Oh, of course I said plus. I said equals. Plus equals. Great. >> no. I didn't like the pluses. Add points. >> Okay. And >> minus point for each remove stone.

[\[07:52\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=472s) >> Minus point for surrounded and removed stone. >> That's it. >> Yep. >> Yeah. >> Okay. So, which one do you want to do? >> maybe the easiest one would be I don't know. They both seem pretty one. Well, the the removing a stone one, the easy one would be we just remove one.

[\[08:24\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=504s) Pretend the user had removed one without actually setting up the board and interacting with the board. >> How do you remove one? >> If we just say board remove stone, a white stone somewhere, then we can say think we just minus one white stone. And then we just calculate the score from that. >> Is that a valid test? That's what I was wondering. >> so, so write the test to show me.

[\[08:55\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=535s) >> So I just saying >> no, just write the test in the code. I mean, >> okay. >> So he does bring in interesting parts cuz I think what you're trying to do is to say, let's not actually do the moves. Let's just tell the board what happened. Right. Right. So, determine winner

[\[09:34\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=574s) One remove white stone. Zero remove black stone. Effective behavior Black. >> Black wins. >> Yeah. >> Can just say black wins. Yep. >> Yeah. Okay. >> Okay. So, search equal

[\[10:53\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=653s) >> but you know we already do remove stones from position right >> did we >> we already implemented that >> we just do we just don't have a public method for it >> because you can't remove a stone for position everything is just built into the board right now, >> right? >> Okay. >> Mhm. So maybe the best way would be without introducing another public method, the best way would be

[\[11:24\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=684s) Actually just creating territories then. >> Well, you can create a situation where a stone will be removed. >> Yeah. Right. Right. >> Right. We can't do that, right? >> however, you know what I'm thinking now is that it would be cool if we had a class that we could just say points calculator or something like that. >> Mhm. >> Or board point calculator

[\[11:57\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=717s) Where we would say stone removed from. So we could just basically tell it the play by plays. >> Okay. >> Because then what happens is that you can actually simulate the moves without actually doing them, right? >> Mhm. >> So for example, you can say territories one for black three. See what I mean?

[\[12:28\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=748s) So we have >> so so I so what I'm saying is that it would be cool to be able to do this for example board dot calculator or you know what we can just say zen log then we would say stone Stone removed

[\[13:07\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=787s) Stone color white. Mhm. >> Okay. Now, the event log is basically just an event log of what happened. You don't have to actually do it. >> Mhm. Okay. Wow. >> And the event log can be used to calculate the score. That's that would be a way to do it. And then you can just say, you know what, we don't need a board. We just need an event log to calculate the current score. >> Okay. Okay.

[\[13:37\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=817s) >> What do you think? >> It's just a thought, of course. Could be horribly wrong, but let's go with it. >> what else? There are other ways to think about it. We can we can actually say board something got removed. But that would be too much responsibility for the board. I think it's not simple. I'm trying to just think if this is simple or not.

[\[14:11\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=851s) So you want to just create maybe a territory. I don't know if that will be readable, but we still have to start with something. So I'm kind of you know I'm kind of in between here because in a way what I'd like to do is I'd like to simulate in the test I mean we have two we have two layers where we can test it. We have the actual game layer where we simulate a game as if it was played >> right? So you can say the game was played this way and everything should have been already calculated somehow and the winner would have been black.

[\[14:47\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=887s) >> Yep. >> Okay. Which is kind of what we did up until now where we would say the position status would have been calculated etc. Right. >> Mhm. Right. And then instead of having an event log, we would just say board dot add stone to position like >> one and one or actually one and two and the the stone color. >> Mhm. Actually >> the colors first.

[\[15:23\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=923s) >> Yeah. Stone color. White to one and two and to one to to one. Okay. So that would be somewhere like that. All right. But we want to make it black because we're trying to get a black winner, right?

[\[15:55\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=955s) >> Sure. >> And also going to F2.

[\[16:28\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=988s) Just going to try to make it a bit shorter. >> Okay. And then we would have a winner of black as well. Yep. >> What do you think? >> Yes. >> I agree.

[\[17:10\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1030s) Nope. Shift space. Nope, that's not it. This >> Mhm. >> Yeah. >> Okay. So to me, this feels more like a real game where we can do an end to end almost test of the engine. >> Say this is what a winner. This is the simplest example of a winner.

[\[17:45\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1065s) >> Yeah. >> And it feels less like cheating. I don't know. I mean, I think that definitely maybe towards later we will have our test will become much more complicated and we will have to resort to like event logs type ways of what actually happened, >> right? But right now, I mean, this this looks much much simpler to me, >> right? >> And then later, I mean, after that, we can refactor to an event log or whatever we want.

[\[18:16\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1096s) >> What do you think? >> I agree. I agree. >> Okay. >> This does definitely feel less like cheating. >> Okay. And it's important that sometimes you also disagree with me. Okay. >> You can't just agree with me all the time. Do you agree? >> Gotcha. Okay. I agree. >> Okay. Okay. Alt R. Let's see what happens. >> So, we should probably rename the test. >>

[\[18:46\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1126s) Determine a winner by default because of komi. Determine winner. One removed white stone. Yeah, I agree. I agreed. One do we call it a territory or one stone? one one cube maybe. How do you call one of the cells? >> Let's let's call it >> what about this >> black black only territories? >> Yeah, but territory is too long to write in a [test name](https://osherove.com/blog/2005/4/3/naming-standards-for-unit-tests.html "Naming standards for unit tests (osherove.com)").

[\[19:17\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1157s) >> See one cell, one for black. The thing is >> Yeah. >> because there are other the rest of the board and there's no white stones. the the rest of the board is considered owned by black. Do you know what I mean? Like going back to the Excel sheet-c if there because so if there was no white stones right here >> Mhm.

[\[19:47\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1187s) >> everything would be considered part of black. Oops. Hold on. Hold on. I have to clean my disc. >> Okay. So, you were saying >> Okay. So, I was saying if there was no white stones available, it would all these would be considered

[\[20:18\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1218s) Black. So, all the black would be considered black territories. >> And when would they not be considered black? So, if I put in a white stone in here, let's make this white. >> All these because there's no determined winner of these territories. They would all be neutral. >> Yeah, but it they're both the black is a winner either way, right? >> Yeah, black is a winner either way. >> So, that's just another scenario,

[\[20:49\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1249s) >> right? So we can add that to unetermined versus well undetermined versus default to a color areas. What do you think? undetermined versus determined might be better or just name undetermined terms. >> But well there is one there is

[\[21:22\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1282s) One versus neutral. >> Yeah. >> Versus defaults to a color. How's that? >> I'm not sure what you mean by defaults to a color. >> as you said, if there is no white, everything else defaults to black. Right? Because black owns owns the other black basically won the rest of the territory because if you look at it in the other way, black surrounded everything else.

[\[21:52\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1312s) >> Uhhuh. So so Uhhuh. Okay, I understand. So surrounding we can say that surrounding can go from either side cuz I think that's just another >> scenario here actually >> right >> so we would say surround from outer

[\[22:22\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1342s) Side as well >> so we would have an edge an edge. An edge and we have like a black and a black and one something like that. >> Right. >> Okay. >> But that's we're not there yet.

[\[22:54\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1374s) >> Right. You're thinking too much about the future. What did I just do? Okay. >> Well, the thing the reason I mentioned it was because for your for your naming of the game, you said one cell one for black. That's why I was a little hesitant about >> Okay. >> the naming. >> determine winner. So, how do would you describe that scenario? >> black black territories. Maybe >> what if we said at least one cell?

[\[23:28\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1408s) >> That that's that's fine. That's fine. At least one cell. Yeah, >> because then it doesn't break the future. >> Yeah. >> Okay, cool. >> so now let's make it pass in the simplest way possible. Let's just make sure we're still there, right? >> Okay. Expect black, but was white. Awesome. How do we make this pass in the simplest way?

[\[23:58\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1438s) >> That's what I was wondering too. >> Well, we can basically say that if I was the world's laziest developer, I would just say that whoever added the stone last is the winner because that's the only place we check. >> That would be the laziest implementation. Yes, >> probably the most incorrect, but yeah, >> it's not incorrect if the test passes, my friend. >> And if it's incorrect, you just have to prove it.

[\[24:28\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1468s) >> All right. >> where is the ad stone? Where is it? >> Right there. >> Okay. So, when I say simple, I usually mean at the beginning of the method is always simpler than down later in the method because you don't have to go through logic to do it. >> Mhm. And you don't have and and if it's indented it's less it's more complicated than if it's not indented. So it's inside ifs or loops it's more complicated than without. >> Right? >> Okay. So the way I would say it is that I would just say

[\[25:02\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1502s) Current winner equals stone color. I'm going to just say alt enter create a field and >> default it as white. >> Yep. I will return current winner.

[\[25:43\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1543s) Still color white. Alt R. Yep. Congratulations. We have a feature. It's a boy. You don't like it, do something. >> So, in would you suggest we write another test to prove that wrong in order to refactor it? >> Well, we can have a Yeah, basically we have to prove well. Well, the first rule of [TDD](https://livebook.manning.com/book/the-art-of-unit-testing-third-edition/chapter-1#sigil_toc_id_27 "Test-driven development (The Art of Unit Testing, 3rd ed., ch. 1)") is you don't write a line of production code without a failing test, >> right? >> You we don't have a failing test.

[\[26:13\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1573s) If you want to change it, you have to have something failing. >> Okay. But everything is already passing. So you you can write a new test if you want. >> What do you think? >> I think we basically have the same test. >> Okay. >> But add Well, we could actually take the same test. Yeah, we can do it as a test case. >> We would you want to do a different test case or same test case? >> We can do a test case attribute on the current test.

[\[26:45\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1605s) >> Test case attribute. Have you have you used it? >> Oh, you Yes, I know what you're talking about. So, instead of making it add black stones, we make it add white stones. >> Exactly. >> No, that's >> Yeah. Yeah. >> But that that's not going to make it fail because it the expected winner is going to be white. The expected winner is going to be white. And well, let's see because I'm not sure. I think it will fail. >> Okay.

[\[27:19\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1639s) >> It will fail if we have Yeah. Yeah. I I agree. It will fail based on it will it will pass because it's based on the last ad stone. So if we make the last ad stone black, but the winner will be white, >> the test should fail. Right. >> Right. So, I was saying that in order to make this test fail >> Mhm. >> and we just add add stone white in some random position. Or actually, you could even have the black in the black territory area.

[\[27:50\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1670s) Actually, no, that's not right. >> All we need is that the black should be winning, but white plays last. >> Black should still win. That's all we're saying right now. >> Yeah. So, basically, white places a stone anywhere outside of that corner. >> Exactly.

[\[28:27\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1707s) Stone color white to four. Yeah, >> we can also do three, right? >> Yeah. >> Okay. I don't want to go like crazy. Just just below it because it's important that there are no questions about the [readability](https://livebook.manning.com/book/the-art-of-unit-testing-third-edition/chapter-9 "Readability (The Art of Unit Testing, 3rd ed., ch. 9)") of this. So someone say why is it 17 or something, >> right? >> Okay. Okay. So black should still win. Let's see. Alt R.

[\[28:59\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1739s) Okay. So now let's see what we can do. It's not just the latest. We actually have to start keeping score right now. Right. >> Right. >> Okay. >> Count territories. Right. >> Okay. Simplest calculations, simplest everything that will make everything pass. You want to try? >> All right. >> Just imagine you're the laziest developer in the world. You have to go home five minutes. What do you do? Just make as long as you can make everything pass.

[\[29:36\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1776s) All right. Gosh. Well, the simplest would be to to check if this position right here is surrounded and what color it's surrounded by. >> Cool. Yeah, that would be cool. I like it. >> Okay.

[\[30:08\]](https://www.youtube.com/watch?v=AIcaF7KahL0&t=1808s) Don't you just return whatever the color is returned from that position? The positions next to it and above it, right?

## Related

- [TDD: 4 questions that will help you create the simplest thing that could possibly work](https://osherove.com/blog/2010/1/6/tdd-4-questions-that-will-help-you-create-the-simplest-thing.html) · osherove.com

    Four questions for finding the simplest thing that could possibly work, as the pair pick the laziest passing code.

- [Measuring Simplicity in TDD](https://osherove.com/blog/2011/1/20/measuring-simplicity-in-tdd.html) · osherove.com

    Discusses priorities for code changes driven by a failing test, the step from the lazy last-stone rule to real logic.

- [Test-driven development](https://livebook.manning.com/book/the-art-of-unit-testing-third-edition/chapter-1#sigil_toc_id_27) · The Art of Unit Testing, 3rd ed., ch. 1

    Book section on test-driven development, the test-first loop of simple test, lazy code and a new forcing test shown here.

### Also linked in this lesson

#### The Art of Unit Testing, 3rd ed.

- [Readability](https://livebook.manning.com/book/the-art-of-unit-testing-third-edition/chapter-9), ch. 9

#### osherove.com

- [Naming standards for unit tests](https://osherove.com/blog/2005/4/3/naming-standards-for-unit-tests.html)

[Previous lesson Mapping Moves](https://courses.osherove.com/courses/tdd-pairing-sessions-building-a-go-game/mapping-moves/) [Next lesson Colors and Winners](https://courses.osherove.com/courses/tdd-pairing-sessions-building-a-go-game/colors-and-winners/)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
