Main.java

1
package com.takenoko;
2
3
import com.beust.jcommander.JCommander;
4
import com.beust.jcommander.Parameter;
5
import com.takenoko.bot.ColletBot;
6
import com.takenoko.engine.BotManager;
7
import com.takenoko.engine.GameEngine;
8
import com.takenoko.ui.ConsoleUserInterface;
9
import java.util.ArrayList;
10
import java.util.List;
11
import org.apache.logging.log4j.Level;
12
import org.apache.logging.log4j.LogManager;
13
import org.apache.logging.log4j.Logger;
14
import org.apache.logging.log4j.core.LoggerContext;
15
import org.apache.logging.log4j.core.config.Configuration;
16
import org.apache.logging.log4j.core.config.LoggerConfig;
17
18
public class Main {
19
    @Parameter(
20
            names = {"--2thousands"},
21
            description =
22
                    "Run 2*1000 games: best_Bot VS second_best_Bot && best_Bot VS best_Bot | no"
23
                            + " logs")
24
    private boolean thousands = false;
25
26
    @Parameter(
27
            names = {"--demo"},
28
            description = "Run one game as Demo | show all logs")
29
    private boolean demo = false;
30
31
    @Parameter(
32
            names = {"--csv"},
33
            description = "Append the results in a csv file")
34
    private boolean csv = false;
35
36
    private final Logger logger = LogManager.getLogger(Main.class);
37
    private static final int TWO_THOUSANDS_NB_GAMES = 1000;
38
39
    public static void main(String[] args) {
40
        Main main = new Main();
41 1 1. main : removed call to com/beust/jcommander/JCommander::parse → NO_COVERAGE
        JCommander.newBuilder().addObject(main).build().parse(args);
42 1 1. main : removed call to com/takenoko/Main::run → NO_COVERAGE
        main.run();
43
    }
44
45
    @SuppressWarnings("java:S4792")
46
    public void run() {
47
        GameEngine gameEngine = new GameEngine();
48
        LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
49
        Configuration config = ctx.getConfiguration();
50
        LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
51 1 1. run : negated conditional → NO_COVERAGE
        if (thousands) {
52
            loggerConfig.setLevel(ConsoleUserInterface.GAMESTATS);
53
            ctx.updateLoggers();
54 1 1. run : removed call to com/takenoko/engine/GameEngine::runGame → NO_COVERAGE
            gameEngine.runGame(TWO_THOUSANDS_NB_GAMES);
55
            GameEngine gameEngine2 =
56
                    new GameEngine(
57
                            new ArrayList<>(
58
                                    List.of(
59
                                            new BotManager(new ColletBot(), "Collet Bot 01"),
60
                                            new BotManager(new ColletBot(), "Collet Bot 02"))));
61 1 1. run : removed call to com/takenoko/engine/GameEngine::runGame → NO_COVERAGE
            gameEngine2.runGame(TWO_THOUSANDS_NB_GAMES, csv);
62 1 1. run : negated conditional → NO_COVERAGE
        } else if (demo) {
63
            loggerConfig.setLevel(Level.INFO);
64
            ctx.updateLoggers();
65 1 1. run : removed call to com/takenoko/engine/GameEngine::runGame → NO_COVERAGE
            new GameEngine().runGame(1, csv);
66
        } else {
67
            logger.log(Level.INFO, "no parameters");
68
        }
69
    }
70
}

Mutations

41

1.1
Location : main
Killed by : none
removed call to com/beust/jcommander/JCommander::parse → NO_COVERAGE

42

1.1
Location : main
Killed by : none
removed call to com/takenoko/Main::run → NO_COVERAGE

51

1.1
Location : run
Killed by : none
negated conditional → NO_COVERAGE

54

1.1
Location : run
Killed by : none
removed call to com/takenoko/engine/GameEngine::runGame → NO_COVERAGE

61

1.1
Location : run
Killed by : none
removed call to com/takenoko/engine/GameEngine::runGame → NO_COVERAGE

62

1.1
Location : run
Killed by : none
negated conditional → NO_COVERAGE

65

1.1
Location : run
Killed by : none
removed call to com/takenoko/engine/GameEngine::runGame → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.8.0