ColorShapeLinks AI
An AI competition for the IEEE Conference on Games 2021
Framework architecture

Architecture of the ColorShapeLinks development framework

Overview

The ColorShapeLinks development framework offers two application frontends: the ConsoleApp and the UnityApp. However, the framework is internally composed of four .NET projects, namely Common, App, Lib and UnityApp, as shown in Figure 1.

dot_inline_dotgraph_1.png
Figure 1. Internal framework organization. Arrows represent dependencies between projects.

The Common project

The Common project is a .NET Standard 2.0 class library which constitutes the core of the framework. It defines fundamental models of the ColorShapeLinks game (i.e., of the unbounded Simplexity game), such as the board, its pieces or performed moves, and is a dependency of the remaining projects. It is further subdivided in the AI and Session namespaces. The former defines AI-related abstractions, such as the AbstractThinker class, which other AI thinkers must extend, as well as a manager for finding and instantiating concrete AI thinkers. The latter specifies a number of match and session-related interfaces, as well as concrete match and session models.

The Common project is hosted in its own branch branch of the Git repository, and is included as a submodule in both the ConsoleApp and UnityApp folders of the master branch, which is why the framework needs to be cloned with the --recurse-submodules Git clone option.

The folder structure of the Common project is organized as follows:

  • Common - Board, pieces, moves, etc.
    • AI - AI-related abstractions and management of AI thinkers.
    • Session - Match and session classes and related interfaces.

Namespaces follow the folder organization. For example, code in the Session folder is under the ColorShapeLinks.Common.Session namespace.

The ConsoleApp projects

The ConsoleApp is composed of two projects, App and Lib, both of which depend on the Common class library, as shown in Figure 1. The App project is a .NET Core console application with an external dependency on the CommandLineParser library and an internal dependency on the Lib project – itself a .NET Standard 2.0 class library. The App project provides the actual console frontend, namely the text user interface (TUI) with which the user interacts in order to run ColorShapeLinks matches and sessions.

The Lib class library acts as an UI-independent "game engine", offering match and session controllers, as well as interfaces for the associated event system, allowing to plug-in renderers (views, in MVC parlance) or other event handling code at runtime. It serves as a middleware between the Common library and frontend applications, such as the one implemented in the App project. It is not used by the Unity implementation, since Unity already provides its own game engine logic, forcing match and session controllers to be tightly integrated with its way of doing things. Nonetheless, the Lib class library makes the creation of new ColorShapeLinks TUIs or GUIs very simple, as long as they're not based on highly prescriptive frameworks such as Unity.

The ConsoleApp projects are organized as follows:

  • ConsoleApp - Console application solution folder.
    • ConsoleApp.sln - Solution file.
    • ColorShapeLinks - Folder containing all projects required by the console app.
      • Common - Reference to the Common project branch.
      • TextBased - Console app folder.
        • App - The console app (.NET Core 3.1 console app).
        • Lib - UI-independent library code for running matches and sessions (.NET Standard 2.0 class library).

As in the case of the Common project, namespaces follow folder organization. For example, code in the Lib folder is under the ColorShapeLinks.TextBased.Lib namespace.

The UnityApp project

The UnityApp is a ColorShapeLinks frontend implemented in the Unity game engine. Like the ConsoleApp, it is designed around the MVC pattern, making use of the models provided by the Common library. In this case, however, the views and controllers are tightly integrated with the Unity engine. The UnityApp project is organized as follows:

  • UnityApp - Unity application solution and project folder.
    • Other Unity folders not relevant for this discussion.
    • Assets - Project assets, such as code and textures.
      • Other asset folders not relevant for this discussion.
      • Scripts - Code assets.
        • Common - Reference to the Common project branch.
        • UnityApp - Unity app source code.