package agents.nastyagent; import java.util.ArrayList; import java.util.List; import genius.core.actions.Action; /** * Deliberately goes out of memory while choosing an action. * * @author W.Pasman 25jan16 * */ public class OutOfMem extends NastyAgent { private ArrayList memory = new ArrayList(); private final static String block = "01234567890123456789123456789012"; @Override public Action chooseAction(List> possibleActions) { doubleMemory(); return super.chooseAction(possibleActions); } /** * Double the amount of used memory (starts with 32 bytes if no mem in use * yet) */ private void doubleMemory() { long toAdd = memory.size(); if (toAdd == 0) { toAdd = 1; } for (long i = 0; i < toAdd; i++) { memory.add(block); } } }