Example #1
0
        public void createBoard(GameObject prefab, int x, int y)
        {
            colors = new Dictionary<byte, Color>();
            colors.Add(0, Color.black);
            colors.Add(1, Color.red);
            colors.Add(2, Color.green);
            colors.Add(3, Color.blue);
            colors.Add(4, Color.gray);
            colors.Add(5, Color.cyan);
            colors.Add(6, Color.magenta);
            colors.Add(7, Color.yellow);
            colors.Add(8, Color.white);

            _cellSprite = prefab;
            maxX = x;
            maxY = y;
            _field = new byte[x * y];
            _fieldVisual = new CellRotator[x * y];
            for (int i = 0; i < maxX; i++) {
                for (int j = 0; j < maxY; j++) {
                    var z = Instantiate (_cellSprite);
                    z.transform.position = new Vector2 (j + 0.5f, -i - 0.5f);
                    z.transform.parent = transform;
                    z.name = (i * maxX).ToString() + '_' + j.ToString();
                    _fieldVisual[i * maxX + j] = z.GetComponent<CellRotator> ();
                    _fieldVisual[i * maxX + j].instantOff();
                }
            }

            _state = BoardState.INITIALIZED;
            _mainP = FindObjectOfType<MainProxy>();
            seedPrefab = _mainP.seedPrefab;
        }
Example #2
0
        private void DebugPrintBoard(BoardState board, int indent = 0)
        {
            Debug.WriteLine("");
            Debug.Write(new string('\t', indent));
            Debug.Write(new string('-', _gameConfiguration.NumberOfPits/2*3));
            Debug.WriteLine("");
            Debug.Write(new string('\t', indent));

            for (var pit = _gameConfiguration.NumberOfPits - 1; pit >= _gameConfiguration.NumberOfPits/2; pit--)
            {
                Debug.Write(board[pit].ToString().PadRight(3));
            }

            Debug.WriteLine("");
            Debug.Write(new string('\t', indent));

            for (var pit = 0; pit < _gameConfiguration.NumberOfPits/2; pit++)
            {
                Debug.Write(board[pit].ToString().PadRight(3));
            }

            Debug.WriteLine("");

            Debug.Write(new string('\t', indent));
            Debug.Write(new string('-', _gameConfiguration.NumberOfPits/2*3));
            Debug.WriteLine("");
        }
Example #3
0
 public void When_XGoesCorner_Then_TheBoardIsX00000000()
 {
     var board = new BoardState().Set(0, BoardMark.X);
     AssertBoardPositions(board.FreePositions, 1, 2, 3, 4, 5, 6, 7, 8);
     AssertBoardPositions(board.GetPositions(BoardMark.X), 0);
     AssertBoardPositions(board.GetPositions(BoardMark.O));
 }
Example #4
0
 public void When_XGoesCorner_and_OGoesSide_Then_TheBoardIsXO0000000()
 {
     var board = new BoardState().Set(0, BoardMark.X).Set(1, BoardMark.O);
     AssertBoardPositions(board.FreePositions, 2, 3, 4, 5, 6, 7, 8);
     AssertBoardPositions(board.GetPositions(BoardMark.X), 0);
     AssertBoardPositions(board.GetPositions(BoardMark.O), 1);
 }
 //Varibles End ***************************************************************
 // Use this for initialization
 void Start()
 {
     networkManager = GameObject.Find("NetworkManager");
     getInput = networkManager.GetComponent<GetInput>();
     boardState = networkManager.GetComponent<BoardState>();
     animate = networkManager.GetComponent<Animate>();
 }
Example #6
0
 public void When_GameNotStarted_Then_TheBoardIsEmpty()
 {
     var board = new BoardState();
     AssertBoardPositions(board.FreePositions, 0, 1, 2, 3, 4, 5, 6, 7, 8);
     AssertBoardPositions(board.GetPositions(BoardMark.X));
     AssertBoardPositions(board.GetPositions(BoardMark.O));
 }
 public string EvadeMonsters(BoardState state, Player player)
 {
     state.Field.Cards.Clear();
     state.TurnStep = TurnStep.Ending;
     foreach (var p in state.Players)
         Longpool.Longpool.Instance.PushMessageToUser(p.UserId, new Longpool.AsyncMessage(Longpool.MessageType.EndOfTheBattle));
     return ACTION_DONE;
 }
 private StandardPosition(IList<IPosition> circle, int id, BoardState state, int newCardsCount, ISpecialCommand command, bool canSkip)
 {
     this._actualCircle = circle;
     this._id = id;
     this._state = state;
     this._newCardsCount = newCardsCount;
     this._cards = new List<ICard>();
     this._command = command;
     this._canSkip = canSkip;
 }
Example #9
0
    public BoardState Copy()
    {
        BoardState newBoardState = new BoardState();

        foreach (Player player in Players)
            newBoardState.Players.Add(player.Copy());
        foreach (Card card in Cards)
            newBoardState.Cards.Add(card.Copy());
        newBoardState.ActivePlayer = ActivePlayer;
        newBoardState.CurrentTurn = CurrentTurn;

        return newBoardState;
    }
Example #10
0
 private IEnumerable<BoardState> GenerateSuccessors(BoardState currentBoard)
 {
     for (var pit = 0; pit < _gameConfiguration.NumberOfPits/2; pit++)
     {
         if (currentBoard[pit] > 0)
         {
             var successor = Play(currentBoard, pit);
             if (IsLegalPlay(currentBoard, successor, pit))
             {
                 yield return successor;
             }
         }
     }
 }
Example #11
0
 public BoardStateInfo(BoardState b)
 {
     CurrentPlayerId = b.CurrentPlayerId;
     Players = new List<PlayerInfo>();
     foreach (var p in b.Players)
     {
         if (p.UserId == CurrentUser.Instance.Current.Id)
             Me = p;
         else
             Players.Add(new PlayerInfo(p));
     }
     TurnStep = b.TurnStep;
     Battle = b.Battle;
     FieldCards = b.Field.Cards;
 }
Example #12
0
    //Varibles End ***********************************************************************************
    // Use this for initialization
    void Start()
    {
        //This is so I can access the array and find out what the tile ought to be doing.
        networkManager = GameObject.Find("NetworkManager");
        boardState = networkManager.GetComponent<BoardState>();
        getInput = networkManager.GetComponent<GetInput>();

        defaultColor = this.renderer.material.color;

        x = (int)this.transform.position.x / 10;
        y = (int)this.transform.position.z / 10;

        //TODO Grab this info from the player / Network
        colorPlayerOne = Color.red;
        colorPlayerTwo = Color.blue;
    }
