All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.fhkiel.ki.cathedral.Tester Maven / Gradle / Ivy

The newest version!
package de.fhkiel.ki.cathedral;

import de.fhkiel.ki.cathedral.ai.Agent;
import de.fhkiel.ki.cathedral.game.Building;
import de.fhkiel.ki.cathedral.game.Game;
import de.fhkiel.ki.cathedral.game.Placement;
import de.fhkiel.ki.cathedral.gui.CathedralGUI;
import de.fhkiel.ki.cathedral.gui.Settings;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Optional;
import java.util.Random;
import java.util.Set;

class Tester {
  public static void main(String[] args) {
    CathedralGUI.start(
        Settings.Builder()
            .token("MTI4OTk0MDAwNzk2Mzk4MzkwMw.GfGUUW.eNjmHh-_O6tg_HmHRDkM3l4eXLW3QKqn0r52GI")
            .default_channel("ki-fh-kiel::bot-v-bot")
            .build(),
        new AITest());
  }

  static class AITest implements Agent {
    PrintStream console;

    @Override
    public void initialize(Game game, PrintStream console) {
      this.console = console;
    }

    @Override
    public Optional calculateTurn(Game game, int timeForTurn, int timeBonus) {
      Set placements = new HashSet<>();
      for(Building b : game.getPlacableBuildings()){
        placements.addAll(b.getPossiblePlacements(game));
      }

      console.println("Buildings: " + placements.size());

      if(placements.isEmpty()) {
        return Optional.empty();
      } else {
        return Optional.of(new ArrayList(placements).get(new Random().nextInt(placements.size())));
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy