Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- Piece[] board = whatever();
- // New random number generator.
- Random random = new Random();
- // LINQ query orders each element by the next random number.
- Piece[] randomBoard = (from piece in board
- orderby random.Next()
- select piece).ToArray();
- int index = (y * 8) + x;
- Piece[] pieces = ... your 20 pieces here
- Piece[] board = new Piece[8 * 8];
- Random r = new Random();
- foreach (Piece piece in pieces)
- {
- while (true)
- {
- Int32 location = r.Next(board.Length);
- if (board[location] == null)
- {
- board[location] = piece;
- break;
- }
- }
- }
Add Comment
Please, Sign In to add comment