Ejemplo n.º 1
0
            //Factory method to generate a random move for this player
            internal static GameMove Random(GameBoard brd, GameBoard.Move player)
            {
                //get indexes of all open positions
                var openPositions = brd.Board
                                    .Zip(Enumerable.Range(0, 9), (mv, i) => Tuple.Create(mv, i))
                                    //number all positions
                                    .Where(pr => pr.Item1 == GameBoard.Move.Sp)
                                    //get positions that are a space and place them in an array
                                    .Select(pr => pr.Item2).ToArray();

                //randomly choose an open position from array of positions
                return(new GameMove(player, openPositions[rng.Next(openPositions.Count())]));
            }
Ejemplo n.º 2
0
    public void OnMouseDown()
    {
        // send message for move from selected checker to this location
        GameBoard.Move theMove = new GameBoard.Move()
        {
            Owner         = Board.Player,
            StartLocation = Board.SelectedChecker.GetComponent <Checker>().Location,
            EndLocation   = Location
        };

        Board.ServerConnection.SendMessage(theMove.ToMessage());
        Debugging.Print("Should have just sent a message: " + theMove.ToMessage());
        Board.DeselectPiece();
    }
Ejemplo n.º 3
0
 internal GameMove(GameBoard.Move pl, int pos)
 {
     Player   = pl;
     Position = pos;
 }