package animals;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
public class MultiWolf extends Animal {
private static final LinkedList<Animal> pets = new LinkedList<>();
private static boolean inPetCall = false;
private static void attemptLoadPet(String className) {
try {
Object pet = Class.forName(className).newInstance();
if (pet instanceof Animal) {
pets.add((Animal) pet);
}
} catch (Exception ex) {
// this wolf is not available
System.out.println(className + " is not available for MultiWolf cheating.");
}
}
static {
attemptLoadPet("animals.AlphaWolf");
attemptLoadPet("animals.CamperWolf");
attemptLoadPet("animals.GamblerWolf");
attemptLoadPet("animals.GatheringWolf");
attemptLoadPet("animals.LazyWolf");
attemptLoadPet("animals.Sheep");
attemptLoadPet("animals.Wion");
attemptLoadPet("animals.MOSHPITFRENZYWolf");
attemptLoadPet("animals.PassiveAgressiveWolf");
attemptLoadPet("animals.StoneEatingWolf");
attemptLoadPet("animals.HerjanWolf");
attemptLoadPet("animals.HonorWolf");
attemptLoadPet("animals.MimicWolf");
attemptLoadPet("animals.LionHunterWolf");
attemptLoadPet("animals.OmegaWolf");
attemptLoadPet("animals.WolfWithoutFear");
attemptLoadPet("animals.WolfRunningWithScissors");
// attemptLoadPet("animals.SmartWolf");
// According to Rusher, the above cheating of a non-Java wolf breaks the non-Java-entry wrapper.
attemptLoadPet("animals.ShadowWolf");
attemptLoadPet("animals.HybridWolf");
attemptLoadPet("animals.ProAlpha");
attemptLoadPet("animals.ForrestWolf");
attemptLoadPet("animals.WhenIGrowUp");
attemptLoadPet("animals.MigratingWolf");
attemptLoadPet("animals.BlindWolf");
}
public MultiWolf() {
super('W');
}
@Override
public Attack fight(char opponent) {
if (inPetCall) {
// stop infinite recursion
return Attack.ROCK;
}
inPetCall = true;
HashMap<Attack, Integer> collect = new HashMap<>();
collect.put(Attack.ROCK, 0);
collect.put(Attack.PAPER, 0);
collect.put(Attack.SCISSORS, 0);
collect.put(Attack.SUICIDE, -9001);
for (Animal a : pets) {
a.surroundings = this.surroundings;
Attack atk = a.fight(opponent);
collect.put(atk, collect.get(atk)+1);
}
int top=0;
Attack atk=Attack.ROCK;
for (Entry<Attack, Integer> ent : collect.entrySet()) {
if (ent.getValue() > top) {
atk = ent.getKey();
top = ent.getValue();
}
}
inPetCall = false;
return atk;
}
@Override
public Move move() {
if (inPetCall) {
// stop infinite recursion
return Move.HOLD;
}
inPetCall = true;
HashMap<Move, Integer> collect = new HashMap<>();
collect.put(Move.DOWN, 0);
collect.put(Move.HOLD, 0);
collect.put(Move.LEFT, 0);
collect.put(Move.RIGHT, 0);
collect.put(Move.UP, 0);
for (Animal a : pets) {
a.surroundings = this.surroundings;
Move mv = a.move();
collect.put(mv, collect.get(mv)+1);
}
int top=0;
Move mv=Move.HOLD;
for (Entry<Move, Integer> ent : collect.entrySet()) {
if (ent.getValue() > top) {
mv = ent.getKey();
top = ent.getValue();
}
}
inPetCall = false;
return mv;
}
}
package animals;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
public class MultiWolf extends Animal {
private static final LinkedList<Animal> pets = new LinkedList<>();
private static boolean inPetCall = false;
private static void attemptLoadPet(String className) {
try {
Object pet = Class.forName(className).newInstance();
if (pet instanceof Animal) {
pets.add((Animal) pet);
}
} catch (Exception ex) {
// this wolf is not available
System.out.println(className + " is not available for MultiWolf cheating.");
}
}
static {
attemptLoadPet("animals.AlphaWolf");
attemptLoadPet("animals.CamperWolf");
attemptLoadPet("animals.GamblerWolf");
attemptLoadPet("animals.GatheringWolf");
attemptLoadPet("animals.LazyWolf");
attemptLoadPet("animals.Sheep");
attemptLoadPet("animals.Wion");
attemptLoadPet("animals.MOSHPITFRENZYWolf");
attemptLoadPet("animals.PassiveAgressiveWolf");
attemptLoadPet("animals.StoneEatingWolf");
attemptLoadPet("animals.HerjanWolf");
attemptLoadPet("animals.HonorWolf");
attemptLoadPet("animals.MimicWolf");
attemptLoadPet("animals.LionHunterWolf");
attemptLoadPet("animals.OmegaWolf");
attemptLoadPet("animals.WolfWithoutFear");
attemptLoadPet("animals.WolfRunningWithScissors");
attemptLoadPet("animals.SmartWolf");
attemptLoadPet("animals.ShadowWolf");
attemptLoadPet("animals.HybridWolf");
attemptLoadPet("animals.ProAlpha");
attemptLoadPet("animals.ForrestWolf");
attemptLoadPet("animals.WhenIGrowUp");
attemptLoadPet("animals.MigratingWolf");
attemptLoadPet("animals.BlindWolf");
}
public MultiWolf() {
super('W');
}
@Override
public Attack fight(char opponent) {
if (inPetCall) {
// stop infinite recursion
return Attack.ROCK;
}
inPetCall = true;
HashMap<Attack, Integer> collect = new HashMap<>();
collect.put(Attack.ROCK, 0);
collect.put(Attack.PAPER, 0);
collect.put(Attack.SCISSORS, 0);
collect.put(Attack.SUICIDE, -9001);
for (Animal a : pets) {
a.surroundings = this.surroundings;
Attack atk = a.fight(opponent);
collect.put(atk, collect.get(atk)+1);
}
int top=0;
Attack atk=Attack.ROCK;
for (Entry<Attack, Integer> ent : collect.entrySet()) {
if (ent.getValue() > top) {
atk = ent.getKey();
top = ent.getValue();
}
}
inPetCall = false;
return atk;
}
@Override
public Move move() {
if (inPetCall) {
// stop infinite recursion
return Move.HOLD;
}
inPetCall = true;
HashMap<Move, Integer> collect = new HashMap<>();
collect.put(Move.DOWN, 0);
collect.put(Move.HOLD, 0);
collect.put(Move.LEFT, 0);
collect.put(Move.RIGHT, 0);
collect.put(Move.UP, 0);
for (Animal a : pets) {
a.surroundings = this.surroundings;
Move mv = a.move();
collect.put(mv, collect.get(mv)+1);
}
int top=0;
Move mv=Move.HOLD;
for (Entry<Move, Integer> ent : collect.entrySet()) {
if (ent.getValue() > top) {
mv = ent.getKey();
top = ent.getValue();
}
}
inPetCall = false;
return mv;
}
}
package animals;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
public class MultiWolf extends Animal {
private static final LinkedList<Animal> pets = new LinkedList<>();
private static boolean inPetCall = false;
private static void attemptLoadPet(String className) {
try {
Object pet = Class.forName(className).newInstance();
if (pet instanceof Animal) {
pets.add((Animal) pet);
}
} catch (Exception ex) {
// this wolf is not available
System.out.println(className + " is not available for MultiWolf cheating.");
}
}
static {
attemptLoadPet("animals.AlphaWolf");
attemptLoadPet("animals.CamperWolf");
attemptLoadPet("animals.GamblerWolf");
attemptLoadPet("animals.GatheringWolf");
attemptLoadPet("animals.LazyWolf");
attemptLoadPet("animals.Sheep");
attemptLoadPet("animals.Wion");
attemptLoadPet("animals.MOSHPITFRENZYWolf");
attemptLoadPet("animals.PassiveAgressiveWolf");
attemptLoadPet("animals.StoneEatingWolf");
attemptLoadPet("animals.HerjanWolf");
attemptLoadPet("animals.HonorWolf");
attemptLoadPet("animals.MimicWolf");
attemptLoadPet("animals.LionHunterWolf");
attemptLoadPet("animals.OmegaWolf");
attemptLoadPet("animals.WolfWithoutFear");
attemptLoadPet("animals.WolfRunningWithScissors");
// attemptLoadPet("animals.SmartWolf");
// According to Rusher, the above cheating of a non-Java wolf breaks the non-Java-entry wrapper.
attemptLoadPet("animals.ShadowWolf");
attemptLoadPet("animals.HybridWolf");
attemptLoadPet("animals.ProAlpha");
attemptLoadPet("animals.ForrestWolf");
attemptLoadPet("animals.WhenIGrowUp");
attemptLoadPet("animals.MigratingWolf");
attemptLoadPet("animals.BlindWolf");
}
public MultiWolf() {
super('W');
}
@Override
public Attack fight(char opponent) {
if (inPetCall) {
// stop infinite recursion
return Attack.ROCK;
}
inPetCall = true;
HashMap<Attack, Integer> collect = new HashMap<>();
collect.put(Attack.ROCK, 0);
collect.put(Attack.PAPER, 0);
collect.put(Attack.SCISSORS, 0);
collect.put(Attack.SUICIDE, -9001);
for (Animal a : pets) {
a.surroundings = this.surroundings;
Attack atk = a.fight(opponent);
collect.put(atk, collect.get(atk)+1);
}
int top=0;
Attack atk=Attack.ROCK;
for (Entry<Attack, Integer> ent : collect.entrySet()) {
if (ent.getValue() > top) {
atk = ent.getKey();
top = ent.getValue();
}
}
inPetCall = false;
return atk;
}
@Override
public Move move() {
if (inPetCall) {
// stop infinite recursion
return Move.HOLD;
}
inPetCall = true;
HashMap<Move, Integer> collect = new HashMap<>();
collect.put(Move.DOWN, 0);
collect.put(Move.HOLD, 0);
collect.put(Move.LEFT, 0);
collect.put(Move.RIGHT, 0);
collect.put(Move.UP, 0);
for (Animal a : pets) {
a.surroundings = this.surroundings;
Move mv = a.move();
collect.put(mv, collect.get(mv)+1);
}
int top=0;
Move mv=Move.HOLD;
for (Entry<Move, Integer> ent : collect.entrySet()) {
if (ent.getValue() > top) {
mv = ent.getKey();
top = ent.getValue();
}
}
inPetCall = false;
return mv;
}
}
Edit - I believe this Wolf will need to be loaded after the wolves it references to function properly.
Edit - I believe this Wolf will need to be loaded after the wolves it references to function properly.
package animals;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
public class MultiWolf extends Animal {
private static final LinkedList<Animal> pets = new LinkedList<>();
private static boolean inPetCall = false;
private static void attemptLoadPet(String className) {
try {
Object pet = Class.forName(className).newInstance();
if (pet instanceof Animal) {
pets.add((Animal) pet);
}
} catch (Exception ex) {
// this wolf is not available
// System.out.println(className + " is not available for MultiWolf cheating.");
}
}
static {
attemptLoadPet("animals.AlphaWolf");
attemptLoadPet("animals.CamperWolf");
attemptLoadPet("animals.GamblerWolf");
attemptLoadPet("animals.GatheringWolf");
attemptLoadPet("animals.LazyWolf");
attemptLoadPet("animals.Sheep");
attemptLoadPet("animals.Wion");
attemptLoadPet("animals.MOSHPITFRENZYWolf");
attemptLoadPet("animals.PassiveAgressiveWolf");
attemptLoadPet("animals.StoneEatingWolf");
attemptLoadPet("animals.HerjanWolf");
attemptLoadPet("animals.HonorWolf");
attemptLoadPet("animals.MimicWolf");
attemptLoadPet("animals.LionHunterWolf");
attemptLoadPet("animals.OmegaWolf");
attemptLoadPet("animals.WolfWithoutFear");
attemptLoadPet("animals.WolfRunningWithScissors");
attemptLoadPet("animals.SmartWolf");
attemptLoadPet("animals.ShadowWolf");
attemptLoadPet("animals.HybridWolf");
attemptLoadPet("animals.ProAlpha");
attemptLoadPet("animals.ForrestWolf");
attemptLoadPet("animals.WhenIGrowUp");
attemptLoadPet("animals.MigratingWolf");
attemptLoadPet("animals.BlindWolf");
}
public MultiWolf() {
super('W');
}
@Override
public Attack fight(char opponent) {
if (inPetCall) {
// stop infinite recursion
return Attack.ROCK;
}
inPetCall = true;
HashMap<Attack, Integer> collect = new HashMap<>();
collect.put(Attack.ROCK, 0);
collect.put(Attack.PAPER, 0);
collect.put(Attack.SCISSORS, 0);
collect.put(Attack.SUICIDE, -9001);
for (Animal a : pets) {
a.surroundings = this.surroundings;
Attack atk = a.fight(opponent);
collect.put(atk, collect.get(atk)+1);
}
int top=0;
Attack atk=Attack.ROCK;
for (Entry<Attack, Integer> ent : collect.entrySet()) {
if (ent.getValue() > top) {
atk = ent.getKey();
top = ent.getValue();
}
}
inPetCall = false;
return atk;
}
@Override
public Move move() {
if (inPetCall) {
// stop infinite recursion
return Move.HOLD;
}
inPetCall = true;
HashMap<Move, Integer> collect = new HashMap<>();
collect.put(Move.DOWN, 0);
collect.put(Move.HOLD, 0);
collect.put(Move.LEFT, 0);
collect.put(Move.RIGHT, 0);
collect.put(Move.UP, 0);
for (Animal a : pets) {
a.surroundings = this.surroundings;
Move mv = a.move();
collect.put(mv, collect.get(mv)+1);
}
int top=0;
Move mv=Move.HOLD;
for (Entry<Move, Integer> ent : collect.entrySet()) {
if (ent.getValue() > top) {
mv = ent.getKey();
top = ent.getValue();
}
}
inPetCall = false;
return mv;
}
}
package animals;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
public class MultiWolf extends Animal {
private static final LinkedList<Animal> pets = new LinkedList<>();
private static boolean inPetCall = false;
private static void attemptLoadPet(String className) {
try {
Object pet = Class.forName(className).newInstance();
if (pet instanceof Animal) {
pets.add((Animal) pet);
}
} catch (Exception ex) {
// this wolf is not available
// System.out.println(className + " is not available for MultiWolf cheating.");
}
}
static {
attemptLoadPet("animals.AlphaWolf");
attemptLoadPet("animals.CamperWolf");
attemptLoadPet("animals.GamblerWolf");
attemptLoadPet("animals.GatheringWolf");
attemptLoadPet("animals.LazyWolf");
attemptLoadPet("animals.Sheep");
attemptLoadPet("animals.Wion");
attemptLoadPet("animals.MOSHPITFRENZYWolf");
attemptLoadPet("animals.PassiveAgressiveWolf");
attemptLoadPet("animals.StoneEatingWolf");
attemptLoadPet("animals.HerjanWolf");
attemptLoadPet("animals.HonorWolf");
attemptLoadPet("animals.MimicWolf");
attemptLoadPet("animals.LionHunterWolf");
attemptLoadPet("animals.OmegaWolf");
attemptLoadPet("animals.WolfWithoutFear");
attemptLoadPet("animals.WolfRunningWithScissors");
attemptLoadPet("animals.SmartWolf");
attemptLoadPet("animals.ShadowWolf");
attemptLoadPet("animals.HybridWolf");
attemptLoadPet("animals.ProAlpha");
attemptLoadPet("animals.ForrestWolf");
attemptLoadPet("animals.WhenIGrowUp");
attemptLoadPet("animals.MigratingWolf");
attemptLoadPet("animals.BlindWolf");
}
public MultiWolf() {
super('W');
}
@Override
public Attack fight(char opponent) {
if (inPetCall) {
// stop infinite recursion
return Attack.ROCK;
}
inPetCall = true;
HashMap<Attack, Integer> collect = new HashMap<>();
collect.put(Attack.ROCK, 0);
collect.put(Attack.PAPER, 0);
collect.put(Attack.SCISSORS, 0);
collect.put(Attack.SUICIDE, -9001);
for (Animal a : pets) {
a.surroundings = this.surroundings;
Attack atk = a.fight(opponent);
collect.put(atk, collect.get(atk)+1);
}
int top=0;
Attack atk=Attack.ROCK;
for (Entry<Attack, Integer> ent : collect.entrySet()) {
if (ent.getValue() > top) atk = ent.getKey();
}
inPetCall = false;
return atk;
}
@Override
public Move move() {
if (inPetCall) {
// stop infinite recursion
return Move.HOLD;
}
inPetCall = true;
HashMap<Move, Integer> collect = new HashMap<>();
collect.put(Move.DOWN, 0);
collect.put(Move.HOLD, 0);
collect.put(Move.LEFT, 0);
collect.put(Move.RIGHT, 0);
collect.put(Move.UP, 0);
for (Animal a : pets) {
a.surroundings = this.surroundings;
Move mv = a.move();
collect.put(mv, collect.get(mv)+1);
}
int top=0;
Move mv=Move.HOLD;
for (Entry<Move, Integer> ent : collect.entrySet()) {
if (ent.getValue() > top) mv = ent.getKey();
}
inPetCall = false;
return mv;
}
}
package animals;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
public class MultiWolf extends Animal {
private static final LinkedList<Animal> pets = new LinkedList<>();
private static boolean inPetCall = false;
private static void attemptLoadPet(String className) {
try {
Object pet = Class.forName(className).newInstance();
if (pet instanceof Animal) {
pets.add((Animal) pet);
}
} catch (Exception ex) {
// this wolf is not available
System.out.println(className + " is not available for MultiWolf cheating.");
}
}
static {
attemptLoadPet("animals.AlphaWolf");
attemptLoadPet("animals.CamperWolf");
attemptLoadPet("animals.GamblerWolf");
attemptLoadPet("animals.GatheringWolf");
attemptLoadPet("animals.LazyWolf");
attemptLoadPet("animals.Sheep");
attemptLoadPet("animals.Wion");
attemptLoadPet("animals.MOSHPITFRENZYWolf");
attemptLoadPet("animals.PassiveAgressiveWolf");
attemptLoadPet("animals.StoneEatingWolf");
attemptLoadPet("animals.HerjanWolf");
attemptLoadPet("animals.HonorWolf");
attemptLoadPet("animals.MimicWolf");
attemptLoadPet("animals.LionHunterWolf");
attemptLoadPet("animals.OmegaWolf");
attemptLoadPet("animals.WolfWithoutFear");
attemptLoadPet("animals.WolfRunningWithScissors");
attemptLoadPet("animals.SmartWolf");
attemptLoadPet("animals.ShadowWolf");
attemptLoadPet("animals.HybridWolf");
attemptLoadPet("animals.ProAlpha");
attemptLoadPet("animals.ForrestWolf");
attemptLoadPet("animals.WhenIGrowUp");
attemptLoadPet("animals.MigratingWolf");
attemptLoadPet("animals.BlindWolf");
}
public MultiWolf() {
super('W');
}
@Override
public Attack fight(char opponent) {
if (inPetCall) {
// stop infinite recursion
return Attack.ROCK;
}
inPetCall = true;
HashMap<Attack, Integer> collect = new HashMap<>();
collect.put(Attack.ROCK, 0);
collect.put(Attack.PAPER, 0);
collect.put(Attack.SCISSORS, 0);
collect.put(Attack.SUICIDE, -9001);
for (Animal a : pets) {
a.surroundings = this.surroundings;
Attack atk = a.fight(opponent);
collect.put(atk, collect.get(atk)+1);
}
int top=0;
Attack atk=Attack.ROCK;
for (Entry<Attack, Integer> ent : collect.entrySet()) {
if (ent.getValue() > top) {
atk = ent.getKey();
top = ent.getValue();
}
}
inPetCall = false;
return atk;
}
@Override
public Move move() {
if (inPetCall) {
// stop infinite recursion
return Move.HOLD;
}
inPetCall = true;
HashMap<Move, Integer> collect = new HashMap<>();
collect.put(Move.DOWN, 0);
collect.put(Move.HOLD, 0);
collect.put(Move.LEFT, 0);
collect.put(Move.RIGHT, 0);
collect.put(Move.UP, 0);
for (Animal a : pets) {
a.surroundings = this.surroundings;
Move mv = a.move();
collect.put(mv, collect.get(mv)+1);
}
int top=0;
Move mv=Move.HOLD;
for (Entry<Move, Integer> ent : collect.entrySet()) {
if (ent.getValue() > top) {
mv = ent.getKey();
top = ent.getValue();
}
}
inPetCall = false;
return mv;
}
}
Loading