Masaryk University Faculty of Informatics

Adjustable Artificial Intelligence for OpenTTD

Bachelor’s Thesis

Tereza Katreniaková

Brno, Spring 2020

Masaryk University Faculty of Informatics

Adjustable Artificial Intelligence for OpenTTD

Bachelor’s Thesis

Tereza Katreniaková

Brno, Spring 2020

This is where a copy of the official signed thesis assignment and a copy ofthe Statement of an Author is located in the printed version of the document.

Declaration

Hereby I declare that this paper is my original authorial work, which I have worked out on my own. All sources, references, and literature used or excerpted during elaboration of this work are properly cited and listed in complete reference to the due source.

Tereza Katreniaková

Advisor: RNDr. Mgr. Jaroslav Bayer

i

Acknowledgements

iii Abstract

This thesis aims to implement artificial intelligence (AI) for the com- puter game OpenTTD with the ability to set the properties and behav- ior of the AI directly in the game.

iv Keywords

OpenTTD, NoAI API, AI, Squirrel

v

Contents

Introduction 1

1 Open Deluxe 3

Introduction 3 1.1 Game objective ...... 3 1.2 Infrastructure ...... 3

vii

List of Tables

ix

List of Figures

xi

Introduction

Artificial intelligence (AI) is a field of study in computer science that focuses on research and the design of intelligent agents. An intelligent agent is an autonomous entity, which observes the surrounding en- vironment and takes actions to maximize the chance of successfully achieving its goals. The definition of intelligent agents varies between characteristics such as accommodating new problem-solving rules incrementally, adapting online and in real-time, learning through in- teraction with the environment, learning from large amounts of data, having memory-based exemplar storage, having parameters to repre- sent short and long term memory... Artificial Intelligence is nowadays widely used in medicine, robotics, economics, telecommunications, and many more. This thesis focuses on the implementation of AI for Open Transport Tycoon Deluxe (OpenTTD). The use of AIs in video games is nowadays very widespread and popular. An example of artificial intelligence in games can be computer- controlled opponents, content generation, simulation... AI in video games can be defined as a set of algorithms that include control tech- niques from control theory, robotics, computer graphics, and computer science in general. Game AI, therefore, does not represent “true” ar- tificial intelligence in the sense of learning from a large amountof data and making decisions based on the results, but they operate above a predetermined set of inputs and produce a limited number of responses. The goal of this thesis is to analyze, design, and implement AI for OpenTTD, with the possibility to configure the behavior and the properties of the AI directly in the game.

1

1 Open Transport Tycoon Deluxe

OpenTTD is an open-source business simulation computer game, in which each player operates a transport company. OpenTTD is a re- make and expansion of the Chris Sawyers’ Transport Tycoon Deluxe, which introduces additional features. For instance, a multiplayer game, choice of different map sizes, language localization, great support for creating custom artificial intelligence and scripts and much more. OpenTTD runs on multiple platforms (, Unix, ) and is licensed under the GNU General Public Licence version 2.0.

1.1 Game objective

The main goal of the game is to build a profitable company, which is decent competition for other players and their companies. In default settings, the game starts in the year 1950 and ends in 2050, where the final score is computed based on profit, the number ofowned vehicles and stations, number and amount of delivered cargo and other criteria. At the beginning of the game, there are cities and industries located all over the map, from which the player can transport cargo if a station is placed nearby. The profit from the transport is determined byits amount and transportation speed. There is a limited number of vehicle models at the beginning of the game, new models are being unlocked continuously as the game progress.

1.2 Infrastructure

The player has a choice between four modes of transport, which can be combined arbitrarily:

∙ railways (, diesel, electric, monorail and maglev trains)

∙ roadways (buses, trucks, and trams)

∙ airways (airplanes and helicopters)

3 1. Open Transport Tycoon Deluxe

∙ waterways (ships)

The knowledge of the advantages and disadvantages of each mode of transport is crucial to improve profit

4