Tetris Strategies in a Multiplayer Environment
Total Page:16
File Type:pdf, Size:1020Kb
Universiteit Leiden Opleiding Informatica Tetris Strategies in a Multiplayer Environment Name: Chivany van der Werff Date: 29/09/16 1st supervisor: W.A. Kosters 2nd supervisor: H.J. Hoogeboom BACHELOR THESIS Leiden Institute of Advanced Computer Science (LIACS) Leiden University Niels Bohrweg 1 2333 CA Leiden The Netherlands Contents Abstract 1 1 Introduction 2 2 The Game 4 2.1 The Players . 4 2.2 The Board . 4 2.3 Pieces . 4 2.4 Hold-Function . 5 2.5 RuleSet.................................................... 6 2.6 Goals..................................................... 6 3 Related Work 8 4 Approach 9 4.1 Search Algorithms . 9 4.1.1 MiniMax Search Algorithm . 9 4.1.2 Alpha-Beta Pruning Search Algorithm . 10 4.1.3 Evaluation Functions . 10 4.2 Basic Monte Carlo Tree Search . 11 4.3 Strategies . 11 4.3.1 Random Player . 11 4.3.2 Rule-based Player: Alpha-Beta Pruning Search Algorithm . 11 4.3.3 Monte Carlo Player . 13 5 Experiments 14 5.1 Results . 16 6 Conclusions and Future Work 21 References 23 Abstract Tetris is a puzzle game which can be played in a single player or multiplayer mode. Most research done regarding Tetris was in a single player environment. Therefore, in this thesis we will try to find out which of three different strategies performs better when competing against one another in different multiplayer Tetris environments. In our research a multiplayer game has two players. For this research we have developed a Tetris variant with a different and more restrictive set of rules in order to simplify the game and reduce the amount of possible moves during each turn. We will use different strategies, namely: Random, Rule-based, and Monte Carlo. There are three goals that the strategies will try to achieve. The goals are: (1.) The player who has cleared the most lines at the end of a game is the winner; (2.) The player who is the first to clear a line, wins the game; (3.) The player whose Tetromino sticks out above row m in an m × n sized board loses the game. Aside from different goals we will also vary the board size. Lastly, we will implement a Hold-function which is assessed by enabling and disabling this function in the different environments and setups. Results have been gathered from each setup which show the significance of a Hold-function, but also that in the environments the Rule-based player was the most successful. Also, whenever n = 20 for an m × n board, all the players performed badly. 1 Chapter 1 Introduction The game Tetris [12] was developed in June 1984 by the Artificial Intelligence researcher Alexey Pajitnov. It was firstly introduced as a single player game with a board that has 20 rows and 10 columns (20 × 10) and pieces named Tetrominoes which appear at the top of the board, one at a time. The player on the board needs to decide how to place this random Tetromino while it falls down until it is unmovable when it lands on a surface. Nowadays, Tetris often has a Hold-function implemented in the game, which allows a player to store exactly one Tetromino in its space. Figure 1.1 shows an official present-day single player Tetris game where the Hold-function can also be seen. Tetris is a puzzle-like game where the goal is to clear as many lines as possible which will earn the player points. For players to be able to play the game well, strategies are required. Human players need a lot of practice to be able to master certain strategies on a high level but artificial players are able to do this either in a shorter amount of time or do not need to learn or practice anything beforehand. We look at the latter type of artificial players which will use the Alpha-Beta Pruning search algorithm, also referred to as the Rule-based Player. In this paper we investigate three Tetris strategies. The three strategies that will be tested are: (1.) Random; (2.) Rule-based; (3.) Monte Carlo. We created setups where the strategies play against one another and based on the results we draw a conclusion for the performances of the players. The reason for picking a multiplayer environment is because most research on Tetris was done in a single player environment which excludes a lot of influences that are present in multiplayer Tetris games. Research in this environment would thus give different results than in a single player environment. To measure the performance, the strategies will play in environments with different board sizes and goals. We will also im- plement a Hold-function to see if it improves the performance of the strategies in the different environments. For our research we will be using a simplified version of Tetris because of the fact that the number of pos- sible states in the original game with a board size of 20 × 10 is around 1060 [3]. If played according to the rules of the official game, every newly spawned Tetromino can have a large number of possible placements depending on the present blockstructure in the field. To decrease the nodes in the state space along with the computational time, and thus reducing the complexity, we simplified the game. Figure 1.1: Playstation Network (PS3) Tetris® showing a present-day single player game [17]. 2 We will give a short description of the remaining chapters of this thesis. In Chapter 2 we will be thoroughly explaining our variant of the game. Chapter 3 discusses related work to this research; Chapter 4 discusses our approach for this research; Chapter 5 discusses the experiments and the results; and lastly in Chapter 6 we draw conclusions and give suggestions for future work. This thesis was written as a Bachelor project at the Leiden Institute of Advanced Computer Science (LIACS) of Leiden University, and has been been supervised by Walter A. Kosters and Hendrik Jan Hoogeboom. 3 Chapter 2 The Game As was mentioned before, we will be working with a simplified version of Tetris to reduce the complexity of the game which will make for a faster computation. In this section we will explain the proposed alterations thoroughly. 2.1 The Players There are two players in each game. The players will play on the same field and switch turns after they have placed a Tetromino in the field. A score is kept for each player. The score indicates the amount of cleared lines per player. 2.2 The Board The testing will start out on an m × n board and will be altered to a smaller or bigger board depending on the strength of the opponent and the results. Tetrominoes are out of bounds if their blocks exceed beyond row number m of the board. A sequence of random Tetrominoes falls down on the playing field. In contrast to the original Tetris game, the Tetromino next in line to appear can only be rotated and moved (horizontally) at the top of the board when and where it first appears. After the player has made his choice in rotation and position, the Tetromino will fall down in a straight line. During that process the player is unable to move or rotate the piece. 2.3 Pieces Tetris has a set of seven different pieces called Tetrominoes. In the original Tetris game they are referred to as “Tetriminos” but in this paper we will use the word “Tetrominoes” since it is the definition of geometric shapes that consist of four square-shaped blocks. The different pieces and their rotations are named and displayed on the next page: 4 Figure 2.1: The I-Tetromino and its two possible rotations. Figure 2.2: The J-Tetromino and its four possible rotations. Figure 2.3: The L-Tetromino and its four possible rotations. Figure 2.4: The O-Tetromino and its only possible state. Figure 2.5: The S-Tetromino and its two possible rotations. Figure 2.6: The Z-Tetromino and its two possible rotations. Figure 2.7: The T-Tetromino and its four possible rotations. The game starts with one of the seven pieces being randomly introduced onto the top-most row (row m) of the field and depending on the piece and the rotation its blocks will at least touch the mth row and at most the (m − 3)th row. After the current piece has been rotated and moved by the player, it will be dropped in a straight line on the field. After the landing, the next random Tetromino will be introduced at the top of the field. The pieces always arrive at a fixed position on the field. 2.4 Hold-Function This function is a space which can hold a Tetromino. This gives a player when it is his turn the ability to store a recently spawned piece into this space. If the current Tetromino that has spawned makes up for a worse move than the Tetromino that is already stored in the Hold space, they are swapped. This means that the 5 Tetromino in the Hold space is taken out and the Tetromino that has recently spawned at the top of the field is stored within that space. The previous Hold Tetromino is then used within the field. In the first original Tetris game this function had not been implemented yet. This feature was implemented later on and is very common in contemporary Tetris. The Hold-function is thus not always enabled. 2.5 Rule Set Our variant of Tetris used for this research has a specific rule set.