Example #13
0
    public void UpdateCardTexture(bool alwaysShow, BoardState board, Card card, CardStates State, string classType)
    {
        StringBuilder ImagePath = new StringBuilder(@"Textures/Cards/");
        ImagePath.Append(card.GetCardGFX());
        StringBuilder CardbackPath = new StringBuilder(@"Textures/");
        if (card.PlayerID == 0)
            CardbackPath.Append("Lannister cardback");
        else
            CardbackPath.Append("Stark cardback");

        int attack = board.GetCardAttack(card);
        string manaString = "<b>" + board.GetCardManaCost(card).ToString() + "</b>";
        string attackString = "<b>" + attack.ToString() + "</b>";
        string healthString = "<b>" + board.GetCardHealth(card).ToString() + "</b>";
        if (board.GetCardMaxHealth(card) > board.GetCardHealth(card))
            healthString = "<color=MAROON>" + healthString + "</color>";
           UpdateCard(alwaysShow || State == CardStates.InHand && card.PlayerID == 0,@"<b>" + card.GetName() + @"</b>", ImagePath.ToString(), CardbackPath.ToString(), manaString, attackString, attack > 0, healthString, State, classType);
    }
Example #14
0
        public void Start()
        {
            if (State != State.Lobby && State != State.Created)
                throw new WrongMatchStateException();

            // todo: define somewhere
            if (Players.Count != 4)
            {
                for (int i = Players.Count; i < 4; i++)
                    Players.Add(new Player());
                //throw new NotEnoughPlayersException();
            }

            State = State.InGame;

            BoardState = new BoardState(Players);
            SetRandomStartPlayer();
            SendMessageToPlayers(new AsyncMessage(MessageType.GameStarted));
        }
Example #15
0
    /*private void UpdateBoard()
    {
        foreach(Card card in Cards)
            if (card.State == CardStates.OnBoard && card.Health <= 0)
                DoDie (card.ID);
    }*/
    public static bool CanDoAction(BoardState InitialState, BoardAction Action)
    {
        if (Action.Type == "ACTION_DRAW_CARDS")
            return true;
        if (Action.Type == "ACTION_DEAL_DAMAGE")
            return true;
        if (Action.Type == "ACTION_START_TURN")
            return true;
        if (Action.Type == "ACTION_END_TURN")
            return true;
        if (Action.Type == "ACTION_PLAY_CARD")
        {
            Card ActorCard = InitialState.GetCard((int)Action.Actor);
            BoardState.Player Player = InitialState.Players[(int)Action.Player];
            return Player.CurrentMana >= InitialState.GetCardManaCost(ActorCard) && Action.Player == InitialState.ActivePlayer && ActorCard.State == CardStates.InHand;
        }
        if (Action.Type == "ACTION_ATTACK")
        {
            Card ActorCard = InitialState.GetCard((int)Action.Actor);
            int TargetID = (int)Action.Target;
            Card TargetCard = InitialState.GetCard(TargetID);

            if (ActorCard.CanAttack == false)
                return false;
            if (Action.Player != InitialState.ActivePlayer)
                return false;
            if (ActorCard.PlayerID == TargetCard.PlayerID)
                return false;
            if (InitialState.GetCardAttack(ActorCard) > 0 && (ActorCard.State == CardStates.Hero || ActorCard.State == CardStates.OnBoard) && (TargetCard.State == CardStates.Hero || TargetCard.State == CardStates.OnBoard))
                return true;

            return false;
        }
        if (Action.Type == "ACTION_DIE")
            return true;
        return true;
    }
Example #16
0
        public Boolean makeMove(Move move)
        {
            if (move == null)
                return false;
            if (!isValidSquare(move.To) || !isValidSquare(move.From))
                return false;

            Piece from = this.getPiece(move.From);
            if (from == null)
                return false;
            if (from.PieceColor != CurrentColor)
                return false;

            Piece to = this.getPiece(move.To);
            if (to != null && to.PieceColor == CurrentColor)
                return false;

            if (from.isValidMove(move)) {
                this.board[move.To.x, move.To.y] = from;
                this.board[move.From.x, move.From.y] = null;
                PreviousMove lastMove = new PreviousMove();
                lastMove.Move = move;
                lastMove.FromPiece = from;
                lastMove.ToPiece = to;
                lastMove.CurrentState = this.State;
                lastMove.CurrentColor = this.CurrentColor;
                lastMove.CurrentTurn = this.CurrentTurn;
                lastMove.CurrentHash = this.Hash;
                this.lastMoves.Push(lastMove);

                if (from.PieceType == Piece.Type.p) {
                    if (from.PieceColor == Piece.Color.Black) {
                        if (move.To.x == HEIGHT - 1) {
                            Piece nq = new Piece(Piece.Type.q, from.PieceColor);
                            this.board[move.To.x, move.To.y] = nq;
                        }
                    }
                    else {
                        if (move.To.x == 0) {
                            Piece nq = new Piece(Piece.Type.q, from.PieceColor);
                            this.board[move.To.x, move.To.y] = nq;
                        }
                    }
                }

                this.Hash = 0;

                if (to != null && to.PieceType == Piece.Type.k)
                    this.State = from.PieceColor == Piece.Color.Black ? BoardState.BlackWinner : BoardState.WhiteWinner;
                else {
                    this.CurrentColor = this.CurrentColor == Piece.Color.Black ? Piece.Color.White : Piece.Color.Black;
                    if (this.CurrentColor == Piece.Color.White)
                        ++this.CurrentTurn;
                    if (CurrentTurn > 40)
                        this.State = BoardState.Draw;
                }

                return true;
            }

            return false;
        }
Example #17
0
 private static Player GetNextMover(this BoardState currentBoardState)
 {
     return(currentBoardState.CurrentMover == currentBoardState.TopPlayer.Player
                                         ? currentBoardState.BottomPlayer.Player
                                         : currentBoardState.TopPlayer.Player);
 }
Example #18
0
 public void NextPlayer()
 {
     CurrentPlayer   = (CurrentPlayer == BoardState.BLACK) ? BoardState.RED : BoardState.BLACK;
     CurrentOpponent = (CurrentOpponent == BoardState.BLACK) ? BoardState.RED : BoardState.BLACK;
 }
 public static int Evaluate(BoardState board, int openingPhase, int endingPhase, ulong fieldsAttackedByWhite, ulong fieldsAttackedByBlack)
 {
     return(Evaluate(board, Color.White, openingPhase, endingPhase, fieldsAttackedByBlack) -
            Evaluate(board, Color.Black, openingPhase, endingPhase, fieldsAttackedByWhite));
 }
