package de.fhdw.gaming.ipspiel23.c4.gststrategy;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
import de.fhdw.gaming.core.domain.GameException;
import de.fhdw.gaming.core.domain.Move;
import de.fhdw.gaming.ipspiel23.c4.domain.IC4Player;
import de.fhdw.gaming.ipspiel23.c4.domain.IC4State;
import de.fhdw.gaming.ipspiel23.c4.moves.IC4Move;
import de.fhdw.gaming.ipspiel23.c4.moves.factory.IC4MoveFactory;
import de.fhdw.gaming.ipspiel23.c4.strategies.IC4Strategy;
import de.fhdw.gaming.ipspiel23.gst.domain.ICalculatorKopplung;
import de.fhdw.gaming.ipspiel23.gst.domain.IKopplung;
import de.fhdw.gaming.ipspiel23.gst.domain.impl.GstKopplungsMoveCalculator;
import de.fhdw.gaming.ipspiel23.gst.strategies.impl.GstKopplungNegaMax;
import de.fhdw.gaming.ipspiel23.gst.strategies.impl.GstKopplungNegaMaxMultithreading;
/**
* GSTMoveStrategy for C4 Game.
*/
public class C4GSTMoveStrategy implements IC4Strategy {
/**
* The calculator used for computing the next move.
*/
private ICalculatorKopplung<IC4Player, IC4State> calc;
/**
* The MoveFactory.
*/
private IC4MoveFactory moveFactory;
Perhaps 'moveFactory' could be replaced by a local variable.
Reports fields which may be converted to a local variable. This is so because
in every method where the field is used, it is assigned before it is first read.
Hence, the value that the field had before the method call may not be observed,
so it might as well not be stored in the enclosing object.
Limitations: We can only check private fields for now.
public class Foo {
private int x; // this will be reported
public int foo(int y) {
x = y + 5; // assigned before any read
return x;
}
public int fooOk(int y) {
int z = y + 5; // might as well be a local like here
return z;
}
}