Skip to content

Content of file C4GSTMoveStrategy.java

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;
Unused import - de.fhdw.gaming.ipspiel23.gst.strategies.impl.GstKopplungNegaMax.

Since Checkstyle 3.0

Checks for unused import statements. Checkstyle uses a simple but very reliable algorithm to report on unused import statements. An import statement is considered unused if:

  • It is not referenced in the file. The algorithm does not support wild-card imports like import java.io.*;. Most IDE's provide very sophisticated checks for imports that handle wild-card imports.
  • It is a duplicate of another import. This is when a class is imported more than once.
  • The class imported is from the java.lang package. For example importing java.lang.String.
  • The class imported is from the same package.
  • Optionally: it is referenced in Javadoc comments. This check is on by default, but it is considered bad practice to introduce a compile time dependency for documentation purposes only. As an example, the import java.util.Date would be considered referenced with the Javadoc comment {@link Date}. The alternative to avoid introducing a compile time dependency would be to write the Javadoc comment as {@link java.util.Date}.

The main limitation of this check is handling the case where an imported type has the same name as a declaration, such as a member variable.

For example, in the following case the import java.awt.Component will not be flagged as unused:


import java.awt.Component;
class FooBar {
  private Object Component; // a bad practice in my opinion
  ...
}
        
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; /** * The C4-GST-Kopplung. */ private IKopplung<IC4Player, IC4State> c4Kopplung; /** * . */ private GstKopplungNegaMaxMultithreading<IC4Player, IC4State> negamax; //private GstKopplungNegaMax<IC4Player, IC4State> negamax; /** * Creates new C4GSTMoveStrategy with given MoveFactory. * @param moveFactory */ public C4GSTMoveStrategy(IC4MoveFactory moveFactory) { this.moveFactory = moveFactory; this.c4Kopplung = new C4GSTKopplung(moveFactory); //this.negamax = new GstKopplungNegaMax<>(); this.negamax = new GstKopplungNegaMaxMultithreading<>(); this.calc = new GstKopplungsMoveCalculator<>(); } @Override public Optional<IC4Move> computeNextMove(int gameId, IC4Player player, IC4State state) throws GameException, InterruptedException { //final Collection<Move<IC4Player, IC4State>> possibleMoves = c4Kopplung.getPossibleMoves(state).get(); return Optional.of((IC4Move) calc.calculateMove(c4Kopplung, state, 1000, negamax)); } @Override public String toString() { return C4GSTMoveStrategy.class.getSimpleName(); } }