Dunham Alves Tetris Game Playing
Dunham Alves Tetris Game Playing
PROJECT DESCRIPTION
Underlying Representation
Unlike other analyses of the Tetris problem where the state
space has been reduced or simplified in order to reduce the
state space, in our implementation we considered a full
Tetris grid of width 10, and length 24 [TODO CIT]. There
exist seven possible block types:
B: {“LINE”, “SQUARE”, “Z”, “S”, “L”, “REVERSE_L”,
“TRIANGLE”}
With both of those functions written the algorithm
Additionally, each piece can be rotated into at most 4 of the reflex agent can be presented. The reflex agent
different pieces. This leads to the state space being works by first creating a list of all successor states that
exceptionally large. For example, consider any grid with a complete the greatest number of lines, and then choosing
s-piece about to be dropped. There are 30 different among those states those that score highest on a hand tuned
potential successor states that result from just one piece linear combination of the above two functions. The code is
being dropped. as follows:
applyRuleSet(permutations, old_grid):
Internally each state of the Tetris game was max = 0
represented as a 10x24 Matrix of values {0,1} depending sieve_results = list()
on whether that location in the grid was empty or not. As for p in permutations:
new piece was introduced to the grid, the various agents count = countCompletedLines(p)
were passed a list of grid states that represented all possible if count > max:
permutations of successor states. The agents then returned sieve_results = list()
sieve_results.append(p)
a list of actions for the game engine to execute. max = count
elif count == max:
Reflex Agent sieve_results.append(p)
The reflex agent was the first agent that was choice = max(sieve_results,
implemented and tested. The reflex agent acted as a key=lambda x:1 * calculateCompactness(x,
baseline for the subsequent agents in order to measure x.height, x.width)
performance. The reflex agent was designed with the + -.7 *
checkUnreachable(old_grid, x))
following informal rule set in mind "Complete lines when return choice
possible. Otherwise attempt to make the grid as compact as
possible and avoid making holes." Although the above algorithm seems simplistic, it actually
performs well in practice. It outperforms one of the authors
The first challenge was to formulate the
compactness of the graph in a way that the reflex agent of this paper and often completes 10 plus lines a game.
would treat properly. The algorithm that was chosen is as
follows: Q Learning Agent