s3games

## Class Controller

- java.lang.Object
- - s3games.Controller

- All Implemented Interfaces:
    java.lang.Runnable, SwitchListener

      public class Controller
      extends java.lang.Object
      implements SwitchListener, java.lang.Runnable

  The Controller class is the main logic of the application. It holds one ControllerWindow which is the main menu and responds to the user actions by invoking the corresponding actions.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Controller()` constructs and shows main window and the minimum agenda

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `controlRobot()` opens a window that allows a direct robot arm control - can be used for finding the robot arm angles of individual positions on the field
    `java.lang.String[]` | `getGameNames()` should return the list of available games, this should probably go to some external file (?)
    `java.lang.String[]` | `getHeuristicsForGame(java.lang.String strategyName)` returns list of heuristics that are compatible with the specified strategy - also a place for improvement
    `java.lang.String[]` | `getLearnableStrategyTypesForGame(java.lang.String gameName)` returns a list of strategies that can learn to play the specified game - improve...?
    `int` | `getNumberOfPlayersForGame(java.lang.String gameName)` return the number of players for the specified game - should read the specs...fixit!
    `java.lang.String[]` | `getStrategiesForGame(java.lang.String gameName)` returns list of strategies that can play the specified game, we should improve this architecture somehow later
    `int` | `learn(java.lang.String gameName, Player.boardType boardType, Player.playerType[] playerTypes, java.lang.String[] playerStrategies, java.lang.String[] strategyHeuristics, java.lang.String learnStrategyType, java.lang.String strategyFileName, int numberOfRuns)` tries to learn to play a game - not yet in use
    `void` | `play(java.lang.String gameName, Player.boardType boardType, Player.playerType[] playerTypes, java.lang.String[] playerStrategies, java.lang.String[] strategyHeuristics, int numberOfRuns)` starts a single game
    `void` | `run()` a controller thread that plays all the games in this round - usually just one
    `void` | `switchChanged(boolean newState)` called automatically when a game starts or stops

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Controller

          public Controller()

      constructs and shows main window and the minimum agenda

  - ### Method Detail

    - #### switchChanged

          public void switchChanged(boolean newState)

      called automatically when a game starts or stops
      Specified by:
        `switchChanged` in interface `SwitchListener`

    - #### getGameNames

          public java.lang.String[] getGameNames()

      should return the list of available games, this should probably go to some external file (?)

    - #### getStrategiesForGame

          public java.lang.String[] getStrategiesForGame(java.lang.String gameName)

      returns list of strategies that can play the specified game, we should improve this architecture somehow later

    - #### getHeuristicsForGame

          public java.lang.String[] getHeuristicsForGame(java.lang.String strategyName)

      returns list of heuristics that are compatible with the specified strategy - also a place for improvement

    - #### getLearnableStrategyTypesForGame

          public java.lang.String[] getLearnableStrategyTypesForGame(java.lang.String gameName)

      returns a list of strategies that can learn to play the specified game - improve...?

    - #### getNumberOfPlayersForGame

          public int getNumberOfPlayersForGame(java.lang.String gameName)

      return the number of players for the specified game - should read the specs...fixit!

    - #### play

          public void play(java.lang.String gameName,
                  Player.boardType boardType,
                  Player.playerType[] playerTypes,
                  java.lang.String[] playerStrategies,
                  java.lang.String[] strategyHeuristics,
                  int numberOfRuns)

      starts a single game
      Parameters:
        `gameName` - name of the game to play
        `boardType` - real or simulated
        `playerTypes` - for each player whether it is a human or a computer
        `playerStrategies` - only for computer players, name of strategy to use
        `strategyHeuristics` - name of heuristic to use for each computer player
        `numberOfRuns` - how many times to play this game (normally 1, but higher when running statistical runs)

    - #### run

          public void run()

      a controller thread that plays all the games in this round - usually just one
      Specified by:
        `run` in interface `java.lang.Runnable`

    - #### learn

          public int learn(java.lang.String gameName,
                  Player.boardType boardType,
                  Player.playerType[] playerTypes,
                  java.lang.String[] playerStrategies,
                  java.lang.String[] strategyHeuristics,
                  java.lang.String learnStrategyType,
                  java.lang.String strategyFileName,
                  int numberOfRuns)

      tries to learn to play a game - not yet in use
      Parameters:
        `gameName` - name of the game to play
        `boardType` - real or simulated
        `playerTypes` - for each player whether it is a human or a computer
        `playerStrategies` - only for computer players, name of strategy to use
        `strategyHeuristics` - name of heuristic to use for computer players
        `strategyFileName` - where should we save the learned strategy
        `numberOfRuns` - how many times to play the game while learning
        `learnStrategyType` - strategy that will be learned
      Returns:
        the number of player who won, 0 for draw/nobody, -1 if game was interrupted

    - #### controlRobot

          public void controlRobot()

      opens a window that allows a direct robot arm control - can be used for finding the robot arm angles of individual positions on the field