Jun 01, 2021 Article blog
This article was reproduced to Know ID: Charles (Bai Lu) knows his personal column
Download the W3Cschool Mobile App, 0 Foundation Anytime, Anywhere Learning Programming >> Poke this to learn
Happy New Year to all of you
T_T
Chinese New Year's Eve finally stole half a day idle to remember that some days are not more public number
So, let's have a more wave of articles hhhhhhh
Before it seems that the water several articles to Python can do for the main purpose, then water again a bar
The technical content of this article is still not high, it is AI entry-level content, idea comes from (T_T I also forgot).
Pure Python implementation, does not depend on any deep learning framework...
Come on, go straight to the right question!
Baidu web disk link:
https://pan.baidu.com/s/1UIV51eSD3ixqAuVqRC7z8g
Password: fmtv
(1)neuro-evolution
https://en.wikipedia.org/wiki/Neuroevolution
Game ideas:
Let our plane automatically avoid enemy aircraft flying from the top of the screen.
How to do it:
(1) the use of simple neural networks to determine the way the aircraft operates;
(2) Using the neuro-evolution algorithm to improve the performance of neural networks, the core of the algorithm is similar to Darwin's theory of evolution, randomly generated populations and then selected excellent individuals for hybrid variation to obtain new populations, so repeated cycle.
See the source code for details of ideas and implementations.
Python version: 3.5.4
Related modules:
win_unicode_console modules, pygame modules, and some Python-owned modules.
Environment construction
Install Python and add it to the environment variable, and pip installs the relevant modules that are required.
Use the demo
Run the main.py file in the cmd window:
If it doesn't work well, modify the parameters in the NeuroEvolution.py file yourself, as shown in the following image:
Of course, you can also modify the location of the enemy aircraft in
the main.py
file:
The aircraft will eventually move in a location where no enemy aircraft is generated:
Algorithms really really write very shabby and ugly...
So,
There is no actual use value...
Interested small partners can further optimize and expand this AI game, of course, also welcome backstage message exchanges...
Examples of optimized content are:
(1) optimize the way new genes are produced;
(2) The relevant parameters change with the evolutionary process, etc.