I figured it would be useful (for me, at least!) if you could view the board from either player's view point. The current toString() method of the Board class always renders the board so that White is at the bottom.
With this pull request I introduce new methods for the Board class:
toStringFromWhiteViewPoint()
toStringFromBlackViewPoint()
toStringFromViewPoint(Side side)
The first one renders the board as if it was the White player looking at it, i.e. the 1st rank at the bottom. The second one renders the board as if it was the Black player looking at it, i.e. the 8th rank at the bottom. The third method allows you to specify the side as a parameter. Internally, the first and second method refer to the third one. Similarly, the old toString() method refers to the first one, and then just appends the info on whose turn it is. I also created unit tests for all of these methods, including the old toString() which kind of had a test but without any assertions.
I figured I could do this feature quicker than I could create a pull request that would explain everything that I would need, so I just went ahead and did it before asking, I hope you don't mind. 😃
Greetings,
I figured it would be useful (for me, at least!) if you could view the board from either player's view point. The current
toString()
method of theBoard
class always renders the board so that White is at the bottom.With this pull request I introduce new methods for the
Board
class:toStringFromWhiteViewPoint()
toStringFromBlackViewPoint()
toStringFromViewPoint(Side side)
The first one renders the board as if it was the White player looking at it, i.e. the 1st rank at the bottom. The second one renders the board as if it was the Black player looking at it, i.e. the 8th rank at the bottom. The third method allows you to specify the side as a parameter. Internally, the first and second method refer to the third one. Similarly, the old
toString()
method refers to the first one, and then just appends the info on whose turn it is. I also created unit tests for all of these methods, including the oldtoString()
which kind of had a test but without any assertions.I figured I could do this feature quicker than I could create a pull request that would explain everything that I would need, so I just went ahead and did it before asking, I hope you don't mind. 😃