Syväoppiva tekoäly neljän suora -peliin
Kyllönen, Aki (2021)
Kyllönen, Aki
2021
All rights reserved. This publication is copyrighted. You may download, display and print it for Your own personal use. Commercial use is prohibited.
Julkaisun pysyvä osoite on
https://urn.fi/URN:NBN:fi:amk-2021110319224
https://urn.fi/URN:NBN:fi:amk-2021110319224
Tiivistelmä
Opinnäytetyön tavoitteena oli tutustua tekoälyn ja koneoppimisen käsitteisiin ja metodeihin sekä toteuttaa neljän suora -peli ja siihen syväoppiva tekoäly. Työ on toteutettu Kajaanin ammattikorkeakoulun päättötyönä. Opinnäytetyön lopputuloksena on tiivis ja toimiva teoriaosuus tekoälystä sekä käytännön osuutena Pythonilla toteutettu neljän suora -peli. Peli hyödyntää kolmea eri tekoälyn astetta, jotka ovat satunnaisesti pelaava tekoäly, voittoliikettä tavoitteleva ja vastustajan voittoliikettä estävä tekoäly sekä Keras-tekoälykirjastolla toteutettu ihmisen aivorakennetta mukaileva neuroverkkopohjainen tekoäly. Työssä tutustuttiin tekoälyn käsitteisiin käyttäen useita eri lähteitä internetistä. Työn aikana luotiin oma opetusdata syväoppivalle tekoälylle simuloimalla keskiasteen tekoälyllä 250 000 peliä. Lopputuloksena luotu tekoälymalli saavutti 80,1 voitto-% keskiasteen tekoälyä vastaan ja 88,1 voitto-% satunnaisesti pelaavaa tekoälyä vastaan 1 %:n virhemarginaalilla.
Tekoäly on jatkuvasti kasvava tietojenkäsittelytieteenala, jossa yhdistyvät matematiikka, data-analytiikka ja tilastotiede. Tekoälyn tavoitteena on tutkia ja toteuttaa älykkäitä kone- ja tietokonejärjestelmiä. Koneoppiminen on tekoälyn alaosio, joka voidaan jakaa ohjattuun ja ohjaamattomaan koneoppimiseen, vahvistusoppimiseen ja syväoppimiseen. Koneoppimisessa tekoälyjärjestelmää opetetaan suorittamaan komentoja annetun datan avulla ilman, että jokaista järjestelmän funktiota tarvitsee ohjelmoida erikseen. Koneoppimisen mallit ovat tekoälyjärjestelmän tapoja käsitellä dataa. Yleisimpiä koneoppimisen malleja ovat Naiivi Bayesin luokitin, päätöspuut, lähimmän naapurin luokitin, lineaari- ja logistinen regressio sekä neuroverkot. Käytettävät koneoppimismallit valitaan tekoälyjärjestelmään aina tapauskohtaisesti, eikä yksittäistä oikeaa ratkaisua ole olemassa.
Yleisimpiä koneoppimisen ohjelmointikieliä ovat Python, R, C/C#/C++, Java ja JavaScript, joista Python tuo merkittäviä etuja muihin kieliin verrattuna käytettävissä olevien laajojen koneoppimiskirjastojen, kuten TensorFlow’n, ansiosta. Koneoppimiskirjastot nopeuttavat tekoälyn toteuttamista. Tekoäly ei ole itsenäinen ratkaisu ongelmiin, vaan se tarvitsee myös käyttökelpoisen järjestelmän ympärilleen. Tekoälyjärjestelmän toteuttaminen voidaan tiivistää viiteen eri vaiheeseen: alkuperäisen ratkaistavan ongelman määritteleminen, datan valmisteleminen, koneoppimismallien valitseminen, koneoppimismallien opettaminen ja tekoälyjärjestelmän jatkokehittäminen. The objective of this Bachelor’s thesis was to familiarize the author with commonly used artificial intelligence and machine learning concepts, and to develop a connect 4 game with deep learning artificial intelligence system. The aim of the deep learning AI system was to beat hand-made algorithms with a high win percentage.
Artificial intelligence is a rapidly growing part of computer science industry. The aim of artificial intelligence field is to research and develop intelligent computer systems with the help of mathematics, data analytics, and statistics. One of the subfields of artificial intelligence is machine learning, which can be divided to supervised and unsupervised learning, reinforcement learning, and deep learning. Machine learning teaches an artificial intelligence system to function based on given data without the need to program the system functions. A machine learning model is an algorithm trained to make specific predictions. Some of the most used models are Naïve Bayes classifier, decision trees, the nearest neighbor classifier, linear and logistic regression, and neural networks. Models suitable for different AI systems can differ greatly, and one system can utilize a combination of different algorithms.
Commonly used machine learning languages are Python, R, C/C#/C++, Java, and JavaScript. Python has broad range of free to use and powerful machine learning libraries like TensorFlow and Keras, making it the most popular machine learning language. An artificial intelligence system is not an independent solution to a problem, but rather a part of a functioning software structure. The development of an AI system can be divided to five parts: defining the problem that needs to be solved, preparing the data, choosing the machine learning models, teaching the models, and further improving the AI system.
The resulting thesis is a compact and functional overview of artificial intelligence concepts, and a deep learning AI system made in practice. The developed connect 4 Python software utilized three AI difficulty levels, which are randomly playing AI, an AI pursuing winning moves and blocking opponent’s winning moves, and a deep learning neural network AI developed with Keras machine learning library. The learning data for neural network was generated by simulating 250 000 games with the medium level AI playing against itself. The taught model achieved 80,1 % win rate against the medium level AI and 88,1 % win rate against the randomly playing AI. Both results consisted of 10 000 simulated games with a calculated 1 % margin of error in win rates. The delimiting of the thesis plan was successful, and the aims of the thesis were met.
Tekoäly on jatkuvasti kasvava tietojenkäsittelytieteenala, jossa yhdistyvät matematiikka, data-analytiikka ja tilastotiede. Tekoälyn tavoitteena on tutkia ja toteuttaa älykkäitä kone- ja tietokonejärjestelmiä. Koneoppiminen on tekoälyn alaosio, joka voidaan jakaa ohjattuun ja ohjaamattomaan koneoppimiseen, vahvistusoppimiseen ja syväoppimiseen. Koneoppimisessa tekoälyjärjestelmää opetetaan suorittamaan komentoja annetun datan avulla ilman, että jokaista järjestelmän funktiota tarvitsee ohjelmoida erikseen. Koneoppimisen mallit ovat tekoälyjärjestelmän tapoja käsitellä dataa. Yleisimpiä koneoppimisen malleja ovat Naiivi Bayesin luokitin, päätöspuut, lähimmän naapurin luokitin, lineaari- ja logistinen regressio sekä neuroverkot. Käytettävät koneoppimismallit valitaan tekoälyjärjestelmään aina tapauskohtaisesti, eikä yksittäistä oikeaa ratkaisua ole olemassa.
Yleisimpiä koneoppimisen ohjelmointikieliä ovat Python, R, C/C#/C++, Java ja JavaScript, joista Python tuo merkittäviä etuja muihin kieliin verrattuna käytettävissä olevien laajojen koneoppimiskirjastojen, kuten TensorFlow’n, ansiosta. Koneoppimiskirjastot nopeuttavat tekoälyn toteuttamista. Tekoäly ei ole itsenäinen ratkaisu ongelmiin, vaan se tarvitsee myös käyttökelpoisen järjestelmän ympärilleen. Tekoälyjärjestelmän toteuttaminen voidaan tiivistää viiteen eri vaiheeseen: alkuperäisen ratkaistavan ongelman määritteleminen, datan valmisteleminen, koneoppimismallien valitseminen, koneoppimismallien opettaminen ja tekoälyjärjestelmän jatkokehittäminen.
Artificial intelligence is a rapidly growing part of computer science industry. The aim of artificial intelligence field is to research and develop intelligent computer systems with the help of mathematics, data analytics, and statistics. One of the subfields of artificial intelligence is machine learning, which can be divided to supervised and unsupervised learning, reinforcement learning, and deep learning. Machine learning teaches an artificial intelligence system to function based on given data without the need to program the system functions. A machine learning model is an algorithm trained to make specific predictions. Some of the most used models are Naïve Bayes classifier, decision trees, the nearest neighbor classifier, linear and logistic regression, and neural networks. Models suitable for different AI systems can differ greatly, and one system can utilize a combination of different algorithms.
Commonly used machine learning languages are Python, R, C/C#/C++, Java, and JavaScript. Python has broad range of free to use and powerful machine learning libraries like TensorFlow and Keras, making it the most popular machine learning language. An artificial intelligence system is not an independent solution to a problem, but rather a part of a functioning software structure. The development of an AI system can be divided to five parts: defining the problem that needs to be solved, preparing the data, choosing the machine learning models, teaching the models, and further improving the AI system.
The resulting thesis is a compact and functional overview of artificial intelligence concepts, and a deep learning AI system made in practice. The developed connect 4 Python software utilized three AI difficulty levels, which are randomly playing AI, an AI pursuing winning moves and blocking opponent’s winning moves, and a deep learning neural network AI developed with Keras machine learning library. The learning data for neural network was generated by simulating 250 000 games with the medium level AI playing against itself. The taught model achieved 80,1 % win rate against the medium level AI and 88,1 % win rate against the randomly playing AI. Both results consisted of 10 000 simulated games with a calculated 1 % margin of error in win rates. The delimiting of the thesis plan was successful, and the aims of the thesis were met.