KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > innig > macker > example > modularity > player > impl > RandomPlayer


1 package net.innig.macker.example.modularity.player.impl;
2
3 import net.innig.macker.example.modularity.player.*;
4 import net.innig.macker.example.modularity.game.*;
5 import java.util.*;
6
7 public class RandomPlayer
8     implements Player
9     {
10     public Move nextMove(Set legalMoves, Move otherPreviousMove)
11         {
12         List legalMovesL = new ArrayList(legalMoves);
13         return (Move) legalMovesL.get(rand.nextInt(legalMovesL.size()));
14         }
15     
16     private Random rand = new Random(System.currentTimeMillis() + hashCode());
17     }
Popular Tags