質問内容
https://qiita.com/airtoxin/items/b4f70c6f8dea3d28d656
こちらのサイトの一番下にあるライフゲームを再生しようとしましたが、<IPython.core.display.HTML object>と出てきてアニメーションが出てきません。
これはどういうエラーでどう直せばよいのでしょうか?
ちなみに、Python2.7でコードをコピーして再生しようとしました。
python
1initial = np.random.randint(2, size=(10,10)) 2AnimateArray([initial], cmap='winter').show() 3 4def get_next(current): 5 next_state = [] 6 for i in range(10): 7 next_row = [] 8 for j in range(10): 9 living = current[i-1][j-1] + current[i-1][j] + current[i-1][(j+1)%10] + \ 10 current[i][j-1] + current[i][j] + current[i][(j+1)%10] + \ 11 current[(i+1)%10][j-1] + current[(i+1)%10][j] + current[(i+1)%10][(j+1)%10] 12 next_row.append(1 if living in (3,4) else 0) 13 next_state.append(next_row) 14 return next_state 15 16states = [initial] 17current = initial 18for i in range(1000): 19 current = get_next(current) 20 states.append(np.array(current)) 21 22AnimateArray(states, cmap='winter').show(reflesh=400) 23
あなたの回答
tips
プレビュー