Example #20
0
        public BoardState update()
        {
            Vector3 mouse = GetPickedPosition(
                new Vector2((float)input.MouseHandler.MouseState.X, (float)input.MouseHandler.MouseState.Y));
            bool onEdge = collideWithEdge(mouse);
            lineList[1].Position = mouse;
            lineList[0].Color = Color.OrangeRed;
            lineList[1].Color = Color.OrangeRed;
            if ((state == BoardState.chooseEdge1) && (onEdge))
            {
                    if (input.MouseHandler.WasLeftButtonClicked())
                        state = BoardState.chooseEdge2;
                    else
                        state = BoardState.onEdge1;
            } else
            if ((state == BoardState.onEdge1))
            {
                if (onEdge)
                {
                    if (input.MouseHandler.WasLeftButtonClicked())
                    {
                        lineList[0].Position = p[0].position;
                        state = BoardState.chooseEdge2;
                    }
                } else
                    state = BoardState.chooseEdge1;
            } else
            if ((state == BoardState.chooseEdge2) && (onEdge))
            {
                lineList[1].Position = mouse;
                if (input.MouseHandler.WasLeftButtonClicked())
                    state = BoardState.preFold;
                else
                    state = BoardState.onEdge2;
            } else
            if ((state == BoardState.onEdge2))
            {
                lineList[1].Position = p[1].position;
                lineList[0].Color = Color.Green;
                lineList[1].Color = Color.Green;
                if (onEdge)
                    {
                        if (input.MouseHandler.WasLeftButtonClicked())
                            state = BoardState.preFold;
                    } else
                        state = BoardState.chooseEdge2;
            } else
            if (state == BoardState.preFold)
            {
                Divide(p[0], p[1], out one, out two);
                //Tom -- array of all the old fold lines
                oldLineindices.Add((short)oldLineindices.Count);
                oldLineList.Add(new VertexPositionNormalTexture(p[0].position, new Vector3(0,0,0), new Vector2(0f, 0.5f)));
                oldLineindices.Add((short)oldLineindices.Count);
                oldLineList.Add(new VertexPositionNormalTexture(p[1].position,new Vector3(0,0,0), new Vector2(1f, 0.5f)));

                state = BoardState.folding1;
            }
            if ((input.MouseHandler.WasRightButtonClicked()))
            {
                state = BoardState.chooseEdge1;
                angle = 0;
            }

            return state;
        }
