Example #1
0
        public TigerCaptureMove(BoardSpace startSpace, BoardSpace endSpace, BoardSpace jumpSpace, AbstractPlayer player)
        {
            this.StartSpace = startSpace;
            this.EndSpace = endSpace;
            this.Player = player;

            this.jumpSpace = jumpSpace;
        }
Example #2
0
        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;
        }
Example #3
0
        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());
        }
Example #4
0
 public SlideMove(BoardSpace startSpace, BoardSpace endSpace, AbstractPlayer player)
 {
     this.StartSpace = startSpace;
     this.EndSpace = endSpace;
     this.Player = player;
 }
Example #5
0
 public override List<AbstractMove> GetCaptureMoves(State state, List<CoordinatePair> adjacentSpaces,
     BoardSpace currSpace)
 {
     return null;
 }
Example #6
0
 public GoatPlacementMove(BoardSpace startSpace, BoardSpace endSpace,
     AbstractPlayer player)
     : base(startSpace, endSpace, player)
 {
 }
Example #7
0
 public TigerCaptureMove()
 {
     jumpSpace = null;
 }
Example #8
0
        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;
        }
Example #9
0
 public AbstractMove(BoardSpace startSpace, BoardSpace endSpace, AbstractPlayer player)
 {
     this.startSpace = startSpace;
     this.endSpace = endSpace;
     this.player = player;
 }
Example #10
0
 public abstract List<AbstractMove> GetCaptureMoves(State state, List<CoordinatePair> adjacentSpaces,
     BoardSpace currSpace);