package player.playeragent; import java.util.Random; import player.config.PlayerConfig; import edu.neu.ccs.demeterf.demfgen.lib.List; import edu.neu.ccs.demeterf.demfgen.lib.None; import gen.*; import utils.NameGenerator; /** Class for creating a derivative * @author animesh * */ public class CreateAgent { /** Returns a newly created derivative of a different type than already existing derivatives * @param existingDerTypes * @param player * @return {@link gen.Derivative} */ public static Derivative createDerivative(List existingDerTypes, Player player) { String derName = NameGenerator.getNewName(player.name); PlayerID pID = player.id; Price price = new Price(Math.random()); Type type = generateType(); while(existingDerTypes.contains(type)) type = generateType(); Derivative der = new Derivative(derName, pID, new None(), price, type, new None(), new None()); return der; } /** Returns a type for the derivative being created * @param price * @return {@link gen.Type} */ static Type generateType(){ Random random = new Random(); int numOfRels = random.nextInt(PlayerConfig.MAX_NUM_OF_RELS-PlayerConfig.MIN_NUM_OF_RELS)+PlayerConfig.MIN_NUM_OF_RELS; List tInstances = List.create(); //** SHOULD BE MORE INTELLIGENT for(int i=0; i