Loading cmd/tictactoe/main.go +4 −3 Original line number Diff line number Diff line Loading @@ -8,7 +8,8 @@ import ( "time" "repositories.muehmer.net/bsmrgo/tictactoe/game" "repositories.muehmer.net/bsmrgo/tictactoe/grid" "repositories.muehmer.net/bsmrgo/tictactoe/grid/cross" "repositories.muehmer.net/bsmrgo/tictactoe/grid/nought" ) func main() { Loading @@ -25,7 +26,7 @@ func main() { rand.Seed(seed) g := game.New() g.AddPlayer(name1, &grid.Cross{}) g.AddPlayer(name2, &grid.Nought{}) g.AddPlayer(name1, &cross.Cross{}) g.AddPlayer(name2, &nought.Nought{}) g.Run() } game/game_test.go +4 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,8 @@ import ( "math/rand" "testing" "repositories.muehmer.net/bsmrgo/tictactoe/grid" "repositories.muehmer.net/bsmrgo/tictactoe/grid/cross" "repositories.muehmer.net/bsmrgo/tictactoe/grid/nought" ) func TestGame(t *testing.T) { Loading @@ -12,8 +13,8 @@ func TestGame(t *testing.T) { seed := int64(1557681173) rand.Seed(seed) c1 := &grid.Cross{} c2 := &grid.Nought{} c1 := &cross.Cross{} c2 := &nought.Nought{} g := New() g.AddPlayer("Player 1", c1) Loading grid/cell.go 0 → 100644 +9 −0 Original line number Diff line number Diff line package grid // Cell ... type Cell interface { Symbol() string IsEmpty() bool IsNought() bool IsCross() bool } grid/cross/cross.go 0 → 100644 +24 −0 Original line number Diff line number Diff line package cross // Cross ... type Cross struct{} // Symbol ... func (c *Cross) Symbol() string { return "×" } // IsEmpty ... func (c *Cross) IsEmpty() bool { return false } // IsNought ... func (c *Cross) IsNought() bool { return false } // IsCross ... func (c *Cross) IsCross() bool { return true } grid/cross/cross_test.go 0 → 100644 +1 −0 Original line number Diff line number Diff line package cross Loading
cmd/tictactoe/main.go +4 −3 Original line number Diff line number Diff line Loading @@ -8,7 +8,8 @@ import ( "time" "repositories.muehmer.net/bsmrgo/tictactoe/game" "repositories.muehmer.net/bsmrgo/tictactoe/grid" "repositories.muehmer.net/bsmrgo/tictactoe/grid/cross" "repositories.muehmer.net/bsmrgo/tictactoe/grid/nought" ) func main() { Loading @@ -25,7 +26,7 @@ func main() { rand.Seed(seed) g := game.New() g.AddPlayer(name1, &grid.Cross{}) g.AddPlayer(name2, &grid.Nought{}) g.AddPlayer(name1, &cross.Cross{}) g.AddPlayer(name2, &nought.Nought{}) g.Run() }
game/game_test.go +4 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,8 @@ import ( "math/rand" "testing" "repositories.muehmer.net/bsmrgo/tictactoe/grid" "repositories.muehmer.net/bsmrgo/tictactoe/grid/cross" "repositories.muehmer.net/bsmrgo/tictactoe/grid/nought" ) func TestGame(t *testing.T) { Loading @@ -12,8 +13,8 @@ func TestGame(t *testing.T) { seed := int64(1557681173) rand.Seed(seed) c1 := &grid.Cross{} c2 := &grid.Nought{} c1 := &cross.Cross{} c2 := &nought.Nought{} g := New() g.AddPlayer("Player 1", c1) Loading
grid/cell.go 0 → 100644 +9 −0 Original line number Diff line number Diff line package grid // Cell ... type Cell interface { Symbol() string IsEmpty() bool IsNought() bool IsCross() bool }
grid/cross/cross.go 0 → 100644 +24 −0 Original line number Diff line number Diff line package cross // Cross ... type Cross struct{} // Symbol ... func (c *Cross) Symbol() string { return "×" } // IsEmpty ... func (c *Cross) IsEmpty() bool { return false } // IsNought ... func (c *Cross) IsNought() bool { return false } // IsCross ... func (c *Cross) IsCross() bool { return true }
grid/cross/cross_test.go 0 → 100644 +1 −0 Original line number Diff line number Diff line package cross