public TigerCaptureMove(BoardSpace startSpace, BoardSpace endSpace, BoardSpace jumpSpace, AbstractPlayer player) { this.StartSpace = startSpace; this.EndSpace = endSpace; this.Player = player; this.jumpSpace = jumpSpace; }
public override List<AbstractMove> GetCaptureMoves(State state, List<CoordinatePair> adjacentList, BoardSpace currSpace) { List<AbstractMove> captureMoves = new List<AbstractMove>(); int tempRow = 0; int tempCol = 0; int bRow = 0; int bColumn = 0; foreach (CoordinatePair b in adjacentList) { if (state.GetSpaceState(b.Row, b.Column) == 'G') { tempRow = currSpace.GetRow(); tempCol = currSpace.GetColumn(); bRow = b.Row; bColumn = b.Column; if (bRow == currSpace.GetRow()) { if (bColumn < currSpace.GetColumn()) tempCol = bColumn - 1; if (bColumn > currSpace.GetColumn()) tempCol = bColumn + 1; } if (bRow < currSpace.GetRow()) { tempRow = bRow - 1; if (bColumn < currSpace.GetColumn()) tempCol = bColumn - 1; if (bColumn > currSpace.GetColumn()) tempCol = bColumn + 1; } if (bRow > currSpace.GetRow()) { tempRow = bRow + 1; if (bColumn < currSpace.GetColumn()) tempCol = bColumn - 1; if (bColumn > currSpace.GetColumn()) tempCol = bColumn + 1; } if ((tempRow >= 0 && tempRow <= 4) && (tempCol >= 0 && tempCol <= 4)) if (state.GetSpaceState(tempRow, tempCol) == 'X') captureMoves.Add(new TigerCaptureMove(currSpace, state .Board.GetSpace(tempRow, tempCol), state .Board.GetSpace(bRow, bColumn), this)); } } return captureMoves; }
public void TestBoardSpace() { int row = 0; int col = 1; BoardSpace bs = new BoardSpace(row, col); Console.WriteLine("BoardSpace created: " + bs.ToString()); Assert.IsNotNull(bs); Assert.AreEqual(bs.GetRow(), row); Assert.AreEqual(bs.GetColumn(), col); row = 1; col = 2; bs.SetRow(row); bs.SetColumn(col); Assert.AreEqual(bs.GetRow(), row); Assert.AreEqual(bs.GetColumn(), col); row = 2; col = 3; bs.SetCoordinates(row, col); Assert.AreEqual(bs.GetRow(), row); Assert.AreEqual(bs.GetColumn(), col); Assert.AreEqual(bs.GetSpaceState(), 'X'); bs.SetSpaceState('T'); Assert.AreEqual(bs.GetSpaceState(), 'T'); bs.SetSpaceState('G'); Assert.AreEqual(bs.GetSpaceState(), 'G'); bs.SetSpaceState('X'); Assert.AreEqual(bs.GetSpaceState(), 'X'); try { bs.SetSpaceState('M'); } catch (Exception ex) { Console.WriteLine(ex.Message); } Assert.AreEqual(bs.GetSpaceState(), 'X'); bs = new BoardSpace(1, 3, 'T'); Assert.AreEqual(bs.GetSpaceState(), 'T'); Assert.AreEqual(bs.GetRow(), 1); Assert.AreEqual(bs.GetColumn(), 3); Console.WriteLine("finished TestBoardSpace()"); //Assert.IsNull(bs.getSpaceState()); }
public SlideMove(BoardSpace startSpace, BoardSpace endSpace, AbstractPlayer player) { this.StartSpace = startSpace; this.EndSpace = endSpace; this.Player = player; }
public override List<AbstractMove> GetCaptureMoves(State state, List<CoordinatePair> adjacentSpaces, BoardSpace currSpace) { return null; }
public GoatPlacementMove(BoardSpace startSpace, BoardSpace endSpace, AbstractPlayer player) : base(startSpace, endSpace, player) { }
public TigerCaptureMove() { jumpSpace = null; }
private AbstractMove getRandomFirstGoatMove(State s) { Random r = new Random(); int randInt = r.Next(4); BoardSpace b = null; switch (randInt) { case 0: b = new BoardSpace(0, 2); break; case 1: b = new BoardSpace(2, 0); break; case 2: b = new BoardSpace(2, 4); break; case 3: b = new BoardSpace(4, 2); break; } GoatPlacementMove m = new GoatPlacementMove(null, b, s.Goat); return m; }
public AbstractMove(BoardSpace startSpace, BoardSpace endSpace, AbstractPlayer player) { this.startSpace = startSpace; this.endSpace = endSpace; this.player = player; }
public abstract List<AbstractMove> GetCaptureMoves(State state, List<CoordinatePair> adjacentSpaces, BoardSpace currSpace);