public void StateAccess() { State o = new State(null); Assert.Equal("q", o.At(o.Live, 4, 8).Sym); Assert.Equal(Color.White, o.At(o.Live, 5, 1).Color); Assert.True(o.At(o.Live, 7, 7).Inert); Assert.Equal(Color.White, o.Turn(true)); Assert.Equal(Color.Black, o.Turn(false)); Piece blackKing = o.King(Color.Black, true); Assert.Equal(Color.Black, blackKing.Color); Assert.Equal(5, blackKing.X); Assert.Equal(8, blackKing.Y); o = new State("bbc3 wnf6"); List <(int, int, int, int)> r = o.LineOfAttack(o.At(o.Live, 3, 3), o.At(o.Live, 6, 6)); Assert.Contains((3, 3, 3, 3), r); Assert.Contains((4, 4, 0, 0), r); Assert.Contains((5, 5, 0, 0), r); }
public void StateKill() { State o = new State(null); o.Kill(1, 1); Assert.Null(o.At(o.Live, 1, 1)); }
public void StateChecking() { State o = new State("bkd6 wrc2"); Assert.True(o.WillCheck(Color.White, o.At(o.Live, 3, 2), 4, 2)); o = new State("brc6 wqc4 wkc2"); Assert.True(o.WillBeChecked(Color.White, o.At(o.Live, 3, 4), 2, 4)); o = new State("wka1 bqh2 bnc4"); Assert.True(o.WillCheckmate(Color.Black, o.At(o.Live, 8, 2), 2, 2)); }
public void StateCustomInit() // for testing other things { State o = new State("wnc3"); Assert.NotNull(o); Assert.Single(o.Live); Assert.Empty(o.Dead); Assert.Empty(o.History); Assert.Equal("N", o.At(o.Live, 3, 3).Sym); Assert.Equal(Color.White, o.At(o.Live, 3, 3).Color); o = new State("wpa1 brb2 wnc3 bbd4 wqe5 bkf6"); Assert.NotNull(o); Assert.Equal(6, o.Live.Count); Assert.Equal("P", o.At(o.Live, 1, 1).Sym); Assert.Equal("r", o.At(o.Live, 2, 2).Sym); Assert.Equal("N", o.At(o.Live, 3, 3).Sym); Assert.Equal("b", o.At(o.Live, 4, 4).Sym); Assert.Equal("Q", o.At(o.Live, 5, 5).Sym); Assert.Equal("k", o.At(o.Live, 6, 6).Sym); }
public void StateUndo() { State o = new State(null); Assert.Empty(o.Move(1, 2, 1, 4)); Assert.Null(o.At(o.Live, 1, 2)); Assert.NotNull(o.At(o.Live, 1, 4)); Assert.False(o.At(o.Live, 1, 4).Inert); Assert.Single(o.History); o.Undo(o.LastNote()); Assert.Null(o.At(o.Live, 1, 4)); Assert.NotNull(o.At(o.Live, 1, 2)); Assert.True(o.At(o.Live, 1, 2).Inert); Assert.Empty(o.History); Assert.Empty(o.Move(1, 2, 1, 4)); Assert.Single(o.History); }
public void PieceAccess() { State o = new State("wrd4 bpd7"); Piece p = o.At(o.Live, 4, 4); Assert.True(Piece.Is(p, "Rook")); List <(int, int, int, int)> r1 = p.Reach(o.Board, null); Assert.Equal(13, r1.Count); Assert.Contains((4, 5, 0, 0), r1); Assert.Contains((4, 6, 0, 0), r1); Assert.Contains((4, 7, 4, 7), r1); Assert.Contains((5, 4, 0, 0), r1); Assert.Contains((6, 4, 0, 0), r1); Assert.Contains((7, 4, 0, 0), r1); Assert.Contains((8, 4, 0, 0), r1); Assert.Contains((4, 3, 0, 0), r1); Assert.Contains((4, 2, 0, 0), r1); Assert.Contains((4, 1, 0, 0), r1); Assert.Contains((3, 4, 0, 0), r1); Assert.Contains((2, 4, 0, 0), r1); Assert.Contains((1, 4, 0, 0), r1); int x; int y; o = new State("wke1 wra1"); p = o.At(o.Live, 5, 1); List <Ret> r2 = p.Castle(o, 3, 1, out x, out y); Assert.Contains(Ret.Castle, r2); o = new State("wke1 wra1 brb8"); p = o.At(o.Live, 5, 1); r2 = p.Castle(o, 3, 1, out x, out y); Assert.Contains(Ret.BadCastle, r2); }