private static bool captureKernel(BoardBase board, List <Tuple <byte, byte> > captureList, byte row, byte col, WColor color) { WColor flipColor = ColorUtils.Flip(color); if (!BoardUtil.CheckBounds(board.Size, row, col)) { return(true); } else if (board[row, col] == flipColor) { return(true); } else if (board.GetMark(row, col) == Mark.MARK1) { return(true); } else if (board[row, col] == WColor.EMPTY) { return(false); } else { captureList.Add(new Tuple <byte, byte>(row, col)); board.Mark(row, col, Mark.MARK1); return( captureKernel(board, captureList, (byte)(row + 1), col, color) && captureKernel(board, captureList, (byte)(row - 1), col, color) && captureKernel(board, captureList, row, (byte)(col + 1), color) && captureKernel(board, captureList, row, (byte)(col - 1), color) ); } }
public static bool CheckMove(BoardBase status, WColor turn, byte row, byte col) { BoardStatus toCheck = new BoardStatus(status.Size); toCheck.Board = new BoardBase(status); toCheck.Turn = turn; bool ret = Move(ref toCheck, row, col); return(ret); }
public static WColor Flip(WColor c) { if (c == WColor.BLACK) { return(WColor.WHITE); } else if (c == WColor.WHITE) { return(WColor.BLACK); } return(WColor.EMPTY); }
private static void Drawing_OnDraw(EventArgs args) { if (Me.IsDead) { return; } if (DrawMenu.GetCheckBoxValue("drawReady")) { if (QColor.BoolValue && Q.IsReady()) { Q.DrawSpell(QColor.GetColor()); } if (WColor.BoolValue && W.IsReady()) { W.DrawSpell(WColor.GetColor()); } if (EColor.BoolValue && E.IsReady()) { E.DrawSpell(EColor.GetColor()); } if (RColor.BoolValue && R.IsReady()) { R.DrawSpell(RColor.GetColor()); } } else { if (QColor.BoolValue) { Q.DrawSpell(Q.IsReady() ? QColor.GetColor() : Color.Red); } if (WColor.BoolValue) { W.DrawSpell(W.IsReady() ? WColor.GetColor() : Color.Red); } if (EColor.BoolValue) { E.DrawSpell(E.IsReady() ? EColor.GetColor() : Color.Red); } if (RColor.BoolValue) { R.DrawSpell(R.IsReady() ? RColor.GetColor() : Color.Red); } } }
private static void AddGameSequence(GameRecord gr, string value, WColor wColor) { int p = 0; while (p + 1 < value.Length) { gr.GameSequence.Add(new Tuple <byte, byte, WColor>((byte)(value[p] - 'a'), (byte)(value[p + 1] - 'a'), wColor)); p++; while (p + 1 < value.Length) { p++; if ((value[p] >= 'a') && (value[p] <= 'z')) { break; } } } }
private static bool CalculateCaptureStones(byte row, byte col, WColor color, ref BoardStatus newStatus) { List <Tuple <byte, byte> > capturedStones; bool captured = false; var flipColor = ColorUtils.Flip(color); if ((capturedStones = Capture(newStatus, (byte)(row + 1), col, flipColor)).Count > 0) { RemoveStones(capturedStones, newStatus); captured = true; } if ((capturedStones = Capture(newStatus, (byte)(row - 1), col, flipColor)).Count > 0) { RemoveStones(capturedStones, newStatus); captured = true; } if ((capturedStones = Capture(newStatus, row, (byte)(col + 1), flipColor)).Count > 0) { RemoveStones(capturedStones, newStatus); captured = true; } if ((capturedStones = Capture(newStatus, row, (byte)(col - 1), flipColor)).Count > 0) { RemoveStones(capturedStones, newStatus); captured = true; } if ((!captured) && ((capturedStones = Capture(newStatus, row, col, color)).Count > 0)) { return(false); } else { return(true); } }
public static void PrintToConsole(BoardStatus boardStatus, Mask mask = null) { byte size = boardStatus.Board.Size; Console.WriteLine(); ConsoleColor saveColor = Console.ForegroundColor; Console.Write(" "); Console.ForegroundColor = ConsoleColor.Gray; for (byte i = 0; i < size; i++) { Console.Write(' '); if (i < 8) { Console.Write((char)(i + 'A')); } else { Console.Write((char)(i + 'B')); } } Console.WriteLine(); for (byte i = 0; i < size; i++) { Console.ForegroundColor = ConsoleColor.Gray; Console.Write(" {0,2}", (int)(19 - i)); for (byte j = 0; j < size; j++) { WColor stoneColor = boardStatus.Board.Get(j, i); Mark markColor = boardStatus.Board.GetMark(j, i); ConsoleColor fc = ConsoleColor.Gray; string mark = ""; if (stoneColor == WColor.EMPTY) { fc = ConsoleColor.Gray; mark = " ."; } else if (stoneColor == WColor.WHITE) { fc = ConsoleColor.Green; mark = " X"; } else if (stoneColor == WColor.BLACK) { fc = ConsoleColor.Yellow; mark = " O"; } if (markColor == Mark.MARK1) { fc = ConsoleColor.Red; } if (mask.CheckMaskClose(j, i)) { fc = ConsoleColor.Gray; mark = " #"; } Console.ForegroundColor = fc; Console.Write(mark); } Console.ForegroundColor = ConsoleColor.Gray; Console.Write(" {0}", (int)(19 - i)); Console.WriteLine(); } Console.Write(" "); Console.ForegroundColor = ConsoleColor.Gray; for (byte i = 0; i < size; i++) { Console.Write(' '); if (i < 8) { Console.Write((char)(i + 'A')); } else { Console.Write((char)(i + 'B')); } } Console.WriteLine(); Console.WriteLine(); Console.ForegroundColor = saveColor; }
public void Set(int row, int col, WColor color) { _board[row * Size + col] &= (byte)0xFC; _board[row * Size + col] |= (byte)color; }
public void Play(byte row, byte col, WColor color) { }
internal void FlipTurn() { Turn = ColorUtils.Flip(Turn); }
public BoardStatus(BoardStatus bs) { Board = new BoardBase(bs.Board); Turn = bs.Turn; }
public BoardStatus(byte size) { Board = new BoardBase(size); Turn = WColor.EMPTY; }
private static void Drawing_OnDraw(EventArgs args) { if (Me.IsDead) { return; } var flash = EloBuddy.SDK.Spells.SummonerSpells.Flash; if (flash != null && flash.IsReady() && R.IsReady() && HasQ3()) { Console.WriteLine("Trying"); var targets = EntityCache.EnemyHeroes.Where(e => e.IsValidTarget(1000)).ToArray(); var range = flash.Range + (QCircleRange / 2); var width = QCircleRange; var delay = EDelay + Q.CastDelay / 2 + Game.Ping; var predLocationCircular = Prediction.Position.PredictCircularMissileAoe(targets, range, width, delay, int.MaxValue) .OrderByDescending(r => r.GetCollisionObjects <AIHeroClient>().Length) .FirstOrDefault(); if (predLocationCircular != null && predLocationCircular.HitChancePercent >= 75) { predLocationCircular.CastPosition.DrawCircle(width, SharpDX.Color.Aqua, 5f); var predictedMinion = predLocationCircular.GetCollisionObjects <AIHeroClient>(); if (predictedMinion.Length >= 1) { try { Console.WriteLine("Casting"); if (Me.Dashing()) { //Q.Cast(); //flash.Cast(predLocationCircular.CastPosition); } } catch (Exception) { //ignored } } } } if (DrawMenu.GetCheckBoxValue("drawReady")) { if (QColor.BoolValue && Q.IsReady()) { Q.DrawSpell(QColor.GetColor()); var targets = EntityCache.EnemyHeroes.Where(m => Q.CanCast(m)); if (targets != null || targets.Any()) { /* * var predPos = Q.GetBestLinearCastPosition(targets); * if (predPos.CastPosition != null) * { * var polygon = new Geometry.Polygon.Rectangle(Me.Position, Me.Position.Extend(predPos.CastPosition, Q.Range).To3D(), Q.Width); * * if (polygon != null) * { * polygon.Draw(QColor.CurrentColor, 6); * } * } */ } } if (WColor.BoolValue && W.IsReady()) { W.DrawSpell(WColor.GetColor()); } if (EColor.BoolValue && E.IsReady()) { E.DrawSpell(EColor.GetColor()); } if (RColor.BoolValue && R.IsReady()) { R.DrawSpell(RColor.GetColor()); } } else { if (QColor.BoolValue) { Q.DrawSpell(Q.IsReady() ? QColor.GetColor() : Color.Red); } if (WColor.BoolValue) { W.DrawSpell(W.IsReady() ? WColor.GetColor() : Color.Red); } if (EColor.BoolValue) { E.DrawSpell(E.IsReady() ? EColor.GetColor() : Color.Red); } if (RColor.BoolValue) { R.DrawSpell(R.IsReady() ? RColor.GetColor() : Color.Red); } } }
private static List <Tuple <byte, byte> > Capture(BoardStatus newStatus, byte row, byte col, WColor color) { var capturedStones = new List <Tuple <byte, byte> >(); BoardBase bbTemp = new BoardBase(newStatus.Board); if (!captureKernel(bbTemp, capturedStones, row, col, color)) { capturedStones.Clear(); } return(capturedStones); }
public void Play(byte row, byte col, WColor color) { _currentStatus.Turn = color; Play(row, col); }