Technical Report of Conway`s Inverse Game of Life

Machine Learning: Technical Report of Conway’s Inverse
Game of Life
Instructed by Liwei Wang
Due on Jan 14th, 2013
H. Jiachen, T. Zihan, H. Heping, Z. Zeyu
1
Formulation of the Problem
The Game of Life is a cellular automaton created by mathematician John Conway in 1970. The game consists of a
board of cells that are either on or off. One creates an initial configuration of these on/off states and observes how it
evolves. There are four simple rules to determine the next state of the game board, given the current state.
1.Any live cell with fewer than two live neighbors dies, as if caused by under-population.
2.Any live cell with two or three live neighbors lives on to the next generation.
3.Any live cell with more than three live neighbors dies, as if by overcrowding.
4.Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.
2
Observations about Conway’s Reverse Game of Life
Three important observations are made after some experiment. These features will lead us to design better learning
algorithms.
• Locality
The state of a cell depends mostly on the origin configuration of its neighborhood, since the rule requires the
resulting state of next round is determined by the states of surrounding 9 cells in the current round. This locality
guides us to make decision based on neighboring configuration.
• Clustering
After some experiment of the game, an important is made: The more number of rounds is, the more clustering the
final configuration is. This is also the performance of lives. People tend to live together locally but not separately. This
feature to some extent characterize Conway’s Life game.
• Non-Uniqueness
Given an origin state, the proceeding algorithm is deterministic, but given a resulting state, the initial state is not
unique. Thus, finding a feasible solution is meaningless. Instead, those origin configuration with high likelihood is
what we need.
3
3.1
Ideas and Framework of Algorithm
Basic Notions
Some definitions are in order first to let the following algorithms and arguments make sense.
H. Jiachen, T. Zihan, H. Heping,Technical
Z. Zeyu Report of Conway’s Inverse Game of Life
Our data is generated in the following style: A random sampled configuration evolved 5 round, and the resulting
configuration is given as the “base” configuration, and our input is the resulting configuration of “base” configuration
after 5 round.
The following graph clarify our notions for certain configurations and cells:
Initial Configuration → Origin Configuration → Resulting Configuration
Initial State → Origin State → Resulting State
3.2
Stream of Algorithms
In this section, we introduce every algorithm that we have come up with in this project. Some of them have certain
flaws, and new ideas and construction are invented to overcome them.
• Local Perfect Trace Back
After some experiment, the clustering observation first came into our mind. Since the origin state is the resulting
state of a random sampled initial configuration after 5 rounds. It is stable in some measure, i.e. with good probability,
the origin state is well-clustered already. Thus, it will be helpful to find Local Perfect Trace Back, the specific
algorithm is the following:
First we do clustering of the resulting state, then for every cluster we design an algorithm to figure out a feasible
local origin configuration for it. Finally we combine these local configurations to be our guess of origin configuration.
Drawback:
Sometimes the performance of clustering is not that satisfying because the size of clustering is so large that it is
rather inefficient to find the local perfect track back. On the other hand, the Non-Uniqueness observation tells us that
finding a perfect track back is not that necessary and sometimes it has large deviation. Even if we get a perfect trace
back for the whole configuration from combining partial ones, some mutation will happen at the connection/intersection of some clusters so that the resulting configuration of our state is not always good.
• Local Likelihood for Single Guess
Following the Non-Uniqueness observation, likelihood of neighboring configuration is computed to help determine the state of a cell in origin configuration. Thus, given the resulting configuration, we focus on one cell and make
decision of its origin states based on the neighboring configuration.
What is local? A explicit size should be determined to make the algorithm work. However, there is a trade off
between the following two perspectives on deciding the size.
(1) Small size limits the accuracy of our knowledge of likelihood, and it will therefore influence the probability of
guessing right.
(2) Large size needs large space in storage, and when given an resulting state, our algorithm is indeed inefficient
for giving an output since it will search deeply into the data-tree otherwise the deep training is meaningless.
After some experiment we set t = 5, i.e. we decide the origin state of a cell based on the knowledge of the 5 × 5
configuration in the resulting configuration. t = 5 also makes our knowledge symmetric in every direction.
Drawback:
On one hand, the coverage of 5 × 5 configuration is not good, here the coverage is the fraction between number
of appeared configuration and the number of possible configurations (225 ), which makes our guess unavailable at
some input resulting configuration, this drawback can be overcome by changing the method of searching 5 × 5 local
configuration into developing a BFS style data-tree.
On the other hand, the following problem occurs too many time so that the general performance is not satisfying.
Page 2 of 6
H. Jiachen, T. Zihan, H. Heping,Technical
Z. Zeyu Report of Conway’s Inverse Game of Life
0.4 0.4
0.4 0.4
!
(1)
At some 2 × 2 local configuration, the likelihood is approximately 40 percent for each cell. However, according to
method of maximum likelihood we should guess “dead”, but the real case of origin local configuration is usually one
the following two:
1
0
0
1
!
0
1
1
0
!
(2)
This local error has huge impact on performance. It is because every time we make guess on a single cell but not
a local small configuration. Certain relation between neighboring cells is not taken into concern.
• Simulated Annealing for Local Likelihood for Single Guess
The first change we made for overcoming the lack of relation in Single Guess learning algorithm is Simulated
Annealing. We use standard Local Likelihood for Single Guess to get a guessing origin configuration, then evolve it
5 rounds to get a resulting state, then compare it with the input resulting state, add certain alive cells according to the
likelihood, use the new resulting state as the input of algorithm and run Local Likelihood for Single Guess again.
• Local Likelihood for Local Guess
Following the Clustering observation, and the drawback of Local Likelihood for Single Guess algorithm, it is
helpful to make decision on some local cells simultaneously rather than a single cell. Since it is observed that the
method maximum likelihood often give us four dead cell output even if the likelihood to be alive is about 40 percent
each, in which case it is of high probability that two of them are alive.
We first develop a database containing the likelihood of central cell to be alive for each configuration. They are
stored in a tree. Method of maximum likelihood is employed to made final decisions. And they also help to stop the
development of the data tree for the limit of storage. The details are listed below:
(1) Consider the limit of storage and the requirement of efficiency, we focus on deciding 2 × 2 local configuration
based on our knowledge on the surrounding 4 × 4 local configuration in the input resulting configuration.
(2) We compute the likelihood for every 2 × 2 possible outcome for local configuration, given that the resulting
4 × 4 local configuration is the input local configuration. Conditional probability method is used in guessing the origin
local configuration.
3.3
Training
The data tree is developed in BFS style. Every round a new layer is generated, which means a wider neighborhood
comes into consideration. When the likelihood goes beyond the threshold probability at some leaf node, it then stops
developing.
Example: w = 6, t = 2, D = 1000000maps, p = 0.42, f = 400
Page 3 of 6
H. Jiachen, T. Zihan, H. Heping,Technical
Z. Zeyu Report of Conway’s Inverse Game of Life
Algorithm 1: Train
Input: Search width w, train width t, training data D, probability threshold p, frequency threshold f
Output: Binary search tree
1 TreeHead.EndSearch ← f alse
2
2 for TreeDepth d ← 1 to w − 1 do
3
for All the w × w rectangles ri in the end maps of D do
4
Node ← TreeHead
5
c ← the center cell of ri
6
while Node.HaveSon & Node.Depth < d do
7
if c is dead then
8
Node ← Node.Left
10
else
Node ← Node.Right
11
c ← Next c (Spiral from the center of ri )
9
12
13
14
15
16
17
18
19
20
21
22
if Node.Depth = d & Node.EndSearch = f alse then
Node ← Node.Left/Right (Depends on c. If there is no son, new one)
ri0 ← the corresponding t × t rectangle in the start map (The rectangle is the center of ri )
Node.Config(ri0 ).Freq++
Node.Freq++
for Every leaf node Node where Node.Depth = d + 1 do
Node.EndSearch = true
2
for ri0 ∈ {0, 1}t do
Node.Config(ri0 ).Freq
if Node.Freq > f & |
− 21 | < p then
Node.Freq
Node.EndSearch = f alse
return TreeHead
Page 4 of 6
H. Jiachen, T. Zihan, H. Heping,Technical
Z. Zeyu Report of Conway’s Inverse Game of Life
3.4
Explicit Algorithm Box
Method of maximum likelihood is employed to make decisions on local cells. Data for computing is extracted from
our training tree.
Algorithm 2: Run
Input: End map E, search width w, TreeHead (with train width t), TreeHead’ (with train width 1), frequency
threshold f 0
Output: Start map S
1 for Each cell c in E do
2
c0 ← c
3
Node ← TreeHead’
4
while Node.HaveSon do
5
if c0 is dead then
6
Node ← Node.Left
8
else
Node ← Node.Right
9
c0 ← Next c0 (Spiral from the center c)
7
10
11
12
13
14
15
16
17
4
if | Node.Config(1).Freq
− 12 | > p0 then
Node.Freq
S.Position(c) ← sgn( Node.Config(1).Freq
− 12 )
Node.Freq
else
Find all the t × t rectangles ri covering c
Use the method in line 2-10 (but using TreeHead and c0 ← the center of ri ) to find all the t × t
configration probabilities in ri
Calculate the most likely configuration of the (2t − 1) × (2t − 1) rectangle with center c
S.Position(c) ← the answer
return S
Experiment and Result
We tried three mechanisms by now. Here is the result.
We first tried generating the tree mentioned in the previous section. Due to the fact that the tree may have limitations in this growth speed, we first tried a small training set (that is 100 ∗ 1024 configurations per layer). The result
came out to be 12.35, and we can get the seventh at the time. Afterwards, we tried determining cells in block style,
that is, we consider the overall probability of a 2 ∗ 2 grid. Unfortunately, this works better than naive tree generating
mechanism only in the one-step case.
Mechanism \ Steps
Tree-Gen(1)
Blockwise
Tree-Gen(2)
1
9.99
9.68
9.51
2
12.21
12.24
11.79
3
12.96
13.04
12.66
4
13.24
13.37
13.10
5
13.36
13.48
13.29
Avg.
12.35
12.36
12.07
Table 1: Performance of three mechanisms we have tried.
Page 5 of 6
H. Jiachen, T. Zihan, H. Heping,Technical
Z. Zeyu Report of Conway’s Inverse Game of Life
More efforts are devoted into the intuition of simulated annealing and the use of conditional probability. Unfortunately, due to limited time we didn’t come up with a version which works well, so we decided to construct a bigger
tree using the first tree generation idea. This time we used 100 ∗ 16384 configurations per layer to construct the BST.
Although the size of the tree has been considerably large, performance seemed to be better. The result error rate turned
out to be 12.07 on my laptop, and in Kaggle 12.1038. We are now the 9th on the leaderboard.
A bigger tree may lead another leap in performance, but we have no enough computational resources to afford it.
Moreover, I think that there are still chance to significantly improve the performance of block style estimation.
Page 6 of 6