public static IEnumerable<IMove> GetAllMovesForPlayer(GameBoard board, PlayerColor player) { IEnumerable<GameField> fields = board.GetFieldsByPlayer(player); List<IMove> forcedMoves = new List<IMove>(); List<IMove> idleMoves = new List<IMove>(); bool forcedOnly; foreach (GameField f in fields) { var moves = GetAllMovesFromField(board, f.Position, out forcedOnly); if (forcedOnly) forcedMoves.AddRange(moves); else idleMoves.AddRange(moves); } if (forcedMoves.Count > 0) { int longest = 0; forcedMoves.ForEach(mv => { if (mv.Length > longest) longest = mv.Length; }); return forcedMoves.Where(mv => mv.Length == longest).ForEach<IMove, GameBoard>(SetMoveCaptures, board); } return idleMoves; }
public static bool CheckForGameEnd(GameBoard board, out PlayerColor winner) { int whitePieces = board.GetPieceCountByOccupation(PlayerColor.White); int blackPieces = board.GetPieceCountByOccupation(PlayerColor.Black); if (whitePieces == 0) { winner = PlayerColor.Black; return true; } else if (blackPieces == 0) { winner = PlayerColor.White; return true; } else if (board.IdleMoves >= MAX_IDLE_MOVES) { if (whitePieces == blackPieces) { winner = PlayerColor.None; return true; } winner = whitePieces > blackPieces ? PlayerColor.White : PlayerColor.Black; return true; } winner = PlayerColor.None; return false; }
public Piece(PlayerColor playerColor, PieceType pieceType, byte x, byte y) { playerColorValue = playerColor; pieceTypeValue = pieceType; xValue = x; yValue = y; }
// Use this for initialization void Start() { animator = gameObject.GetComponent<Animator>(); //Set initial color playerColor = PRIVATE_playerColor; }
private static Player CreatePlayer(string name, PlayerColor color, Sex sex, int n) { var player = new Player(name, color, sex); int i = 0; StuffManager stuffManager = StuffManager.Instance; foreach (IDxMCard dxMCard in stuffManager.DxMCards) { if (dxMCard is ICheatCard) continue; if (dxMCard is IRaceCard && player.RaceCards.Count < 2) player.RaceCards.Add((IRaceCard)dxMCard); else if (dxMCard is IClassCard && player.ClassCards.Count < 2) player.ClassCards.Add((IClassCard)dxMCard); else if (dxMCard is IHalfBreededCard) player.HalfBreededCard = (IHalfBreededCard)dxMCard; else if (dxMCard is ISuperManchkinCard) player.SuperManchkinCard = (ISuperManchkinCard)dxMCard; else player.HandCards.Add(dxMCard); } foreach (ITreasureCard treasureCard in stuffManager.TreasureCards) { ICheatCard cheatCard = i++ == 4 ? stuffManager.DxMCards.OfType<ICheatCard>().Single() : null; player.WornItems.Add(Tuple.Create(treasureCard, cheatCard)); } /* for (int j = 0; j < n * 2; j++) player.HandCards.Add(cardManager.TreasureCards.First()); */ return player; }
void ChangeOutfit(PlayerColor color) { transform.FindChild("Change_Fx_Front").GetComponent<Animator>().SetTrigger("Change"); transform.FindChild("Change_Fx_Back").GetComponent<Animator>().SetTrigger("Change"); StartCoroutine(DelayToChange(color)); }
public EndGameAction(System.IO.BinaryReader reader) { this.hasCheckmate = reader.ReadBoolean(); if (this.hasCheckmate) this.looser = (PlayerColor)reader.ReadByte(); else this.stalemateReason = (StalemateReason)reader.ReadByte(); }
public Player(string name, int playerNumber, PlayerColor color, string textualRepresentation) { this.Pawns = new List<Pawn>(5); this.Name = name; this.PlayerNumber = playerNumber; this.Color = color; this.TextualRepresentation = textualRepresentation; }
public Player GetPlayer(PlayerColor color) { if (this.PlayerColor == color) return new HumanPlayer(); //return new ComputerPlayer(AILevel.Hard); return new ComputerPlayer(this.AILevel < AILevel.Easy ? AILevel.Medium : this.AILevel); }
public Piece(PlayerColor couleur, String nom) { if (couleur == PlayerColor.White) this.nom = nom + "B"; else this.nom = nom + "N"; this.couleur = couleur; }
public WinBoard(PlayerColor color, AILevel aiLevel, string startFen, string engine) { this.color = color; this.AILevel = aiLevel; this.startFen = startFen; var psi = new ProcessStartInfo { UseShellExecute = false, CreateNoWindow = true, FileName = "engines\\polyglot", Arguments = "engines\\" + engine + ".ini", RedirectStandardInput = true, RedirectStandardOutput = true }; this.process = Process.Start(psi); this.output = this.process.StandardOutput; this.input = this.process.StandardInput; }
private static Image DrawSquare(SquareColor color, PlayerColor player = 0, Type piece = null) { var image = new Bitmap(100, 100); using (var g = Graphics.FromImage(image)) { g.FillRectangle(new SolidBrush(color.ToColor()), 0, 0, 100, 100); if (piece != null) g.DrawImage(Images.GetPieceImage(player, piece), 0, 0, 100, 100); } return image; }
// public void PlayerDied(PlayerColor color) { foreach(var startingPosObj in this.StartingPositions.transform) { var startingPos = ((Transform)startingPosObj).GetComponent<StartingPosition>(); if (startingPos.IsActive && startingPos.PlayerColor == color) { StartCoroutine( startingPos.SpawnPlayer() ); break; } } }
public Player(PlayerColor color, RaceName race, bool isHuman) { Color = color; Race = race; Money = 70; TimeLeft = 30 * 25; MaxTurnTime = 30 * 25; UnitCount = 0; StationCount = 0; IsHuman = isHuman; Strategy = new HumanStrategy(); }
// Use this for initialization void Start() { var kvp = PlayerManager.Instance.GetPlayerFor( this.MatchupForPlayers ); if (kvp.HasValue) { this.IsActive = true; this.PlayerColor = kvp.Value.Key; this.playerActions = kvp.Value.Value; StartCoroutine( this.SpawnPlayer() ); } }
private void AddPlayer(string playerTokenUrl, PlayerColor playerColor) { NumberOfPlayers++; var player = new Player { Name = string.Format("Player {0}", NumberOfPlayers), ImageUri = new Uri(playerTokenUrl), TurnOrder = NumberOfPlayers, GameTokenColor = playerColor }; PlayerList.Add(player); }
public void ComputeBestMove(GameBoard board, PlayerColor player, int depth) { VerifyAccess(); Reset(); CTS = new CancellationTokenSource(); AIState state = new AIState(board, player, depth); _task = new Task<IMove>(GetBestMove, state, CTS.Token); _task.ContinueWith(task => { BestMove = task.Result; Dispatcher.BeginInvoke((Action)OnBestMoveChosen, null); }); _task.Start(); }
public static bool isLegalMove(Piece movingPiece, Piece targetPiece, PlayerColor currentPlayer) { if (movingPiece.playerColor == currentPlayer && targetPiece.playerColor != currentPlayer) { if (Math.Abs(movingPiece.x - targetPiece.x) == 1) { if ((movingPiece.playerColor == PlayerColor.White && movingPiece.y - targetPiece.y == 1) || (movingPiece.playerColor == PlayerColor.Black && movingPiece.y - targetPiece.y == -1)) return true; } } return false; }
public static PlayerColor OtherPlayer(PlayerColor player) { switch (player) { case PlayerColor.None: throw new ArgumentException(); case PlayerColor.Black: return PlayerColor.White; case PlayerColor.White: return PlayerColor.Black; default: throw new ArgumentException(); } }
public Token3D(Vector3D basePoint, PlayerColor color) : base(basePoint) { switch (color) { case PlayerColor.Black: firstColor = Color.Blue; secondColor = Color.DarkBlue; break; case PlayerColor.White: firstColor = Color.Red; secondColor = Color.DarkRed; break; } List<Vector3D> up = new List<Vector3D>(); List<Vector3D> down = new List<Vector3D>(); for (int i = 0; i <= 16; ++i) { int gegenkathete = (int) (Math.Sin((Math.PI / (RESOLUTION / 2)) * i) * RADIUS); int ankathete = (int)(Math.Cos((Math.PI / (RESOLUTION / 2)) * i) * RADIUS); up.Add(new Vector3D(ankathete, gegenkathete, HEIGHT)); down.Add(new Vector3D(ankathete, gegenkathete, 0)); } // Circle down for (int i = 0; i < down.Count - 1; ++i) { this.addTriangle(new Triangle3D(new Vector3D(0, 0, 10), down[i], down[i + 1], firstColor)); } this.addTriangle(new Triangle3D(new Vector3D(0, 0, 10), down[down.Count - 1], down[0], firstColor)); // Side Triangle up, up, down for (int i = 0; i < up.Count - 1; ++i) { this.addTriangle(new Triangle3D(up[i], up[i + 1], down[i], secondColor)); } this.addTriangle(new Triangle3D(up[up.Count - 1], up[1], down[down.Count - 1], secondColor)); // Side Triangle down, down, up for (int i = 0; i < down.Count - 1; ++i) { this.addTriangle(new Triangle3D(down[i], down[i + 1], up[i + 1], secondColor)); } this.addTriangle(new Triangle3D(down[down.Count - 1], down[1], up[1], secondColor)); // Circle Up for (int i = 0; i < up.Count - 1; ++i) { this.addTriangle(new Triangle3D(new Vector3D(0, 0, 10), up[i], up[i + 1], firstColor)); } this.addTriangle(new Triangle3D(new Vector3D(0, 0, 10), up[up.Count - 1], up[0], firstColor)); }
/// <summary> /// Clears the player input for a particular color. /// </summary> /// <param name="playerColor">Player color to clear input of.</param> public void ClearRecordedInput(PlayerColor playerColor) { switch (playerColor) { case PlayerColor.Red: redInput = null; break; case PlayerColor.Green: greenInput = null; break; case PlayerColor.Blue: blueInput = null; break; } }
public Plateau() { rectangleSelection = new Selection(); plateauRectangle = new Rectangle(0, 0, 352, 352); plateauValeur = new Case[8, 8]; positionPossibilities = new List<Point>(); playerTour = PlayerColor.White; pieceIsSelected = false; isEchec = false; isEchecEtMat = false; CaseHeight = 44; CaseWidth = 44; }
/// <summary> /// Konstruktor. Inicializálja az objektumot. /// </summary> /// <param name="Name"></param> /// <param name="Color"></param> public Player(string name, PlayerColor color) { Name = name; Color = color; Materials = new Dictionary<Material, int>(); Settlements = new List<Settlement>(); Roads = new List<Road>(); TradeItems = new Dictionary<Material, TradeItem>(); Gold = 1000; Materials.Add(Material.Clay, 5); Materials.Add(Material.Iron, 5); Materials.Add(Material.Wheat, 5); Materials.Add(Material.Wood, 5); Materials.Add(Material.Wool, 5); }
public Player(string name, PlayerColor color, Sex sex) { Name = name; Color = color; Sex = sex; Level = 1; WornItems = new List<Tuple<ITreasureCard, ICheatCard>>(); InPackItems = new List<ITreasureCard>(); RaceCards = new List<IRaceCard>(); ClassCards = new List<IClassCard>(); HandCards = new List<ICard>(); Golds = 300; HealthTokensTotal = HealthTokensActive = 4; StepsPerformed = 0; Location = null; // to be set }
public Color Convert(PlayerColor value, Type targetType, object parameter, CultureInfo culture) { switch (value) { case PlayerColor.Blue: return Colors.Blue; case PlayerColor.Red: return Colors.Red; case PlayerColor.Green: return Colors.Green; case PlayerColor.Orange: return Colors.Orange; default: throw new ArgumentOutOfRangeException("value", "Nincs ilyen szín definiálva!"); } }
private int Compute(ref IMove bestMove, GameBoard board, PlayerColor currentPlayer, int startDepth, int depth) { CheckForStop(); if (depth == 0) return Evaluator.Evaluate(board, currentPlayer); var moves = RuleEngine.GetAllMovesForPlayer(board, currentPlayer); CheckForStop(); if (moves.Count() == 0) return Evaluator.Evaluate(board, currentPlayer); int bestValue = int.MinValue; PlayerColor opponent = GameUtils.OtherPlayer(currentPlayer); GameBoard boardCopy = board.Copy(); CheckForStop(); foreach (var move in moves) { CheckForStop(); boardCopy.DoMove(move, true); int moveValue = -Compute(ref bestMove, boardCopy, opponent, startDepth, depth - 1); IMove revMove = move.Reverse(); boardCopy.DoMove(revMove, true); CheckForStop(); if (depth == startDepth) { Trace.WriteLine(string.Format("Move: {0} Value: {1}", move.ToString(), moveValue.ToString())); if (bestMove == null || moveValue > bestValue) { bestMove = move; } } bestValue = Math.Max(bestValue, moveValue); } return bestValue; }
public Color playerColorToColorBG(PlayerColor pc) { switch (pc) { case PlayerColor.Red: return Color.Red; case PlayerColor.Blue: return Color.FromArgb(0, 8, 160); case PlayerColor.Cyan: return Color.FromArgb(0, 164, 120); case PlayerColor.Purple: return Color.FromArgb(112, 8, 160); case PlayerColor.Yellow: return Color.FromArgb(160, 164, 0);//Color.Yellow; case PlayerColor.Orange: return Color.FromArgb(160, 112, 0); case PlayerColor.Green: return Color.Green; case PlayerColor.Pink: return Color.FromArgb(152, 84, 136); case PlayerColor.Gray: return Color.FromArgb(112, 120, 112); case PlayerColor.LightBlue: return Color.FromArgb(112, 140, 160);//Color.LightSkyBlue; case PlayerColor.DarkGreen: return Color.FromArgb(40, 108, 72); case PlayerColor.Brown: return Color.FromArgb(80, 56, 32); case PlayerColor.Observer: return Color.White; default: return Color.Black; } }
public PlayerGalleryViewModel(Game game, PlayerColor color) { Game = game; Color = color; HasPlayer = game.Players.Any(p => p.Color == color); EmptyGalleryCssClass = HasPlayer ? "" : "unused-gallery-region"; IsGalleryFirst = color == PlayerColor.yellow || color == PlayerColor.purple; GalleryVisitors = game.VisitorByPlayerAndLocation(color, GameVisitorLocation.Gallery); GalleryInvestorCount = GalleryVisitors.Where(v => v.Type == VisitorTicketType.investor).Count(); GalleryCollectorCount = GalleryVisitors.Where(v => v.Type == VisitorTicketType.collector).Count(); GalleryVipCount = GalleryVisitors.Where(v => v.Type == VisitorTicketType.vip).Count(); GalleryVisitorCounts = new List<int> { GalleryInvestorCount, GalleryCollectorCount, GalleryVipCount }; LobbyVisitors = game.VisitorByPlayerAndLocation(color, GameVisitorLocation.Lobby); LobbyInvestorCount = LobbyVisitors.Where(v => v.Type == VisitorTicketType.investor).Count(); LobbyCollectorCount = LobbyVisitors.Where(v => v.Type == VisitorTicketType.collector).Count(); LobbyVipCount = LobbyVisitors.Where(v => v.Type == VisitorTicketType.vip).Count(); LobbyVisitorCounts = new List<int> { LobbyInvestorCount, LobbyCollectorCount, LobbyVipCount }; }
IEnumerator DelayToChange(PlayerColor color) { yield return new WaitForSeconds(0.5f); _animator.SetInteger("color", (int)color); switch(color) { case PlayerColor.Fire: _light.color = new Color(1, 0, 0); break; case PlayerColor.Water: _light.color = new Color(0, 0.3f, 1); break; case PlayerColor.Grass: _light.color = new Color(0, 1, 0); break; case PlayerColor.None: _light.color = new Color(0.5f, 0.5f, 0.5f); break; } }
/// <summary> /// Adds the player input to this input frame. This replaces already existing input! /// </summary> /// <param name="playerColor">Player color to add</param> /// <param name="recordedInput">Recorded input to add</param> public void AddPlayerInput(PlayerColor playerColor, CapturedInput capturedInput) { switch (playerColor) { case PlayerColor.Red: if (redInput != null) Debug.LogWarning("Replaced red input where input already existed!"); redInput = capturedInput; break; case PlayerColor.Green: if (greenInput != null) Debug.LogWarning("Replaced green input where input already existed!"); greenInput = capturedInput; break; case PlayerColor.Blue: if (blueInput != null) Debug.LogWarning("Replaced blue input where input already existed!"); blueInput = capturedInput; break; } }
/// <summary> /// 先後を駒の色フラグに変換 /// </summary> /// <param name="color"></param> /// <returns></returns> public static Piece PieceFlagFromColor(PlayerColor color) { return((Piece)((int)color << ColorShift)); }
private void SetModalOptions(ModalEV modal, PlayerColor victoriousPlayer) { SetModalType(modal, ModalType.CHECKMATE); SetModalVictoriousPlayer(modal, victoriousPlayer); }
public bool IsAlreadyConnected(City origin, City destination, PlayerColor color) { List <BoardRoute> returnRoutes = new List <BoardRoute>(); // A city is already connected to itself if (origin == destination) { return(true); } // Get next-order connected origin cities for given player var masterOriginList = GetConnectingCitiesForPlayer(origin, color); // Get next-order connected destination cities for given player var masterDestinationList = GetConnectingCitiesForPlayer(destination, color); // If these methods return no routes, there are no possible routes to finish. So we return an empty list. if (!masterOriginList.Any() || !masterDestinationList.Any()) { return(false); } var originCitiesList = masterOriginList.Select(x => x.City); var destinationCitiesList = masterDestinationList.Select(x => x.City); bool targetOrigin = true; // Step through the connected cities to find their next-order destinations. while (!originCitiesList.Intersect(destinationCitiesList).Any() && originCitiesList.Count() < 500) { if (targetOrigin) { var copyMaster = new List <City>(originCitiesList); foreach (var originCity in copyMaster) { masterOriginList.AddRange(GetConnectingCitiesForPlayer(originCity, color)); } } else { var copyMaster = new List <City>(destinationCitiesList); foreach (var destinationCity in copyMaster) { masterDestinationList.AddRange(GetConnectingCitiesForPlayer(destinationCity, color)); } } targetOrigin = !targetOrigin; } // It is possible that there are no connecting routes left. // In that case, the collections for master cities get very large // If they get very large, assume no connections exist. if (originCitiesList.Count() >= 500) { return(false); } // If midpoint exists, find it var midpointCity = originCitiesList.Intersect(destinationCitiesList).First(); // Check for direct routes between the origin and midpoint var originDirectRoute = GetDirectRouteForPlayer(origin, midpointCity, color); // Check for direct routes between midpoint and destination var destinationDirectRoute = GetDirectRouteForPlayer(midpointCity, destination, color); if (originDirectRoute != null) { returnRoutes.Add(originDirectRoute); } if (destinationDirectRoute != null) { returnRoutes.Add(destinationDirectRoute); } // If no direct route from origin to midpoint is found, recursively call this method to find multiple routes between origin and midpoint. if (originDirectRoute == null) { return(false || IsAlreadyConnected(origin, midpointCity, color)); } //If no direct route from midpoint to destination is found, recursively call this method to find multiple routes between midpoint and destination. if (destinationDirectRoute == null) { return(false || IsAlreadyConnected(midpointCity, destination, color)); } return(returnRoutes.Any()); }
/// <summary> /// Selects a new color in the combobox of the host. /// </summary> public void SelectNewColor(PlayerColor newColor) { this.extComboChMgr.ChangeSelectedIndex(this.cbColorSelector, (int)newColor); }
public void Initialize(int playerNumber, int playerModelNumber, CharacterStats stats, Ability ability, Weapon weapon, PlayerColor color, Game parentGame) { this.parentGame = parentGame; this.playerNumber = playerNumber; this.playerModelNumber = playerModelNumber; playerStats = stats; currentAbility = ability; currentWeapon = weapon; playerColor = color; }
public Pawn(Type type, PlayerColor color, Vector2Int pos) : base(type, color, pos) { }
public Queen(ChessPosition startingPosition, PlayerColor owner) : base(startingPosition, owner) { }
public override void onOutgoingLocalMsg(string msg, PlayerColor color) { }
public Snake(PlayerColor color) { this.color = color; this.body = new LinkedList <Coordinate>(); }
public PlaceRoadAction(HexEdge edge, PlayerColor color) { Edge = edge; Color = color; }
public HumanPlayer(string name, PlayerColor color) : base(name, color) { }
public Bishop(PlayerColor _color, Coordinate cord) : base(_color, cord.Column, cord.Row) { }
public static PlayerColor Opp(this PlayerColor color) { return(color ^ PlayerColor.White); }
public bool IsCommanderInCheck(PlayerColor turnPlayer, IEntitiesDB entitiesDB) { return(destinationTileService.CalcNumCommanderThreats(turnPlayer, entitiesDB) > 0); }
public static char ToChar(this PlayerColor color) { return(color == PlayerColor.Black ? '▲' : '△'); }
public static PlayerColor ConvertPlayerColor(int i) { return(PlayerColor.GetPlayerColor(i)); }
public static string GetImageSource(PlayerColor color, PieceType type) { string directory = "Images/"; switch (type) { case PieceType.Bishop: if (color == PlayerColor.White) { return(directory + "white_bishop.png"); } else { return(directory + "black_bishop.png"); } case PieceType.Rook: if (color == PlayerColor.White) { return(directory + "white_rook.png"); } else { return(directory + "black_rook.png"); } case PieceType.Queen: if (color == PlayerColor.White) { return(directory + "white_queen.png"); } else { return(directory + "black_queen.png"); } case PieceType.Pawn: if (color == PlayerColor.White) { return(directory + "white_pawn.png"); } else { return(directory + "black_pawn.png"); } case PieceType.King: if (color == PlayerColor.White) { return(directory + "white_king.png"); } else { return(directory + "black_king.png"); } case PieceType.Knight: if (color == PlayerColor.White) { return(directory + "white_knight.png"); } else { return(directory + "black_knight.png"); } default: return(null); } }
public bool Fullfils(PlayerColor color) { return(Color == color); }
public void SetColor(PlayerColor c) { color = c; gameObject.GetComponent <Renderer>().materials[1].color = PlayerColorManager.GetColor(color); }
public Figure(FigureType type, PlayerColor color, bool moved = false) { Type = type; Color = color; Moved = moved; }
public PlayerInfo(PlayerColor color, string name) { Color = color; Name = name; }
public static void AddPoints(PlayerColor color) { points[color] += previousPlayerDeaths; previousPlayerDeaths++; }
public static PlayerColor Opposing(this PlayerColor color) { return(color == PlayerColor.Black ? PlayerColor.White : PlayerColor.Black); }
/// <summary> /// 駒のタイプと色から駒をさくせい /// </summary> /// <param name="piece"></param> /// <param name="pt"></param> /// <param name="color"></param> public static Piece MakePiece(PieceType pt, PlayerColor color) { return((Piece)((int)pt | ((int)color << ColorShift))); }
public void CmdSetColor(PlayerColor c) { color = c; }
public Knight(ChessPosition startingPosition, PlayerColor owner) : base(startingPosition, owner) { }
public override void onOutgoingLocalMsg(string msg, PlayerColor color) { sendServerMsg(msg, color, (short)CommProtocol.MsgType.move); }
public bool Fullfils(PlayerColor color, FigureType type) { return(Fullfils(color) && Fullfils(type)); }
public Bishop(PlayerColor _color, int _column, int _row) : base(_color, _column, _row) { }
public int CalcNumCommanderThreats(PlayerColor commanderColor, IEntitiesDB entitiesDB) { return(destinationTileService.CalcNumCommanderThreats(commanderColor, entitiesDB)); }