Esempio n. 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);
        }
Esempio n. 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);
 }
Esempio n. 3
0
 private ZertzBallContainer getCurrentPlayerSourcePool()
 {
     if (this.commonPool != ZertzBallContainer.Empty())
     {
         return(this.commonPool);
     }
     else
     {
         return(this.playersPools[this.turn]);
     }
 }
Esempio n. 4
0
 public void TestConstructor()
 {
     ZertzBallContainer zbc;
     for(byte b = byte.MinValue; b < byte.MaxValue; b++) {
         for(byte c = byte.MinValue; c < byte.MaxValue; c++) {
             for(byte d = byte.MinValue; d < byte.MaxValue; d++) {
                 zbc = new ZertzBallContainer(b,c,d);
                 Assert.AreEqual(b,zbc[ZertzBallType.White]);
                 Assert.AreEqual(c,zbc[ZertzBallType.Gray]);
                 Assert.AreEqual(d,zbc[ZertzBallType.Black]);
             }
         }
     }
 }
Esempio n. 5
0
        public void TestConstructor()
        {
            ZertzBallContainer zbc;

            for (byte b = byte.MinValue; b < byte.MaxValue; b++)
            {
                for (byte c = byte.MinValue; c < byte.MaxValue; c++)
                {
                    for (byte d = byte.MinValue; d < byte.MaxValue; d++)
                    {
                        zbc = new ZertzBallContainer(b, c, d);
                        Assert.AreEqual(b, zbc[ZertzBallType.White]);
                        Assert.AreEqual(c, zbc[ZertzBallType.Gray]);
                        Assert.AreEqual(d, zbc[ZertzBallType.Black]);
                    }
                }
            }
        }
Esempio n. 6
0
 public void PutToPool(ZertzBallContainer container)           //PTP
 {
     this.getCurrentPlayerDestinationPool().Add(container);
 }
Esempio n. 7
0
 public void Add(ZertzBallContainer container)
 {
     this.counters += container.counters;
 }
Esempio n. 8
0
 public void Add(ZertzBallContainer container)
 {
     this.counters += container.counters;
 }
Esempio n. 9
0
 public static ZertzBallRenderer[] GenerateBalls(ZertzBallContainer zbc, RenderContainer rc, ZertzCupRenderer zcr, int offsetid)
 {
     int id = offsetid;
     ZertzBallType zbt;
     ZertzBallRenderer zbr;
     ZertzBallRenderer[] list = new ZertzBallRenderer[zbc.Total];
     int j = 0x00;
     for(byte b = 0x00; b < 0x03; b++) {
         zbt = (ZertzBallType) b;
         for(int i = 0x00; i < zbc[zbt]; i++) {
             zbr = new ZertzBallRenderer(zbt);
             list[j++] = zbr;
             rc.Add(id++,zbr);
             zbr.RenderMover = RenderMoveManager.GenerateStaticMover(zcr.CommonContainer.Add(zbr));
         }
     }
     return list;
 }
Esempio n. 10
0
 public void PutToPool(ZertzBallContainer container)
 {
     //PTP
     this.getCurrentPlayerDestinationPool().Add(container);
 }