Professional Documents
Culture Documents
1 Introduction
2D puzzle fighters are a sub-genre of game in which the players solve geometric puzzles. In
other words, the players are responsible for recognizing the pattern to complete it.
However, any multiplayer game should be playable solo – that is to say, against an
appropriate AI player. Such an AI player would need to understand the rules of the game,
victory condition, and the game’s controls (there hereafter: “the game’s systems”).
Furthermore, the AI must prove to be a reasonable challenge.
Therefore, for game development purposes, it is in the best interests of a designer to
initially develop two test cases: a randomly-moving AI, and the best AI possible. This is to
gauge what competency of AI is most appropriate for an average player. The intent of this
paper is to discuss these two test cases in the context of a sample game, their
implementations, and what was learned during the process.
Figure 2 Players score by filling in a row or column. Yellow is about to score 2 lines.
3.1 AI Architecture
The original plan to facilitate the game’s AI was to design a “Behavior Forest” architecture.
The intent was for there to be templates from which Behavior Trees would be built and
stored in the “forest”. As the game state progresses, the AI would pick a more offensive,
defensive, accurate, or agile Behavior Tree template based on its analysis of the game state.
However, upon presenting this plan at a GAM presentation, Chi-Hao Kuo pointed
out that, due to the low number of options available to a player at a given time, a utility-
based architecture would be simpler to implement and still suit our needs. This advice was
not initially heeded, leading to about 10 hours of “wasted” development as it became clearer
that such an architecture would require a massive time investment. Instead, a utility-based
architecture with a finite state machine (for control flow) was selected:
- The utility-based architecture would assign each of the available options an
attractiveness value. Since the goal is to develop the upper bar for ShockLock’s AI,
we can simply choose the most attractive option.
- The finite state machine allows us to make a cycle in which each state is its own
frame. Simplified, these are:
o ReceivedNewMoveRequest
o CopyData
o StallCalculation
o AnalyzeBottomRows
Analyze moves that fill rows, but only in the bottom half of the board
o AnalyzeTopRows
Analyze moves that fill rows, but only in the top half of the board
o AnalyzeLeftColumns
Analyze moves that fill columns, but only in the left half…
o AnalyzeRightColumns
Analyze moves that fill columns, but only in the right half…
o ChooseMove
o SendChosenMove
This allows us to spread the work of choosing a move over the course of 9 frames.
Attempting to place all 1024 move evaluations in a single frame results in both the WebGL
and Mono builds “stuttering”, with the WebGL version also crashing due to running out of
memory – the garbage collector was unable to keep up.
4
3.2 Playtesting
Deciding on the formula for attractiveness required gaining an understanding of how actual
players of the game operated.
According to the lead designer, playtesting data showed that players who “filled
holes” (see Figure 3) before preparing to fill lines. Furthermore, it appeared to be self-
evident that placing larger pieces would allow for more lines to be filled per time unit.
Therefore, the equation for attractiveness (assuming that the option is valid) needs to
account for:
- Number of lines filled
- Number of holes filled
- Size of the piece
4 Comparisons
This shows that the AI is roughly 15% better than me at filling lines, and is therefore able to
compete against me.
6
5 Conclusion