Metroid Learning – The Core

The core script can be metaphorically described as the brain of the AI. It utilizes all the other scripts and is therefore considered the most important element of the project. It is also the most overwhelming, since it consists of over 1100 lines of code (in comparison: the game script boils down to 170 lines). Quite some time ago, I analyzed the functionality of this very script. Today, I want to bring structure into it.

In this blog, I try to structure the code of MarI/O’s core script so that I can salvage re-usable parts and determine the next steps of the project.

Figure 1 – Core Script Segments

When I first approached this script months ago, I tried to figure out what it was supposed to do – by inspecting every single line of code of it.
In conclusion, that analysis resulted in a deeper understanding about the MarI/O project and I realized that some parts of it were implemented in such an abstract fashion that they could be used for any project, while many other pieces of functionality were not. But what exactly is that?

 

The script can be structured into four segments, as shown in Figure 1. I decided the names of the segments based on their functionality. Most functions that I would group together are not; thus, the relevative values of this graph are estimated and rounded.

The NEAT Functions segment contains all functions that are required to build and maintain the neural network. It is by far the largest segment. Important to note is that it is only a collection of functions – none of this segment’s code is executed on its own.
This entire segment is reusable without any circumstances.

The Display Checks segment contains everything that is required for sprite recognition. The AI does not see the game the same way we do. It tries to recognize the game’s sprites on the screen. Based on the sprite list, it is able to differentiate between power-up and enemy. This code segment checks the screen for sprites – and draws the AI’s vision, network structure and status on the upper half of the screen.
This segment seems reusable; it might need some minor adjustments, though.

The File Management segment contains all functions related to saving and loading data.
This segment needs some adaptions to fit Super Metroids player data.

The Reinforcement Learning segment contains the whole learning process. It is responsible for most of the decision making process. It contains the algorithm that makes the AI behave the way it should.
This segment means trouble. It will take a lot of effort, experiments and luck to get this working.

The next logical step is to replace all Super Mario World specific pieces of code with ones of Super Metroid. After that, the AI can be put to its first test, which will (hopefully) show misbehavior. If it shows any behavior, I see this as an absolute win.

 

 

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

acht − 5 =