Exemple #1
0
func TestMoves(t *testing.T) {
	testCases := []struct {
		curPos            game.Position
		expectedDirection game.Direction
	}{
		{
			curPos:            game.NewPosition(5, 5),
			expectedDirection: game.UP,
		},
	}

	for n, tc := range testCases {
		g := game.NewGame()
		g.ActivePlayer.PawnPos = tc.curPos
		cpy := g.Copy()
		intel := intelligence.NewSimpleIntelligence(g.ActivePlayer.Color)
		move := intel.NextMove(cpy)
		movePawn, ok := move.(*game.MovePawn)
		if !ok {
			t.Errorf("(%d) Expected move pawn, got %v", n, move)
		}
		if movePawn.Direction != tc.expectedDirection {
			t.Errorf("(%d) Expected direction %v, got %v", n, tc.expectedDirection, movePawn.Direction)
		}
	}
}
Exemple #2
0
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	g := cmd.NewGameRunner(cmd.NewHumanPlayer(scanner), intelligence.NewSimpleIntelligence(game.BLACK))
	g.Play()
}