[PYTHON] I tried to make Othello AI with tensorflow without understanding the theory of machine learning ~ Introduction ~

Series table of contents

--I tried to make Othello AI with tensorflow without understanding the theory of machine learning-Introduction- -I tried to make Othello AI with tensorflow without understanding the theory of machine learning-Implementation- -I tried to make Othello AI with tensorflow without understanding the theory of machine learning-Iza battle- -I tried to make Othello AI after trying to understand the theory of machine learning ~ Restart! ~ -I tried to make Othello AI after trying to understand the theory of machine learning-What is this Alpha Zero edition- -I tried to make a neutral network with Excel to understand the theory of machine learning ~ Image recognition mnist edition ~

In this field, as an outsider, I didn't study "theory of machine learning" at all. I would like to make an AI for Othello. Click here for the referenced site ・ Implement DQN (Deep Q Network) with TensorFlow in a super-simple manner ~ Introduction ~

Overview

If you explain the concept roughly AI.png Two artificial intelligences confront Othello earnestly, Save the AI behind and fight me (human). That's why.

Environmental condition

My environment is as follows. OS ・ Ubuntu Development environment ・ Python 3.5

I think it works in this environment Building Ubuntu python development environment on Google Cloud Platform

Let's move it first

First, download the source code. The source is here. $ git clone https://github.com/sasaco/tf-dqn-reversi.git

Learning

When the environment is ready, move to the source code directory and hit train.py to start learning.

python


$ cd tf-dqn-reversi
$ python train.py

If you see the following log, you are learning correctly.

python


player:1 | pos:32 | LOSS: 0.0000 | Q_MAX: 0.0041
player:2 | pos:15 | LOSS: 0.0000 | Q_MAX: 0.0009
…
layer:2 is only pos:56
player:2 | pos:56 | LOSS: 0.0000 | Q_MAX: 0.8607
EPOCH: 999/999 | WIN: player2 
winner is player2

test

It will take several hours to finish the study. Now let's test with the model we learned.

python


$ python FightWithAI.py

------------- GAME START ---------------
***user turn ○***
  0  1  2  3  4  5  6  7
  8  9 10 11 12 13 14 15
 16 17 18 19 20 21 22 23
 24 25 26 ○ ● 29 30 31
 32 33 34 ● ○ 37 38 39
 40 41 42 43 44 45 46 47
 48 49 50 51 52 53 54 55
 56 57 58 59 60 61 62 63
Please enter the number
[43, 34, 29, 20]

>>>

If the game starts as above, you are successful. Did it work properly? The result of the match will be written in ~ Iza Battle ~.

Next time will deliver the implementation version.

Recommended Posts

I tried to make Othello AI with tensorflow without understanding the theory of machine learning ~ Introduction ~
I tried to make Othello AI with tensorflow without understanding the theory of machine learning ~ Implementation ~
I tried to make Othello AI with tensorflow without understanding the theory of machine learning ~ Battle Edition ~
[Machine learning] I tried to summarize the theory of Adaboost
I tried to find the average of the sequence with TensorFlow
I tried to make something like a chatbot with the Seq2Seq model of TensorFlow
I tried to make Othello AI that I learned 7.2 million hands by deep learning with Chainer
I tried to visualize the model with the low-code machine learning library "PyCaret"
I tried to predict the presence or absence of snow by machine learning.
I tried to move machine learning (ObjectDetection) with TouchDesigner
I tried to compress the image using machine learning
I tried to understand the learning function of neural networks carefully without using a machine learning library (first half).
I tried to make a real-time sound source separation mock with Python machine learning
I tried to create a reinforcement learning environment for Othello with Open AI gym
I tried to find the entropy of the image with python
I tried to implement ListNet of rank learning with Chainer
I tried machine learning with liblinear
I tried to compare the accuracy of machine learning models using kaggle as a theme.
I tried to verify the yin and yang classification of Hololive members by machine learning
I tried to automate the watering of the planter with Raspberry Pi
I tried to understand it carefully while implementing the algorithm Adaboost in machine learning (+ I deepened my understanding of array calculation)
I tried to make deep learning scalable with Spark × Keras × Docker
[Introduction to StyleGAN] I played with "The Life of a Man" ♬
[Introduction to StyleGAN] Unique learning of anime with your own machine ♬
I tried to expand the size of the logical volume with LVM
I tried to improve the efficiency of daily work with Python
I tried to make a mechanism of exclusive control with Go
I tried to implement Autoencoder with TensorFlow
I tried to visualize AutoEncoder with TensorFlow
I tried calling the prediction API of the machine learning model from WordPress
[Introduction to machine learning] Until you run the sample code with chainer
I tried to get the authentication code of Qiita API with Python.
I tried to automatically extract the movements of PES players with software
(Machine learning) I tried to understand Bayesian linear regression carefully with implementation.
I tried to analyze the negativeness of Nono Morikubo. [Compare with Posipa]
A beginner of machine learning tried to predict Arima Kinen with python
I tried to streamline the standard role of new employees with Python
I tried to visualize the text of the novel "Weathering with You" with WordCloud
Memorandum of means when you want to make machine learning with 50 images
I tried to get the movie information of TMDb API with Python
I tried the common story of using Deep Learning to predict the Nikkei 225
I tried to predict the behavior of the new coronavirus with the SEIR model.
I refactored "I tried to make Othello AI when programming beginners studied python"
(Machine learning) I tried to understand the EM algorithm in a mixed Gaussian distribution carefully with implementation.
I tried to understand the learning function in the neural network carefully without using the machine learning library (second half).
I tried to make a thumbnail image of the best avoidance flag-chan! With RGB values ​​[Histogram] [Visualization]
I tried to predict next year with AI
[Python] Easy introduction to machine learning with python (SVM)
I tried to save the data with discord
I tried to touch the API of ebay
I tried to correct the keystone of the image
I tried to make AI for Smash Bros.
I tried to make a ○ ✕ game using TensorFlow
I tried to predict the price of ETF
I tried to vectorize the lyrics of Hinatazaka46!
I tried to organize the evaluation indexes used in machine learning (regression model)
I tried to make a simple mail sending application with tkinter of Python
[Patent analysis] I tried to make a patent map with Python without spending money
Machine learning beginners tried to make a horse racing prediction model with python
I tried to easily visualize the tweets of JAWS DAYS 2017 with Python + ELK
I tried running the TensorFlow tutorial with comments (text classification of movie reviews)