Generating a GUI for a game

It is not necessary for a game to have a GUI to run it in TAG. However a GUI can be very helpful in debugging a game (or AI agents) by playing against them. It is also essential if you want humans to play the game. Note that currently TAG does not have support for more than one human player at a time.

To implement a GUI, a GUIManager must be implemented (extending from AbstractGUIManager). This has two things that need to be implemented:

Constructor

    public NewGUIManager(GamePanel parent, ActionController ac, int maxActionSpace) {
        super(parent, ac, maxActionSpace);
      // and whatever else is needed for specific Views 
      // These can be anything that extends JComponent
      // once created they need to be added to the parent GamePanel with:
      //    parent.add(view);
    }

The default GUI manager support a minimal set of data:

  • The current game score for all players, and the game state
  • A history panel showing all actions taken so far
  • An action panel for human player to select an available action on their turn

Functionality in these can be overridden if required via createGameStateInfoPanel(...) and createActionPanel(...). Everything else needs to be implemented in a game-specific fashion.

An _update method

   protected void _update(AbstractPlayer player, AbstractGameState gameState) {
     // update the GUI Views with the current game state
     
     parent.repaint();
   }

Standard Views

There are a number of standard Views implemented for the core Component types (in the gui.views package). The most functionally rich and useful of these is DeckView which can be used to easily display decks of cards (see LoveLetterGUIManager, or others for examples of how to use this).

An index of example GUIs can be found here.