public override string ToString() { StringBuilder lStringBuilder = new StringBuilder(); for (int y = Width; y > 0; y--) { lStringBuilder.Append(y); if (y < 10) { lStringBuilder.Append(" "); } lStringBuilder.Append(" : "); for (int x = 0; x < Width; x++) { if (Contains(CoordinateSystem.At(x, y - 1, Width))) { lStringBuilder.Append('X'); } else { lStringBuilder.Append('.'); } } lStringBuilder.AppendLine(); } lStringBuilder.Append(" "); lStringBuilder.AppendLine("ABCDEFGHJKLMNOPQURS".Substring(0, Width)); return(lStringBuilder.ToString()); }
/// <summary> /// Verifies the specified GO/GTP coordinates translate correctly. /// </summary> /// <param name="coordinate">The coordinate.</param> /// <returns></returns> public static bool Verify(int boardSize, string coordinate) { int lPoint = CoordinateSystem.At(coordinate, boardSize); CoordinateSystem lCoord = CoordinateSystem.GetCoordinateSystem(boardSize); string lCoordinate = lCoord.ToString(lPoint); Assert.AreEqual(coordinate.ToLower(), lCoordinate.ToLower()); return(coordinate.ToLower() == lCoordinate.ToLower()); }
public Region(StringMap stringMap) { Width = (stringMap.Height > stringMap.Width) ? stringMap.Height : stringMap.Width; Grid = new bool[Width * Width]; Count = 0; for (int x = 0; x < Width; x++) { for (int y = 0; y < Width; y++) { if ((stringMap.Get(x, y) != ' ') && (stringMap.Get(x, y) != '.')) { Add(CoordinateSystem.At(x, y, Width)); } } } // Console.WriteLine(pStringMap.ToString()); }
public bool IsIntersection(int x, int y) { return(IsIntersection(CoordinateSystem.At(x, y, Width))); }
protected ZobristHash ComputeZobrist(Pattern pattern, Color color) { int lSize = pattern.GetFullBoardSize(); ZobristHash lZobristHash = new ZobristHash(); for (int x = 0; x < lSize; x++) { for (int y = 0; y < lSize; y++) { switch (pattern.GetCell(x, y)) { case 'X': lZobristHash.Delta(color.IsBlack ? Color.Black : Color.White, CoordinateSystem.At(x, y, lSize)); break; case 'O': lZobristHash.Delta(color.IsBlack ? Color.White : Color.Black, CoordinateSystem.At(x, y, lSize)); break; } } } return(lZobristHash); }
public void ProcesLine(string line) { if (line == null) { Disconnect(); return; } string lLine = line.TrimEnd('\n'); string[] lCmds = lLine.Split('\t'); bool lAsync = (lCmds[0][0] == '!'); bool lSuccess = (lCmds[0][lAsync ? 1 : 0] == '='); string[] lID = lCmds[1].Split('.'); int lCommandNbr = Convert.ToInt32(lID[0]); int lSeqNbr = Convert.ToInt32(lID[1]); if ((Verbose) && (lCmds.Length > 3)) { Console.Error.WriteLine("STATUS: P< " + lLine); } lock (this) { if ((lCommandNbr == 0) && (lSeqNbr == 0) && (!lSuccess)) { // worker disconnecting... Disconnect(); return; } if (State == ConnectionState.Negotiating) { if ((!lSuccess) || (lCmds[2] != "1.0")) { Disconnect(); return; } if (lSeqNbr == 1) { State = ConnectionState.Negotiated; ThreadPoolHelperWithParam <WorkerProxy> .Execute(NagCoordinator.WorkerNegotiated, this); //NagCoordinator.WorkerNegotiated(this); } } else if (State == ConnectionState.SendingPatterns) { if (CommandNbr == lCommandNbr) { if (!lSuccess) { Disconnect(); return; } if (lSeqNbr == 1) { State = ConnectionState.Available; ThreadPoolHelperWithParam <WorkerProxy> .Execute(NagCoordinator.WorkerAvailable, this); //NagCoordinator.WorkerAvailable(this); } } } else if (State == ConnectionState.Initializing) { if (CommandNbr == lCommandNbr) { if (!lSuccess) { // error with commands, disconnect to reset worker Disconnect(); return; } if (lSeqNbr == 1) { State = ConnectionState.Ready; ThreadPoolHelperWithParam <WorkerProxy> .Execute(NagCoordinator.WorkerReady, this); // NagCoordinator.WorkerReady(this); } } } else if (State == ConnectionState.Thinking) { if (CommandNbr == lCommandNbr) { if (!lSuccess) { // error with commands, disconnect to reset worker Disconnect(); return; } if ((lSeqNbr == 6) && (lAsync)) { State = ConnectionState.Ready; if (NagNode != null) { NagNode.SetResult(Convert.ToInt32(lCmds[3]), CoordinateSystem.At(lCmds[2], BoardSize)); ThreadPoolHelperWithParam <NagNode> .Execute(NagCoordinator.WorkerResult, NagNode); NagNode = null; } ThreadPoolHelperWithParam <WorkerProxy> .Execute(NagCoordinator.WorkerReady, this); } } } else if (State == ConnectionState.Aborting) { if (CommandNbr == lCommandNbr) { if (!lSuccess) { // error with commands, disconnect to reset worker Disconnect(); return; } if (lSeqNbr == 1) { State = ConnectionState.Ready; NagNode = null; ThreadPoolHelperWithParam <WorkerProxy> .Execute(NagCoordinator.WorkerReady, this); } } } } }
public int At(int x, int y) { return(Coord.At(x, y)); }
public void SetupStone(Color color, string move) { AddMove(new GameMove(color, CoordinateSystem.At(move, BoardSize), true)); }
public void PlayStone(Color color, string move) { AddMove(new GameMove(color, CoordinateSystem.At(move, BoardSize), false)); }
public bool PlayStone(string move, Color color) { int lMove = CoordinateSystem.At(move, Board.BoardSize); return(Board.PlayStone(lMove, color, false)); }