Example #1
0
        public ZertzBallContainer CaptureLandPieces(HexLocation hl)           //CLP
        {
            HashSet <HexLocation> visited = new HashSet <HexLocation>();
            Stack <HexLocation>   todo    = new Stack <HexLocation>();
            ZertzBallContainer    zbc     = ZertzBallContainer.Empty();
            ZertzPiece            zp;

            zbc[this[hl].BallType]++;
            this[hl] = ZertzPiece.Dead;
            visited.Add(hl);
            todo.Push(hl);
            HexLocation hla, nei;

            while (todo.Count > 0x00)
            {
                hla = todo.Pop();
                for (int i = 0x00; i < 0x06; i++)
                {
                    nei = hla + HexLocation.NeighbourDirections[i];
                    if (!visited.Contains(nei))
                    {
                        visited.Add(nei);
                        zp = this[nei];
                        if (zp.IsAlive)
                        {
                            zbc[zp.BallType]++;
                            this[nei] = ZertzPiece.Dead;
                            todo.Push(nei);
                        }
                    }
                }
            }
            return(zbc);
        }
Example #2
0
 public ZertzGame(out HexLocation[] hls)
 {
     //this.players = new IPlayer[] {playerA,playerB};
     this.board        = ZertzBoard.OffsetBoard(out hls);
     this.playersPools = new ZertzBallContainer[] { ZertzBallContainer.Empty(), ZertzBallContainer.Empty() };
     this.turn         = 0x00;
     this.zmc          = new ZertzMoveCreator(this);
 }
Example #3
0
 private ZertzBallContainer getCurrentPlayerSourcePool()
 {
     if (this.commonPool != ZertzBallContainer.Empty())
     {
         return(this.commonPool);
     }
     else
     {
         return(this.playersPools[this.turn]);
     }
 }