//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())])); }
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(); }
internal GameMove(GameBoard.Move pl, int pos) { Player = pl; Position = pos; }