How can this be done more elegant and without creating new objects?
List<Move> playerMoves = clone.getValidSuccessorMoves(0);
List<Move> opponentMoves = clone.getValidSuccessorMoves(1);
Move pmove = playerMoves[rand.Next(playerMoves.Count)];
Move omove = opponentMoves[rand.Next(opponentMoves.Count)];
MapManipulator.applyMove(clone.Map, pmove);
MapManipulator.applyMove(clone.Map, omove);
clone.Player = pmove.Destination;
clone.Opponent = omove.Destination;
The “select a random item bit” seems to be done:
is fine, so long as you’re creating instances of
Randomappropriately. Given that there’s so much code we don’t know about though, we can’t really answer the other part of your question – you haven’t shown anything which actually creates any new objects…