Example #21
0
    public override bool isValid(AIState currentState)
    {
        if (currentState.CurrentPlayerState.HandsFree())
        {
            return(false);
        }
        else
        {
            int droppedItemID = currentState.CurrentPlayerState.HoldingItemID;

            if (currentState.ItemStateList[droppedItemID].MyItemType == ItemType.MEAL ||
                currentState.ItemStateList[droppedItemID].MyItemType == ItemType.TABLE ||
                currentState.ItemStateList[droppedItemID].MyItemType == ItemType.BOARD)
            {
                return(false);
            }


            if (currentState.ItemStateList[id].MyItemType == ItemType.TABLE)
            {
                TableSpace table = currentState.ItemStateList[id] as TableSpace;
                return(table.IsFree());
            }
            else if (currentState.ItemStateList[id].MyItemType == ItemType.BOARD)
            {
                BoardState board = currentState.ItemStateList[id] as BoardState;
                return((currentState.ItemStateList[droppedItemID].MyItemType == ItemType.INGREDIENT) &&
                       board.IsFree());
            }
            else if (currentState.ItemStateList[id].MyItemType == ItemType.POT)
            {
                if (currentState.ItemStateList[droppedItemID].MyItemType != ItemType.INGREDIENT)
                {
                    return(false);
                }
                else
                {
                    if ((currentState.ItemStateList[droppedItemID] as IngredientState).IsPrepared &&
                        (currentState.ItemStateList[droppedItemID] as IngredientState).IsSpawned)
                    {
                        PotState  pot  = currentState.ItemStateList[id] as PotState;
                        MealState meal = currentState.ItemStateList[pot.mealID] as MealState;
                        return(meal.MealSize() + 1 <= PotState.MAX_ITEMS_PER_POT && !meal.IsBurnt());
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else if (currentState.ItemStateList[id].MyItemType == ItemType.PLATE)
            {
                if (currentState.ItemStateList[droppedItemID].MyItemType != ItemType.INGREDIENT)
                {
                    return(false);
                }
                else
                {
                    PlateState plate = currentState.ItemStateList[id] as PlateState;
                    MealState  meal  = currentState.ItemStateList[plate.mealID] as MealState;
                    return((currentState.ItemStateList[droppedItemID] as IngredientState).IsPrepared &&
                           (currentState.ItemStateList[droppedItemID] as IngredientState).IsSpawned &&
                           !plate.IsSubmitted &&
                           !meal.IsBurnt());
                }
            }
            else
            {
                return(false);
            }
        }
    }
Example #22
0
        public void GameStartState_SolvedCheck_Correct(BoardState startState, bool expected)
        {
            var sut = new Game(startState);

            Assert.Equal(expected, sut.IsSolved);
        }
Example #23
0
 private float EstimateEnvironment(BoardState state, (char row, int col) position, ((char row, int col)p1, (char row, int col)p2) opPositions)
Example #24
0
 public void CloneFrom(BoardState source)
 {
     CloneFrom(source.board);
 }
Example #25
0
 protected override void OnUpdateBoardState(BoardState aBoardState)
 {
     this.text.text = aBoardState.par.ToString();
     this.leftButton.interactable  = (aBoardState.par != 1);
     this.rightButton.interactable = (aBoardState.par != Constants.MAXPAR);
 }
Example #26
0
 public GameHistory With(Turn turn, BoardState nextState)
 => new GameHistory(
     States.Append(nextState).ToArray(),
     Turns.Append(turn).ToArray());
Example #27
0
 private void PrisonerGetBlocked(BoardState board)
 {
     boardState = board;
     MessageBox.Show("Player cant move, switch turn");
 }
Example #28
0
 public void DoMove(BoardState currentState)
 {
     NextMoveAvailable?.Invoke(new Capitulation());
 }
Example #29
0
        public Boolean undoLastMove()
        {
            if (lastMoves.Count < 1)
                return false;
            PreviousMove lastMove = lastMoves.Pop();
            if (lastMove.FromPiece == null || lastMove.Move == null)
                return false;

            this.setPiece(lastMove.Move.To, lastMove.ToPiece);
            this.setPiece(lastMove.Move.From, lastMove.FromPiece);
            this.CurrentTurn = lastMove.CurrentTurn;
            this.CurrentColor = lastMove.CurrentColor;
            this.State = lastMove.CurrentState;
            this.Hash = lastMove.CurrentHash;
            return true;
        }
Example #30
0
    public void NewTurn(BoardState newState)
    {
        int turnCount = board.currentGame.GetTurnCount() + board.currentGame.turnHistory.Count % 2;

        NewTurn(newState, turnCount);
    }
Example #31
0
 //public void initLevel(List<IDictionary<string, string>> data)
 //{
 //    List<Vector3> vecs = new List<Vector3>();
 //    List<Vector2> tex = new List<Vector2>();
 //    foreach (IDictionary<string, string> item in data)
 //    {
 //       Vector3 temp = new Vector3();
 //       temp.X = Convert.To (item["x"])  ( item["x"];
 //    }
 //}
 public void DrawfoldPart()
 {
     if (state == BoardState.folding1)
     {
         one.foldShape(angle);
         one.Draw();
         angle -= Game1.closeRate;
         if (angle < -MathHelper.Pi + 1.8f * Game1.closeRate)
             state = BoardState.folding2;
     }
     else
         if (state == BoardState.folding2)
         {
             one.foldShape(angle);
             one.Draw();
             angle += Game1.openRate;
             if (angle > 0)
                 state = BoardState.chooseEdge1;
         }
 }
Example #32
0
 public override void Delete(BoardState state)
 {
     state.Wires.Remove(this);
     RemoveConnections(state.Connections);
 }
Example #33
0
 public override string Execute(BoardState state, Player invoker, ITarget target)
 {
     return SetRace(invoker, target as Card);
 }
Example #34
0
 public override async Task Draw(PainterScope scope, BoardState state)
 {
     await WirePainter.DrawWireLine(scope, state, this);
 }
Example #35
0
 public Task <GameState> Process(BoardState boardState)
 {
     return(Task.Run(() => GetActions(boardState)));
 }
        public static string formatBoardMsgFromServer(string rawBoard, Game.PlayerColor color, BoardState state = BoardState.ongoing)
        {
            rawBoard = replaceServerFormat(rawBoard, color);
            JSONObject jMsg = new JSONObject();

            jMsg.AddField(Consts.Fields.board, createJGrid(rawBoard));
            jMsg.AddField(Consts.Fields.boardState, state.ToString());

            return(jMsg.Print());
        }
Example #37
0
 public abstract ReadOnlyCollection <Move> GetCandidateMoves(BoardState board, ChessPiece piece);
 public override string Execute(BoardState state, Player invoker, ITarget target)
 {
     return RemoveAfterUse(state, target as Card);
 }
        public static double KnightProbability(int N, int K, int r, int c)
        {
            if (K == 0)
            {
                return(1);
            }

            int[][] neighbors = new int[][] { new int[] { -1, -2 }, new int[] { -2, -1 }, new int[] { -2, 1 }, new int[] { -1, 2 }, new int[] { 1, -2 }, new int[] { 2, -1 }, new int[] { 1, 2 }, new int[] { 2, 1 } };

            BoardState[,] dp = new BoardState[N, N];
            BigInteger[] validMoves    = new BigInteger[K];
            BigInteger[] possibleMoves = new BigInteger[K];
            int          maxDepth      = 0;

            BigInteger[,] prevCoordinates = new BigInteger[N, N];
            BigInteger[,] currCoordinates = new BigInteger[N, N];

            BigInteger a = 2;

            a += 2 * 5;

            prevCoordinates[r, c] = 1;

            int elementCount = 1;

            for (int i = 0; i < K && elementCount != 0; i++)
            {
                elementCount = 0;

                for (int j = 0; j < N; j++)
                {
                    for (int k = 0; k < N; k++)
                    {
                        if (prevCoordinates[j, k] != 0)
                        {
                            elementCount++;
                            if (dp[j, k] != null)
                            {
                                foreach (var coord in dp[j, k].Neighbors)
                                {
                                    currCoordinates[coord.Item1, coord.Item2] += prevCoordinates[j, k];
                                }

                                validMoves[i]    += dp[j, k].ValidMoves * prevCoordinates[j, k];
                                possibleMoves[i] += 8 * prevCoordinates[j, k];
                            }
                            else
                            {
                                List <Tuple <int, int> > nb = new List <Tuple <int, int> >();
                                int valid = 0;

                                // Look for neighbors
                                for (int m = 0; m < neighbors.Length; m++)
                                {
                                    int nx = j + neighbors[m][0];
                                    int ny = k + neighbors[m][1];

                                    if (nx >= 0 && nx < N && ny >= 0 && ny < N)
                                    {
                                        nb.Add(new Tuple <int, int>(nx, ny));
                                        valid++;
                                    }
                                }

                                validMoves[i]    += valid * prevCoordinates[j, k];
                                possibleMoves[i] += 8 * prevCoordinates[j, k];
                                foreach (var coord in nb)
                                {
                                    currCoordinates[coord.Item1, coord.Item2] += prevCoordinates[j, k];
                                }
                                dp[j, k] = new BoardState(nb, valid);
                            }
                        }
                    }
                }

                for (int j = 0; j < N; j++)
                {
                    for (int k = 0; k < N; k++)
                    {
                        prevCoordinates[j, k] = currCoordinates[j, k];
                        currCoordinates[j, k] = 0;
                    }
                }
                maxDepth = i + 1;
            }

            double possibility = 1;

            maxDepth = elementCount == 0 ? maxDepth - 1 : maxDepth;

            for (int i = 0; i < maxDepth; i++)
            {
                Console.WriteLine(validMoves[i] + " " + possibleMoves[i]);
                possibility *= ((double)((validMoves[i] * 1000000000000) / possibleMoves[i]) / 1000000000000);
            }

            return(Math.Round(possibility, 5));
        }
Example #40
0
 public static string getStateString(BoardState state)
 {
     switch (state) {
         case BoardState.BlackWinner:
             return "B wins";
         case BoardState.WhiteWinner:
             return "W wins";
         case BoardState.Draw:
             return "Draw";
         case BoardState.Playing:
             return "Playing";
         default:
         case BoardState.Unknown:
             return "Unknown";
     }
 }
 public Road placeFreeRoad(BoardState state)
 {
     return(state.availableRoads.ElementAt(_r.Next(0, state.availableRoads.Count())));
 }
Example #42
0
 public static BoardStateDto ToDto(this BoardState boardState)
 => new()
Example #43
0
        private void stepMovement()
        {
            if (boardState == BoardState.MOVING)
            {
                float currentDistance = (targetPosition - position).magnitude;
                float stepPos = (targetPosition - startPosition).magnitude / totalAnimationTime * Chronos.deltaTime;
                float stepRot = (targetRotation - startRotation).magnitude / totalAnimationTime * Chronos.deltaTime;

                if (currentDistance <= stepPos)
                {
                    position = targetPosition;
                    rotation = targetRotation;
                    boardState = BoardState.NORMAL;
                }
                else
                {
                    position += (targetPosition - position).normalized * stepPos;
                    rotation += (targetRotation - rotation).normalized * stepRot;
                }

            }
        }
 public Settlement placeFreeSettlement(BoardState state)
 {
     return(state.availableSettlements.ElementAt(_r.Next(0, state.availableSettlements.Count())));
 }
        public string RemoveAfterUse(BoardState state, Card card)
        {
            state.Field.Cards.Remove(card);

            return ACTION_DONE;
        }
        private void UpdateIcons()
        {
            IconBoardAttackPlayer.Visibility   = Config.Instance.HidePlayerAttackIcon || _game.IsInMenu ? Collapsed : Visible;
            IconBoardAttackOpponent.Visibility = Config.Instance.HideOpponentAttackIcon || _game.IsInMenu ? Collapsed : Visible;

            // do the calculation if at least one of the icons is visible
            if (_game.SetupDone && (IconBoardAttackPlayer.Visibility == Visible || IconBoardAttackOpponent.Visibility == Visible))
            {
                var board = new BoardState();
                TextBlockPlayerAttack.Text   = board.Player.Damage.ToString();
                TextBlockOpponentAttack.Text = board.Opponent.Damage.ToString();
            }


            var showPlayerCthunCounter      = WotogCounterHelper.ShowPlayerCthunCounter;
            var showPlayerSpellsCounter     = WotogCounterHelper.ShowPlayerSpellsCounter;
            var showPlayerJadeCounter       = WotogCounterHelper.ShowPlayerJadeCounter;
            var showPlayerPogoHopperCounter = WotogCounterHelper.ShowPlayerPogoHopperCounter;

            if (showPlayerCthunCounter)
            {
                var proxy = WotogCounterHelper.PlayerCthunProxy;
                WotogIconsPlayer.Attack = (proxy?.Attack ?? 6).ToString();
                WotogIconsPlayer.Health = (proxy?.Health ?? 6).ToString();
            }
            if (showPlayerSpellsCounter)
            {
                WotogIconsPlayer.Spells = _game.Player.SpellsPlayedCount.ToString();
            }
            if (showPlayerJadeCounter)
            {
                WotogIconsPlayer.Jade = WotogCounterHelper.PlayerNextJadeGolem.ToString();
            }
            if (showPlayerPogoHopperCounter)
            {
                WotogIconsPlayer.PogoHopper = ((_game.Player.PogoHopperPlayedCount + 1) * 2 - 1).ToString();
            }
            WotogIconsPlayer.WotogCounterStyle      = showPlayerCthunCounter && showPlayerSpellsCounter ? Full : (showPlayerCthunCounter ? Cthun : (showPlayerSpellsCounter ? Spells : None));
            WotogIconsPlayer.JadeCounterStyle       = showPlayerJadeCounter ? Full : None;
            WotogIconsPlayer.PogoHopperCounterStyle = showPlayerPogoHopperCounter ? Full : None;

            var showOpponentCthunCounter      = WotogCounterHelper.ShowOpponentCthunCounter;
            var showOpponentSpellsCounter     = WotogCounterHelper.ShowOpponentSpellsCounter;
            var showOpponentJadeCounter       = WotogCounterHelper.ShowOpponentJadeCounter;
            var showOpponentPogoHopperCounter = WotogCounterHelper.ShowOpponentPogoHopperCounter;

            if (showOpponentCthunCounter)
            {
                var proxy = WotogCounterHelper.OpponentCthunProxy;
                WotogIconsOpponent.Attack = (proxy?.Attack ?? 6).ToString();
                WotogIconsOpponent.Health = (proxy?.Health ?? 6).ToString();
            }
            if (showOpponentSpellsCounter)
            {
                WotogIconsOpponent.Spells = _game.Opponent.SpellsPlayedCount.ToString();
            }
            if (showOpponentJadeCounter)
            {
                WotogIconsOpponent.Jade = WotogCounterHelper.OpponentNextJadeGolem.ToString();
            }
            if (showOpponentPogoHopperCounter)
            {
                WotogIconsOpponent.PogoHopper = ((_game.Opponent.PogoHopperPlayedCount + 1) * 2 - 1).ToString();
            }
            WotogIconsOpponent.WotogCounterStyle      = showOpponentCthunCounter && showOpponentSpellsCounter ? Full : (showOpponentCthunCounter ? Cthun : (showOpponentSpellsCounter ? Spells : None));
            WotogIconsOpponent.JadeCounterStyle       = showOpponentJadeCounter ? Full : None;
            WotogIconsOpponent.PogoHopperCounterStyle = showOpponentPogoHopperCounter ? Full : None;
        }
Example #47
0
        public List<Move> getMoves(Piece.Color c)
        {
            List<Move> list = MoveCache.getValueByHash(this.Hash);
            if (list == null) {
                list = new List<Move>();
                for (int x = 0; x < HEIGHT; ++x) {
                    for (int y = 0; y < WIDTH; ++y) {
                        Piece p = board[x, y];
                        if (p != null && p.PieceColor == c) {
                            list.AddRange(getPieceMoves(new Square(x, y)));
                        }
                    }
                }
                MoveCache.storeValue(this.Hash, list);
            }

            if (list.Count < 1)
                this.State = CurrentColor == Piece.Color.Black ? BoardState.WhiteWinner : BoardState.BlackWinner;
            return list;
        }
Example #48
0
        public void Run()
        {
            IsRunning = true;

            computerPlayer = new Player(PlayerType.TopPlayer, botName);
            humanPlayer    = new Player(PlayerType.BottomPlayer);

            bot.Init(computerPlayer.PlayerType, gameConstraints);

            currentBoardState = BoardStateTransition.CreateInitialBoadState(computerPlayer, humanPlayer);
            NewBoardStateAvailable?.Invoke(currentBoardState);

            var moveCounter = 0;

            if (initialProgress != null)
            {
                var moves = ParseProgressText.FromFileText(initialProgress)
                            .Select(MoveParser.GetMove);

                foreach (var move in moves)
                {
                    currentBoardState = currentBoardState.ApplyMove(move);
                    NewBoardStateAvailable?.Invoke(currentBoardState);
                }

                if (moves.Count() % 2 == 1)
                {
                    var succeedGame = DoBotMove();

                    if (!succeedGame)
                    {
                        IsRunning              = false;
                        bot.NextMoveAvailable -= OnNextBotMoveAvailable;
                        return;
                    }
                }

                moveCounter = (int)Math.Ceiling(moves.Count() / 2.0);
            }

            while (!stopRunning)
            {
                if (moveCounter >= gameConstraints.MaximalMovesPerPlayer)
                {
                    WinnerAvailable?.Invoke(computerPlayer, WinningReason.ExceedanceOfMaxMoves, null);
                }

                bool succeedGame;

                succeedGame = DoHumanMove();
                if (!succeedGame)
                {
                    break;
                }


                succeedGame = DoBotMove();
                if (!succeedGame)
                {
                    break;
                }

                moveCounter++;
            }

            IsRunning              = false;
            bot.NextMoveAvailable -= OnNextBotMoveAvailable;
        }
Example #49
0
        public void resetBoard()
        {
            //Black
            //First row
            this.board[0, 0] = new Piece(Piece.Type.k, Piece.Color.Black);
            this.board[0, 1] = new Piece(Piece.Type.q, Piece.Color.Black);
            this.board[0, 2] = new Piece(Piece.Type.b, Piece.Color.Black);
            this.board[0, 3] = new Piece(Piece.Type.n, Piece.Color.Black);
            this.board[0, 4] = new Piece(Piece.Type.r, Piece.Color.Black);
            //Second row
            for (int x = 0; x < WIDTH; ++x)
                this.board[1, x] = new Piece(Piece.Type.p, Piece.Color.Black);
            //White
            //First row

            this.board[HEIGHT - 1, 0] = new Piece(Piece.Type.r, Piece.Color.White);
            this.board[HEIGHT - 1, 1] = new Piece(Piece.Type.n, Piece.Color.White);
            this.board[HEIGHT - 1, 2] = new Piece(Piece.Type.b, Piece.Color.White);
            this.board[HEIGHT - 1, 3] = new Piece(Piece.Type.q, Piece.Color.White);
            this.board[HEIGHT - 1, 4] = new Piece(Piece.Type.k, Piece.Color.White);
            //Second row
            for (int x = 0; x < WIDTH; ++x)
                this.board[HEIGHT - 2, x] = new Piece(Piece.Type.p, Piece.Color.White);

            this.CurrentColor = Piece.Color.White;
            this.CurrentTurn = 1;
            this.State = BoardState.Playing;
            lastMoves = new Stack<PreviousMove>();
            this.Hash = 0;
        }
 public override string Execute(BoardState state, Player invoker, ITarget target)
 {
     return EvadeMonsters(state, invoker);
 }
Example #51
0
 public ActionData(BoardAction Action, BoardState FinalState, List<KeyValuePair<BoardAction, BoardState>> History)
 {
     this.Action = Action;
     this.FinalState = FinalState;
     this.History = History;
 }
Example #52
0
 internal double FaceAttackOnBoard(ICard actionCard, Hero enemyHero, PlayerBoardState playerState, BoardState boardState)
 {
     if (actionCard.GetDamage() >= enemyHero.GetHPLeft())
     {
         return(Double.MaxValue);
     }
     else
     {
         if (playerState.Hero.GetHPLeft() < enemyHero.GetHPLeft())
         {
             return(actionCard.GetDamage() / 4.0);
         }
         else
         {
             return(actionCard.GetDamage());
         }
     }
 }
Example #53
0
        public void Initialize(int vNum, Vector3[] points, Vector2[] texCords)
        {
            pointOnEdge = Vector3.Zero;
            center = Vector3.Zero;
            foreach (Vector3 vec in points)
                center += vec;
            center /= vNum;
            int iCount = (vNum - 3) * 3 + 3;
            vertNum = vNum;

            vertices = new VertexPositionNormalTexture[vNum];
            oldLineList = new List<VertexPositionNormalTexture>();
            oldLineindices = new List<short>();
            lineList = new VertexPositionColor[2];
            lineList[0].Color = Color.Orange;
            lineList[1].Color = Color.Orange;
            lineIndices = new List<short>();
            camera = Game1.camera;
            device = Game1.device;
            input = Game1.input;
            worldMatrix = Matrix.Identity;
            state = BoardState.chooseEdge1;

            indices = new short[iCount];
            invertIndices = new short[iCount];
            for (int i = 0; i < vNum; i++)
            {
                vertices[i].Position = points[i];
                vertices[i].TextureCoordinate = texCords[i];
                vertices[i].Normal = Vector3.Up;
            }
            //create the indices. every 2 consecutive points makes an outer edge (x,y,z) -> xy , yz (not xz)
            short j = 0;
            for (short i = 0; i < iCount; i += 3)
            {
                invertIndices[iCount - (i + 1)] =  indices[i] = (short)(j % vNum);
                invertIndices[iCount - (i + 1) - 1] = indices[i + 1] = (short)((j + 1) % vNum);
                invertIndices[iCount - (i + 1) - 2] = indices[i + 2] = (short)(((j != 4 ? j : 5) + 2) % vNum);
                j += 2;
            }
            verOnEdge = new VertexPositionColor[6];
            verOnEdge[0].Color = Color.Purple;
            verOnEdge[1].Color = Color.Purple;
            verOnEdge[2].Color = Color.Purple;
            verOnEdge[3].Color = Color.Purple;
            verOnEdge[4].Color = Color.Purple;
            verOnEdge[5].Color = Color.Purple;
            p = new DividingVert[2];
        }
Example #54
0
        private List <short> FindBestMove(int player, ref int rating, int initialBestRating, short depth)
        {
            List <short> bestMoves     = new List <short>();
            int          currentRating = -1;
            int          bestRating    = -initialBestRating;

            m_currentTurn += depth;
            BoardState state = EvaluateBoard();

            m_currentTurn -= depth;

            if (state != BoardState.Unfinished)
            {
                switch (state)
                {
                case BoardState.Win:
                    rating = 1;
                    break;

                case BoardState.Lose:
                    rating = -1;
                    break;

                case BoardState.Draw:
                    rating = 0;
                    break;
                }

                return(bestMoves);
            }

            for (int i = 0; i < m_numbersLeft[player].Count; i++)
            {
                short s = m_numbersLeft[player][i];

                m_board[player, s - 1] = (short)(m_currentTurn + depth);
                m_numbersLeft[player].Remove(s);

                if (player == User)
                {
                    FindBestMove(Opponent, ref currentRating, -initialBestRating, depth);
                }
                else if (player == Opponent)
                {
                    if (m_currentTurn + depth + 1 == Turn.Done)
                    {
                        FindBestMove(User, ref currentRating, -initialBestRating, (short)(depth + 1));
                    }
                    else
                    {
                        for (int j = 0; j < m_numbersLeft[Computer].Count; j++)
                        {
                            short t = m_numbersLeft[Computer][j];

                            m_board[Computer, t - 1] = (short)(m_currentTurn + depth + 1);
                            m_numbersLeft[Computer].Remove(t);
                            FindBestMove(User, ref currentRating, -initialBestRating, (short)(depth + 1));
                            m_board[Computer, t - 1] = 0;
                            m_numbersLeft[Computer].Insert(j, t);
                        }
                    }
                }

                if (player == User)
                {
                    if (currentRating > bestRating)
                    {
                        bestMoves.Clear();
                        bestMoves.Add(s);

                        bestRating = currentRating;
                    }
                    else if (currentRating == bestRating)
                    {
                        bestMoves.Add(s);
                    }
                }
                else if (player == Opponent)
                {
                    if (currentRating < bestRating)
                    {
                        bestMoves.Clear();
                        bestMoves.Add(s);

                        bestRating = currentRating;
                    }
                    else if (currentRating == bestRating)
                    {
                        bestMoves.Add(s);
                    }
                }

                m_board[player, s - 1] = 0;
                m_numbersLeft[player].Insert(i, s);
            }

            rating = bestRating;
            return(bestMoves);
        }
Example #55
0
    //Varibles End---------------------------------------------------------
    //NOTE: Looks like this will run before the board is fully filled causing null refrences. This does not crash the game.
    //NOTE: Currently I am leaving it as is. This should be fixed later.
    // Use this for initialization
    void Start()
    {
        networkManager = GameObject.Find("NetworkManager");
        boardState = networkManager.GetComponent<BoardState>();
        getInput = networkManager.GetComponent<GetInput>();

        threatCheckReady = true; // This is just so it will call on startup (threatened tiles)

        //Here I will go ahead and draw up the game board.
        //Each tile will be drawn seprately to allow modification and skins.
        for (int i = 0; i < 8; i++) for (int j = 0; j < 8; j++)
        {
            if (i % 2 == 0)
            {
                if (j % 2 == 0)
                {
                    Instantiate(darkTile, new Vector3(i * 10, 0, j * 10), Quaternion.identity);
                }
                else
                {
                    Instantiate(lightTile, new Vector3(i * 10, 0, j * 10), Quaternion.identity);
                }
            }
            else
            {
                if (j % 2 == 0)
                {
                    Instantiate(lightTile, new Vector3(i * 10, 0, j * 10), Quaternion.identity);
                }
                else
                {
                    Instantiate(darkTile, new Vector3(i * 10, 0, j * 10), Quaternion.identity);
                }
            }//Draw the tile
        }//Draw Loop
    }
Example #56
0
 Task <Turn> IPlayer.NextTurn(BoardState state) => ((IPlayer)TurnCmdHandler).NextTurn(state);
Example #57
0
        public void Run()
        {
            IsRunning = true;

            NewBoardStateAvailable?.Invoke(currentBoardState);

            var moveCounter = 0;

            while (!stopRunning)
            {
                if (moveCounter >= gameConstraints.MaximalMovesPerPlayer)
                {
                    WinnerAvailable?.Invoke(currentBoardState.TopPlayer.Player, WinningReason.ExceedanceOfMaxMoves);
                }

                var nextBottomPlayerBotMove = GetBottomPlayerBotMove();

                if (nextBottomPlayerBotMove == null)
                {
                    break;
                }

                if (!GameAnalysis.IsMoveLegal(currentBoardState, nextBottomPlayerBotMove))
                {
                    WinnerAvailable?.Invoke(currentBoardState.TopPlayer.Player, WinningReason.InvalidMove);
                    break;
                }

                currentBoardState = currentBoardState.ApplyMove(nextBottomPlayerBotMove);
                NewBoardStateAvailable?.Invoke(currentBoardState);

                if (nextBottomPlayerBotMove is Capitulation)
                {
                    WinnerAvailable?.Invoke(currentBoardState.TopPlayer.Player, WinningReason.Capitulation);
                }

                var winner = GameAnalysis.CheckWinningCondition(currentBoardState);
                if (winner != null)
                {
                    WinnerAvailable?.Invoke(winner, WinningReason.RegularQuoridorWin);
                    break;
                }

                var nextTopPlayerBotMove = GetTopPlayerBotMove();

                if (nextTopPlayerBotMove == null)
                {
                    break;
                }

                if (!GameAnalysis.IsMoveLegal(currentBoardState, nextTopPlayerBotMove))
                {
                    WinnerAvailable?.Invoke(currentBoardState.BottomPlayer.Player, WinningReason.InvalidMove);
                    break;
                }

                currentBoardState = currentBoardState.ApplyMove(nextTopPlayerBotMove);
                NewBoardStateAvailable?.Invoke(currentBoardState);

                if (nextTopPlayerBotMove is Capitulation)
                {
                    WinnerAvailable?.Invoke(currentBoardState.BottomPlayer.Player, WinningReason.Capitulation);
                }

                var winner2 = GameAnalysis.CheckWinningCondition(currentBoardState);
                if (winner2 != null)
                {
                    WinnerAvailable?.Invoke(winner2, WinningReason.RegularQuoridorWin);
                    break;
                }

                moveCounter++;
            }

            IsRunning = false;

            bottomPlayerBot.NextMoveAvailable -= OnNextBottomPlayerBotMoveAvailable;
            topPlayerBot.NextMoveAvailable    -= OnNextTopPlayerBotMoveAvailable;
        }
Example #58
0
    private BoardState CreateBoardStateFromJson(JSONNode json)
    {
        BoardState boardState = new BoardState();

        boardState.wordBoardId   = json["wordBoardId"].Value;
        boardState.wordBoardSize = json["wordBoardSize"].AsInt;
        boardState.nextHintIndex = json["nextHintIndex"].AsInt;

        // Parse the words
        JSONArray wordsJson = json["words"].AsArray;

        boardState.words = new string[wordsJson.Count];

        for (int i = 0; i < wordsJson.Count; i++)
        {
            boardState.words[i] = wordsJson[i].Value;
        }

        // Parse the found words
        JSONArray foundWordsJson = json["foundWords"].AsArray;

        boardState.foundWords = new bool[foundWordsJson.Count];

        for (int i = 0; i < foundWordsJson.Count; i++)
        {
            boardState.foundWords[i] = foundWordsJson[i].AsBool;
        }

        // Parse the tile states
        JSONArray tileStatesJson = json["tileStates"].AsArray;

        boardState.tileStates = new BoardState.TileState[tileStatesJson.Count];

        for (int i = 0; i < tileStatesJson.Count; i++)
        {
            boardState.tileStates[i] = (BoardState.TileState)tileStatesJson[i].AsInt;
        }

        // Parse the tile lettes
        JSONArray tileLettersJson = json["tileLetters"].AsArray;

        boardState.tileLetters = new char[tileLettersJson.Count];

        for (int i = 0; i < tileLettersJson.Count; i++)
        {
            boardState.tileLetters[i] = System.Convert.ToChar(tileLettersJson[i].Value);
        }

        // Parse the hint letters
        JSONArray hintLettersJson = json["hintLetters"].AsArray;

        boardState.hintLettersShown = new List <int[]>(hintLettersJson.Count);

        for (int i = 0; i < hintLettersJson.Count; i++)
        {
            string[] hintLetter = hintLettersJson[i].Value.Split(',');
            boardState.hintLettersShown.Add(new int[2] {
                System.Convert.ToInt32(hintLetter[0]), System.Convert.ToInt32(hintLetter[1])
            });
        }

        return(boardState);
    }
Example #59
0
        private void FirstThrowHistory(List <string> validOpponentNames)
        {
            short[] firstThrows = new short[N];

            IDictionaryEnumerator e = m_history.GetEnumerator();

            while (e.MoveNext())
            {
                string         opp   = (string)e.Key;
                List <short[]> games = (List <short[]>)e.Value;

                if (validOpponentNames.Contains(opp))
                {
                    foreach (short[] game in games)
                    {
                        foreach (int y in m_numbersLeft[Opponent])
                        {
                            if (game[N * Opponent + y - 1] == 1)
                            {
                                firstThrows[y - 1]++;
                                break;
                            }
                        }
                    }
                }
            }

            if (validOpponentNames.Count == 1 && validOpponentNames[0] == m_opponentName)
            {
                Console.WriteLine("First Throw History[" + m_opponentName + "]:");
            }
            else
            {
                Console.WriteLine("First Throw History[" + m_joinDate.ToShortDateString() + "]:");
            }
            for (int i = 0; i < N; i++)
            {
                Console.WriteLine((i + 1) + ": " + firstThrows[i]);
            }
            Console.WriteLine();

            if (validOpponentNames.Count == 1)
            {
                foreach (string person in validOpponentNames)
                {
                    if (m_history.ContainsKey(person))
                    {
                        int wins   = 0;
                        int losses = 0;
                        int ties   = 0;

                        foreach (short[] game in m_history[person])
                        {
                            BoardState status = Status(game);
                            if (status == BoardState.Win)
                            {
                                wins++;
                            }
                            if (status == BoardState.Lose)
                            {
                                losses++;
                            }
                            if (status == BoardState.Draw)
                            {
                                ties++;
                            }
                        }

                        Console.WriteLine(validOpponentNames[0] + " win rate = " + (100 * losses / (wins + losses + ties)) + "%\n");
                    }
                }
            }
        }
Example #60
0
        private void Go()
        {
            if (m_currentTurn == Turn.Start)
            {
                Console.Write("\nOpponent's Name: ");
                m_opponentName = Console.ReadLine();
                Console.WriteLine();
                if (!GuaranteeLookup())
                {
                    Console.Write("Is " + m_opponentName + " definitely a person (y/n)? ");
                    string guarantee = Console.ReadLine();
                    if (guarantee.ToLower() == "y")
                    {
                        m_isGuaranteedPerson = true;
                    }
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("This player is definitely a person.");
                    Console.WriteLine();
                }
JoinDate:
                if (DateLookup() == DateTime.MinValue)
                {
                    Console.Write("When did this player join (mmddyy)? ");
                    string startdate = Console.ReadLine();
                    foreach (char c in startdate)
                    {
                        if (!char.IsDigit(c))
                        {
                            goto JoinDate;
                        }
                    }
                    string month = startdate.Substring(0, 2);
                    string day   = startdate.Substring(2, 2);
                    string year  = startdate.Substring(4, 2);
                    try
                    {
                        int intMonth = Convert.ToInt16(month);
                        int intDay   = Convert.ToInt16(day);
                        int intYear  = Convert.ToInt16(year) + 2000;
                        m_joinDate = new DateTime(intYear, intMonth, intDay);
                    }
                    catch
                    {
                        goto JoinDate;
                    }
                }
                else
                {
                    m_joinDate = DateLookup();
                    Console.WriteLine("This player started on " + m_joinDate.ToShortDateString() + ".");
                    Console.WriteLine();
                }
                List <string> opponents = new List <string>();
                opponents.Add(m_opponentName);
                FirstThrowHistory(opponents);

                if (m_dateToPlayers.ContainsKey(m_joinDate))
                {
                    if (m_dateToPlayers[m_joinDate].Count == 1 &&
                        m_dateToPlayers[m_joinDate][0] == m_opponentName)
                    {
                        // no op
                    }
                    else
                    {
                        FirstThrowHistory(m_dateToPlayers[m_joinDate]);
                    }
                }
            }

            Display();
            m_currentTurn++;

            if (m_currentTurn == Turn.Done || EvaluateBoard() != BoardState.Unfinished)
            {
                BoardState state = EvaluateBoard();
                Console.WriteLine("Game Complete: " + state.ToString());

                switch (state)
                {
                case BoardState.Win:
                    m_wins++;
                    break;

                case BoardState.Lose:
                    m_losses++;
                    break;

                case BoardState.Draw:
                    m_draws++;
                    break;
                }

                Console.WriteLine("(" + m_wins + "/" + m_losses + "/" + m_draws + ")");
                Console.WriteLine("Win% = " + (m_wins * 100.0 / (m_wins + m_losses + m_draws)) + "%");

                Save();
                return;
            }

            string input;

Computer:
            Console.Write("Computer displays: ");
            input = Console.ReadLine();
            if (input.ToLower() == "q")
            {
                m_currentTurn = Turn.Done;
                return;
            }
            if (ValidShort(input, Computer))
            {
                m_board[Computer, ToShort(input) - 1] = (short)m_currentTurn;
                m_numbersLeft[Computer].Remove(ToShort(input));
            }
            else
            {
                goto Computer;
            }

            List <string> opponents2 = new List <string>();

            opponents2.Add(m_opponentName);
            Histogram(ToShort(input), opponents2);
            if (m_dateToPlayers.ContainsKey(m_joinDate))
            {
                if (m_dateToPlayers[m_joinDate].Count == 1 &&
                    m_dateToPlayers[m_joinDate][0] == m_opponentName)
                {
                    // no op
                }
                else
                {
                    Histogram(ToShort(input), m_dateToPlayers[m_joinDate]);
                }
            }

            if (m_currentTurn > Turn.Second)
            {
                int          rating    = 0;
                List <short> bestMoves = FindBestMove(User, ref rating, int.MaxValue, 0);
                string       moves     = "{";
                for (int i = 0; i < bestMoves.Count; i++)
                {
                    moves += bestMoves[i].ToString();
                    if (i != bestMoves.Count - 1)
                    {
                        moves += ", ";
                    }
                    else
                    {
                        moves += "}";
                    }
                }
                Console.WriteLine("Best Move: " + moves);
                Console.WriteLine("Rating: " + rating);

                User     = 2;
                Opponent = 0;

                rating    = 0;
                bestMoves = FindBestMove(User, ref rating, int.MaxValue, 0);
                moves     = "{";
                for (int i = 0; i < bestMoves.Count; i++)
                {
                    moves += bestMoves[i].ToString();
                    if (i != bestMoves.Count - 1)
                    {
                        moves += ", ";
                    }
                    else
                    {
                        moves += "}";
                    }
                }
                Console.WriteLine("Opponent's Best Move: " + moves);
                Console.WriteLine("Opponent's Rating: " + rating + "\n");

                User     = 0;
                Opponent = 2;
            }

User:
            Console.Write("User chooses: ");
            input = Console.ReadLine();
            if (input.ToLower() == "q")
            {
                m_currentTurn = Turn.Done;
                return;
            }
            if (ValidShort(input, User))
            {
                m_board[User, ToShort(input) - 1] = (short)m_currentTurn;
                m_numbersLeft[User].Remove(ToShort(input));
            }
            else
            {
                goto User;
            }

Opponent:
            Console.Write("Opponent displays: ");
            input = Console.ReadLine();
            if (input.ToLower() == "q")
            {
                m_currentTurn = Turn.Done;
                return;
            }
            if (ValidShort(input, Opponent))
            {
                m_board[Opponent, ToShort(input) - 1] = (short)m_currentTurn;
                m_numbersLeft[Opponent].Remove(ToShort(input));
            }
            else
            {
                goto Opponent;
            }

            Console.WriteLine();
            Go();
        }