public Space.Color GetGroupTerritory(List <Space> group) { Space.Color territory = Space.Color.None; foreach (Space space in group) { for (int cX = space.X - 1; cX <= space.X + 1; cX++) { for (int cY = space.Y - 1; cY <= space.Y + 1; cY++) { if ((cX == space.X && cY != space.Y) || (cX != space.X && cY == space.Y)) { if (cX > 0 && cX <= this.BoardSize && cY > 0 && cY <= this.BoardSize) { Space cSpace = this.Spaces.GetSpace(cX, cY); if (cSpace.SpaceColor != Space.Color.None) { if (territory == Space.Color.None) { territory = cSpace.SpaceColor; } if (cSpace.SpaceColor != territory) { return(Space.Color.None); } } } } } } } return(territory); }
public void SetTerritory(Space.Color territory) { if (this._territory != territory) { this._territory = territory; this.paintSpace(); } }
public int GetScore(Space.Color color) { if (color == Space.Color.Black) { return(this._blackTerritory.Count + this._capturesB); } else { return(this._whiteTerritory.Count + this._capturesW); } }
public int GetCaptures(Space.Color color) { if (color == Space.Color.White) { return(this._capturesW); } else { return(this._capturesB); } }
public override bool IsLegal(Board board, int x, int y, Space.Color color) { bool isLegal = base.IsLegal(board, x, y, color); if (isLegal) { return(true); } else { return(false); } }
private void checkTerritory() { this._whiteTerritory.Clear(); this._blackTerritory.Clear(); List <Space> none = new List <Space>(); foreach (Space space in this.Spaces) { if (space.SpaceColor == Space.Color.None && !_whiteTerritory.Contains(space) && !_blackTerritory.Contains(space) && !none.Contains(space)) { List <Space> group = this.GetEmptyGroup(space.X, space.Y); Space.Color territory = this.GetGroupTerritory(group); if (territory == Space.Color.None) { foreach (Space tSpace in group) { none.Add(tSpace); tSpace.SetTerritory(territory); } } else { foreach (Space tSpace in group) { if (territory == Space.Color.White) { _whiteTerritory.Add(tSpace); } if (territory == Space.Color.Black) { _blackTerritory.Add(tSpace); } tSpace.SetTerritory(territory); } } } } this._board.SetScoringStatus(); }
public Space AddStone(int x, int y, Space.Color spaceColor) { Space addSpace = this._spaces.GetSpace(x, y); if (addSpace.SpaceColor == Space.Color.None) { addSpace.SpaceColor = spaceColor; this.addToGroup(addSpace); StoneChangedEventArgs e = new StoneChangedEventArgs(); e.Color = addSpace.SpaceColor; e.X = addSpace.X; e.Y = addSpace.Y; this.OnStoneChanged(e); return(addSpace); } return(null); }
public override bool IsLegal(Board board, int x, int y, Space.Color color) { throw new NotImplementedException(); }
public override int GetScore(Board board, Space.Color color) { throw new NotImplementedException(); }