Table of Contents
This software was developed as a fourth-year dissertation project for the University of Strathclyde.
Artificially intelligent (AI) agents in games can be surprisingly unintelligent. Particularly in board games, players are often faced a range of AI opponents represented by convoluted difficulty selectors. Creating custom AI opponents not only results in extra work for the developers, but also impairs the player’s enjoyment of the game. Mismatches in the skill level of players can results in either player growing frustrated or becoming bored. Current dynamic difficulty adjustment (DDA) techniques rely on game-specific evaluations, restricting their application to the game industry at large.
This project introduces a new DDA technique, prolongation bias, whereby the Monte Carlo Tree Search algorithm is adapted to prioritise game elongation. Experiments carried out with a sample size of 81 participants show the AI utilising the prolongation bias technique can dynamically adapt its difficulty to players with a range of skill levels and increase the human player’s enjoyment and satisfaction of matches against computer-controlled opponents.
In order to test the AI, a two-player abstract board game had to be chosen. Gomoku, also known as Five in a Row, was picked as the best candidate out of various board games. Details about this decision can be found here.
The fofmat of the game are simple: two players take turns placing black and white tokens on a board whilst trying to chain these pieces five in a row, either horizontally, vertically or diagonally. Gomoku can be classified as an m, n, k-game. During the process of development, it was found that "pure" Monte Carlo Tree Search performs poorly on a traditional 15 by 15 Gomoku-board. Instead, a 7 by 7 board was used for the purposes of this research.
.
├── dist · JavaScript compiled from TypeScript. Mirrors \src\ts\.
├── res · Resources, such as images and icons.
├── test · Mocha Unit tests for JavaScript files in \dist\.
└── src · The website's source code.
├── css · Styling for all HTML pages, organized from high- to low-level.
├── html · All HTML pages, both high- and low-level.
└── ts · Logic and back-end of the software.
├── controller · Controllers connecting models and views, MVC design pattern.
├── factory · Classes following the factory method design pattern.
├── model · Part of the MVC. In practice, defines games as a Markov decision process.
├── player · Defines a hierarchy of player-classes, including various AI players.
├── script · Files referenced directly by HTML pages. Instantiates MVC classes.
├── utility · Common utility classes used extensively in other parts of the system.
└── view · Part of MVC. Utilises JQuery to manipulate the DOM.
Please refer to instructions on setting up a local test server if you wish to host and run the project locally. Alternatively, visit the web application hosted on GitHub Pages to run the software on any modern browser, as well as to install it as a Progressive Web App (PWA).
The code located in the \dist\
directory is JavaScript (JS), compiled from TypeScript located in \src/ts\
. TypeScript (TS) is a strongly-typed language, also allowing for additional object oriented features to be used on top of what JS already used. If making any changes to the TS code, any changed files must be re-compiled. Please refer to the official TypeScript page for instructions on downloading, running and using TS.
For this project, v4.6.2
of TS was used. To compile modified JS files, run the following command in the root directory of the project:
tsc build
Mocha and Chai for testing, two open-source JS unit testing frameworks. Testing was focused on the Model (i.e., the game) and related classes. To simplify the process, tests were written for and run on compiled JS, as opposed to the source TypeScript files. Unit tests are located in the \test\
directory.
Node.js must be installed before unit tests can be executed (v14.18.1
is used in this project). Assuming this is the case, and you're located in the project's root folder, the following commands will both install dependencies in the package.json
for this project, and run all unit tests:
npm install
npm test
- For additional details, as well as the development process for this project, visit this Notion Workspace. The paper written as part of this project can be read here. The UI was designed in Figma; an interactive prorotype can be found at this page.
I want to thank Dr. John Levine for supervising, and providing his invaluable support and guidance troughout this project.
Resource | Usage |
---|---|
Material Design 3 | Guidelines for the design and creation of the UI. |
TypeScript | Back-end of system, particularly the model (the game) and the several AI agents. |
JQuery | UI animations, particularly navigating from page-to-page. |
PWA technology | Making the app installable on multiple platforms. The PWA Builder extension for VS Code was used in particular. |
GitHub Pages | Hosting the web app. |
Mocha and Chai | Unit testing. |
TypeDoc | Exporting documentation to HTML. |
Zapsplat | In-game sound-effects. |