public Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> > MakeRandomMove(GameBoard <counters> board, counters counter, int ply, Tuple <int, int> positions, bool mmax, GameBoard <int> scoreBoard, ref int cont) { List <Tuple <int, int> > availableMoves = getAvailableMoves(board, positions); Tuple <int, int> Move = new Tuple <int, int>(0, 0); Random rnd = new Random(); int randMoveX = rnd.Next(1, 7); // creates a number between 1 and 7 int randMoveY = rnd.Next(1, 7); // creates a number between 1 and 7 Tuple <int, int> randMove = new Tuple <int, int>(randMoveX, randMoveY); int score = Consts.MIN_SCORE; // current score of move counters us = Flip(counter); int ourindex = 1; // Create new stopwatch. Stopwatch stopwatch = new Stopwatch(); // Begin timing. stopwatch.Start(); Move = randMove; positions = randMove; // HWL: NB: this overwrites the arg positions; which means you are actually not considering the move in positions, but a different, random move; this probably explains why you get such strange moves in your gameplay board.DisplayBoard(); //cont = 1; if (ply > 0) { score = EvalCurrentBoard(board, scoreBoard, ourindex, us); // is current pos a win? } // Stop timing. stopwatch.Stop(); Console.WriteLine("========================================================================================================================" + "RANDOMLY SELECTED MOVE:" + Environment.NewLine + "------------------------------------------------------------------------------------------------------------------------" + "position: " + positions + "; " + "for player: " + counter + "; " + "score: " + score + "; " + "positions visited " + cont + "; " + "depth level: " + ply + Environment.NewLine + "elapsed time for move: " + stopwatch.Elapsed + "; " + "no. of remaining moves left: " + availableMoves.Count + Environment.NewLine + "two in a row detected at: " + "Cell 1: " + IsLeftofTwo(board, counter) + ", " + "Cell 2: " + IsRightofTwo(board, counter) + Environment.NewLine + "build on two-in-row? " + "left: " + board.IsTwoLeftNeighbourEmpty(board, counter) + " at position " + board.PrintTwoLeftNeighbour(board, counter) + ", right: " + board.IsTwoRightNeighbourEmpty(board, counter) + " at position " + board.PrintTwoRightNeighbour(board, counter) + Environment.NewLine + "top: " + board.IsTwoTopNeighbourEmpty(board, counter) + " at position " + board.PrintTwoTopNeighbour(board, counter) + ", bottom: " + board.IsTwoBottomNeighbourEmpty(board, counter) + " at position " + board.PrintTwoBottomNeighbour(board, counter) + Environment.NewLine + "build on one-in-row? " + "left: " + board.IsOneLeftNeighbourEmpty(board, counter) + " at position " + board.PrintOneLeftNeighbour(board, counter) + ", right: " + board.IsOneRightNeighbourEmpty(board, counter) + " at position " + board.PrintOneRightNeighbour(board, counter) + Environment.NewLine + "top: " + board.IsOneTopNeighbourEmpty(board, counter) + " at position " + board.PrintOneTopNeighbour(board, counter) + ", bottom: " + board.IsOneBottomNeighbourEmpty(board, counter) + " at position " + board.PrintOneBottomNeighbour(board, counter) + Environment.NewLine + "build on two-in-row?:" + " with horzi gap? " + board.IsTwoWithHorziGapEmpty(board, counter) + " at position " + board.PrintTwoWithHorziGap(board, counter) + ", with vertical gap?: " + board.IsTwoWithVerticalGapEmpty(board, counter) + " at position " + board.PrintTwoWithVerticalGap(board, counter)); Console.WriteLine("========================================================================================================================"); // Console.ReadLine(); // assign score to correct cell in score scoreBoard[randMoveX, randMoveY] = score; // RandScoringSummary(board, scoreBoard); // scoreBoard.DisplayBoard(); // Console.ReadLine(); return(new Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> >(score, positions, board, scoreBoard)); }