AI, Darwin's evolution

Source: Internet
Author: User
Tags knowledge base
This is a big question. So it will be very long.
In addition, because my U disk is bitten by a dog, I have to re-write everything and it is expected to be updated every 2-3 days.

Start:
AI, Darwin's evolution and wuziqi

Directory

1.0 Preface

2.0 Model Introduction
2.1 Evolutionary Model
2.2 SMART models
2.20 Expert System
2.21 Neural Networks

3.0 Javascript implementation
3.1 some background information that is not very important
3.2 AI
Body

1.0 Preface
This article explores the possibility of using Darwin's evolution to produce artificial intelligence.
The goal is to use Javascript as a programming tool to generate an evolutionary AI that can be used to play the game.

2.0 Model Introduction

2.1 Evolutionary Model
Darwin's theory of evolution is, in a general sense, a "natural race ". Extended, it is "Competition" and "daily choice ".
The "physical competition" part requires that the species have the ability to inherit and mutate. Genetics can produce a relatively stable race, which is conducive to the continuation of beneficial genes. Variations can generate diverse races, facilitating competition and genetic evolution.
In the "Daily selection" part, it is required that species compete with each other to survive the fittest to find out unreasonable genes.
In summary, an AI that meets your needs should have the following features:
A) hereditary: the vast majority of features can be passed to the child.
B) variability: some variations are generated instead of full replication.
C) can be competitive: in this article, competition is to play 5 games with other AI players.

2.2 SMART models
2.20 Expert System
Google's explanation
Generally, chess and board AI cannot do without behavior rule judgment and intelligent libraries. According to the general logic, chess and AI will simulate human thinking, determine where the next move is, what will happen, and estimate several more steps accordingly. Generally, AI stores a board chart for quick calculation. This board chart is the knowledge base of AI.
The defects of this type of AI are: humans need to abstract the problems to be solved first to form a knowledge base-knowledge expression logic, which is very difficult to express completely, there will always be situations outside the knowledge base. Moreover, this model is obviously difficult to achieve continuous evolution. All it can do is to constantly complete the knowledge base, but the evolution of knowledge expression is very difficult to achieve.

2.21 Neural Networks
Google's explanation
If we think of an independent AI as a newborn baby, how can we teach it to learn? Babies do not have a knowledge base.
In fact, it is very simple. We can abstract the AI baby learning process into this: Give AI a stimulus (input), AI generates a feedback (output), we make a judgment, infants record the feedback judgment results to deepen or weaken the feedback mechanisms for such stimuli.
(I wrote too briefly... but this article does not focus on the popularization of basic knowledge... you can take a look and find google if you have any questions)

3.0 Javascript implementation

// --------- 2007.04.03 update segmentation --- Hutia ----------------//

3.1 some background information that is not very important
Code environment: Window XP sp2, IE 6.0
File Information: Gobang_ai.hta, ai.txt, sp/gobang_ai.css, sp/gobang_ai.js

Gobang_ai.hta content:

Copy content to clipboard

Code:

<title>Gobang Artificial Intelligency</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="sp/gobang_ai.css" />
<script type="text/javascript" src="sp/gobang_ai.js"></script>
<body></body>

Ai.txt is used to store AI

Sp/gobang_ai.css is the basic CSS and the content is omitted.

Sp/gobang_ai.js is the core of this article...

3.2 AI
(Because this article has not been completed, it does not necessarily show the final code. As the structure expands, the code will change)

Copy content to clipboard

Code:

Function AI (){
// Genetics
This. gene = new Array (mmm );
// Some information
This. count_played = 0;
This. count_win = 0;
This. generation = 0;
This. level = 0;
This. score = 10;

// Genetics & mutation
This. aberrance = AI_m_aberrance;
// Initialization
This. init = AI_m_init;

This. init ();
}

The code is actually very simple (and incomplete ). Set an array of genes used to store AI genes (the mmm variable is global and used to store the length of this gene ). All AI In this article has only one chromosome (an array), and the length of the gene is the same length.

The initialization code is simple:

Copy content to clipboard

Code:

Function AI_m_init (){
// Initialization
For (var I = 0; I <mmm; I ++) this. gene [I] = 0.5;
}

Ps: assigning the initial values of all gene bits to 0.5 is an empirical value, which will be mentioned later in gene expression.

Then there is the code for mutation and Reproduction:

Copy content to clipboard

Code:

Function AI_m_aberrance (){
// Genetics & mutation
Var mi, ni, n, aberranced_ai;

Aberranced_ai = new AI ();

// Genetic
For (var I = 0; I <mmm; I ++) aberranced_ai.gene [I] = this. gene [I];

Mi = parseInt (mmm * aberrance_ratio );
Ni = 5/mi;
N = aberranced_ai.gene.length;

// Mutation
For (var I = 0; I <mi; I ++ ){
If (Math. random () <ni) aberranced_ai.gene [parseInt (n * Math. random ()] * = (1 + (Math. random ()-0.5)/5 );
}

Return (aberranced_ai );
}

In this article, all AI resources are divided and reproduced. Although the introduction of sex will optimize the evolution of AI, it may be more appropriate for more complex AI. Today, this simple AI gene has only one expression direction (down to wuziqi) and one chromosome. If it is useful to exchange chromosomes, it is a bit of a High-gun to fight mosquitoes.

Aberrance_ratioIt is a global variable used to store the genetic variation rate of our world-the world with a high variation rate will evolve faster, but it is difficult to generate truly valuable AI at a high variation rate. (think about the real world. If nuclear radiation is everywhere, it may produce a variety of microorganisms, but it is difficult to generate a plant)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.