Skip to content

Commit 13e8717

Browse files
authored
Merge pull request #13 from SergySanJj/MainDev
Working version will label it ultra pre Alpha 0.01
2 parents 6a58067 + 0030a34 commit 13e8717

26 files changed

Lines changed: 384 additions & 358 deletions

File tree

NeuralNetwork/NeuralNetwork/LifeGame.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,16 @@ char LifeGame::getXY(int X, int Y)
271271
return (this->_field->getXY(X, Y));
272272
}
273273

274+
vector<int> LifeGame::getResult()
275+
{
276+
vector<int> res(this->deadPlayers.size());
277+
for (auto it = this->deadPlayers.begin(); it != this->deadPlayers.end(); ++it)
278+
{
279+
res[(*it)->_player->getID()] = (*it)->lastStep;
280+
}
281+
return res;
282+
}
283+
274284
bool LifeGame::checkMove(int new_x, int new_y)
275285
{
276286
if (new_x > 0 && new_y > 0)

NeuralNetwork/NeuralNetwork/LifeGame.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class LifeGame
8686
void initializeAllWithRnd(float a, float b);
8787
void echo(bool value); // 1 - print 0 - don't print
8888
char getXY(int X, int Y);
89+
vector<int> getResult();
8990
bool checkMove(int new_x, int new_y);
9091

9192
void step();

NeuralNetwork/NeuralNetwork/NeuralNetwork.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,13 @@ NeuralNetwork::~NeuralNetwork()
5252
}
5353
}
5454

55-
float * NeuralNetwork::getData(const string & ID)
55+
vector<float> NeuralNetwork::getData(const string & ID)
5656
{
5757
Layer* layer = this->layers.find(ID)->second;
5858
int n = (*layer).getSize();
5959

60-
if (n == 0)
61-
return nullptr;
62-
63-
float* mas = new float[n];
60+
vector<float> mas(n);
61+
//float* mas = new float[n];
6462

6563
for (int i = 0; i < n; i++)
6664
{

NeuralNetwork/NeuralNetwork/NeuralNetwork.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class NeuralNetwork
6767
bool setLayerWeights(const string& ID, float value);
6868
bool setActivationFunction(const string& ID, float(*f)(float));
6969

70-
float* getData(const string& ID);
70+
vector<float> getData(const string& ID);
7171

7272
Layer* getLayer(const string& ID);
7373

NeuralNetwork/NeuralNetwork/Player.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
float partFunction(float x)
66
{
7-
if (x <= -0.25f)
7+
if (x <= -0.5f)
88
return -1.0f;
9-
if (x >= 0.25f)
9+
if (x >= 0.5f)
1010
return 1.0f;
1111
else
1212
return 0.0f;
@@ -212,9 +212,9 @@ void Player::activateNeuro(float * input)
212212

213213
this->neuro->activateLayer("sigmoid");
214214

215-
this->neuro->activatonFunction("output");
215+
//this->neuro->activatonFunction("output");
216216

217-
float* output = (this->neuro->getData("output")); // output size = 2
217+
vector<float> output = this->neuro->getData("sigmoid"); // output size = 2
218218

219219
int tmp_x = paramToInt(output[0]) + this->pos_x;
220220
int tmp_y = paramToInt(output[1]) + this->pos_y;
@@ -225,7 +225,6 @@ void Player::activateNeuro(float * input)
225225
this->pos_y = tmp_y;
226226
}
227227

228-
delete[] output;
229228
}
230229

231230
void Player::mutate(float a, float b)
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
-0.72557657957 -0.40614634752
2-
-0.36994007230 -0.77179467678
3-
0.54482358694 0.66125631332
4-
-1.18516445160 0.60362786055
5-
0.19229166210 -0.28935742378
6-
-1.75342512131 -0.07786682248
7-
-0.58532649279 -1.16547143459
8-
0.97608643770 -0.67785531282
9-
0.63559800386 -0.60164779425
10-
-0.32269579172 -0.71746587753
11-
-0.97859632969 -0.15166762471
12-
0.02242569253 -1.99261903763
13-
-0.78190171719 0.46248430014
14-
0.49818855524 0.67419129610
15-
-1.38197875023 0.24851255119
16-
0.10724135488 0.79875230789
17-
0.50927275419 -1.73625540733
18-
0.50397294760 0.82367759943
19-
-1.91731619835 0.07602580637
20-
0.89469015598 -1.65551042557
21-
-1.14460301399 -1.91602575779
22-
0.62713122368 -1.20222771168
23-
0.84740078449 -1.15262115002
24-
-0.76024019718 -0.38859438896
25-
-0.08274416625 -0.73493307829
26-
0.30916801095 0.60584396124
27-
-0.97917473316 -0.99655014277
28-
0.58235430717 -0.51539474726
1+
-0.55282199383 -1.48869013786
2+
-1.33806550503 0.82382029295
3+
-0.93287909031 -0.79204231501
4+
-0.79855328798 -0.99974471331
5+
-0.12330394983 -1.77908039093
6+
0.45447856188 -1.57397055626
7+
0.23765815794 -0.69727629423
8+
0.45790418983 -0.85875916481
9+
-1.75754427910 -0.60978728533
10+
-1.00911426544 -0.57517397404
11+
-1.31637191772 -1.87753391266
12+
0.22551876307 0.56240743399
13+
-0.47627705336 -1.86317455769
14+
-1.08057796955 -0.10497000068
15+
-1.25448429585 -1.96512079239
16+
-1.51364541054 -1.83087491989
17+
-1.90684139729 -0.65523403883
18+
-0.70537197590 -1.52377331257
19+
-1.29761123657 -0.79503589869
20+
0.26874101162 -1.60347783566
21+
-1.66487693787 -0.59635877609
22+
0.87664616108 -0.94734191895
23+
-1.90675556660 -0.53596884012
24+
-0.45646676421 0.51447242498
25+
-0.05934403092 -1.40204560757
26+
0.31129336357 -1.58941233158
27+
0.70505338907 0.71017605066
28+
-0.13439214230 -1.93271124363
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
-0.36973053217 0.59947794676 -0.86793744564 0.58711421490 0.34405353665 -0.59677964449 0.23377805948 0.63076764345 -0.46215364337 0.64657652378 -0.78857016563 0.68019890785 -0.68718338013 0.84952348471 0.91254925728 -0.58837294579 0.07401360571 -0.99978798628 -0.27824229002 -0.03501671553 -0.06565977633 -0.75092375278 0.42006489635 -0.19380262494 -0.67729419470 -0.48383027315 0.53636884689 -0.02129899152
2-
-0.38158595562 0.64221733809 0.73140627146 -0.89090090990 -0.19622737169 0.92640286684 0.94302469492 -0.58939993382 0.83151811361 0.18626318872 0.78558588028 -0.61475694180 0.96997630596 0.62224692106 -0.91112124920 0.59692269564 -0.70123046637 0.30491036177 0.25174102187 0.20664876699 0.68286305666 -0.08615478128 0.80601316690 -0.54013293982 0.98236566782 0.62613892555 0.87440675497 -0.75444698334
3-
0.15783229470 0.46279016137 -0.55345791578 -0.23921290040 -0.11647964269 -0.59725099802 0.52365428209 0.50187969208 0.31353425980 0.94694560766 -0.64770060778 0.89565402269 -0.80774110556 0.35525262356 -0.69884228706 -0.11344311386 -0.56604969501 -0.82142806053 0.44858062267 -0.70860803127 0.58448469639 -0.26654914021 0.77053117752 -0.39888793230 0.26253929734 0.01810504496 -0.25985768437 0.79144543409
4-
-0.02025397494 -0.12750647962 0.17374344170 0.09104421735 -0.14548155665 0.13206493855 -0.01872201636 -0.15412047505 0.13743197918 0.01311114896 -0.16439943016 -0.08945652843 0.05281800777 -0.01736357622 0.07308960706 -0.18953117728 0.15039911866 0.08961533755 0.02733595483 -0.06643521786 0.00362970331 0.17473039031 0.14773546159 -0.08584979922 -0.02391219512 -0.00221586111 -0.17483648658 0.14668773115
5-
-0.03982288763 0.07808629423 -0.01766825467 -0.06336390972 0.04941292852 -0.14169839025 0.18534943461 0.15650586784 0.17476214468 -0.07998546958 -0.12498512864 0.16632147133 -0.07429192215 0.19985730946 0.16884917021 0.01551082637 -0.11661223322 0.00596169150 -0.19680880010 -0.15757358074 0.09318022430 0.09697260708 0.13913060725 0.08429864049 -0.07476017624 -0.14715807140 -0.07911434025 -0.09981153905
6-
-0.73140108585 -0.18128134310 -0.24050323665 0.60270053148 -0.67094528675 0.61664646864 -0.30583459139 0.59350514412 -0.58802527189 0.80383610725 -0.69534903765 0.81384938955 0.76442700624 0.45988741517 0.67517226934 0.85727781057 0.84357953072 -0.91476011276 -0.54776138067 -0.68183416128 0.86500459909 0.57652527094 0.19584746659 -0.37079766393 0.68227463961 -0.81707042456 0.44720923901 0.33439898491
1+
-0.15187828243 0.09229380637 -0.00257935189 -0.13449221849 -0.02118024603 0.10919152200 0.00417439314 0.05270624906 -0.11781196296 0.13849808276 0.08128109574 0.11358596385 0.12022089958 -0.09942422807 -0.00857584458 -0.01881923154 -0.07830753922 -0.07282365113 0.07364641875 0.04961930215 -0.06395774335 0.07867963612 -0.15074716508 0.07392071933 -0.06739383191 -0.11685746163 0.01265097409 -0.14716385305
2+
-0.07418517023 -0.03729342669 -0.19300910830 -0.06686466187 0.13288897276 -0.04228108376 -0.05625942722 0.01486224774 -0.06194628775 0.18658722937 0.01157756895 -0.08990583569 -0.15549661219 0.18971662223 0.10646916926 -0.16192892194 -0.18323212862 -0.00511173811 0.00803370774 -0.18284311891 -0.15642628074 -0.04170976579 0.05066880211 0.03760647029 -0.06403997540 -0.17397107184 0.19678744674 0.00508671813
3+
0.18438491225 -0.05940401182 0.19384798408 -0.16870231926 0.10068305582 0.17678380013 0.11537411064 0.00294313300 -0.14333179593 0.13307307661 0.02632713504 0.06687033921 0.16555689275 -0.04158123583 -0.01195319742 -0.07008554041 0.08135925233 -0.11772824079 -0.01561072469 0.03522622958 0.02718740702 0.06009895727 0.04958850890 0.02575608715 -0.19268545508 -0.05885015801 -0.08872704208 -0.09153474867
4+
-0.11188304424 0.18971151114 0.15596373379 0.06184137613 -0.09218712896 0.15880951285 0.13389416039 -0.14347277582 -0.06900326908 0.13253481686 0.14859828353 0.10270562023 -0.10133572668 0.09426362813 -0.08059603721 -0.08624926209 0.05372596532 -0.14232073724 -0.01586335897 -0.07251894474 0.05971630663 -0.16448253393 -0.02727313526 0.11382339150 0.07747456431 0.09837758541 0.10600065440 -0.15742579103
5+
-0.05408127233 0.06513681263 -0.11222590506 -0.04227430746 -0.05324415863 -0.14341424406 0.01756284386 -0.19199293852 0.01202782150 -0.19216321409 0.02764029801 -0.16590695083 0.18195784092 -0.04220211878 0.11414195597 0.10763295740 -0.15654619038 0.12332488596 -0.08840542287 -0.13014636934 0.18493619561 -0.03742296249 -0.18746300042 -0.03933567181 0.13539664447 -0.11380755901 -0.00863376167 -0.10237548500
6+
-0.15741553903 -0.10168852657 0.17228828371 0.07863883674 -0.06329447031 -0.16302466393 -0.00260299793 0.01537345350 0.05586158857 0.12757800519 0.01527035888 -0.18293571472 -0.14052282274 -0.06633287668 -0.09465920925 -0.13552451134 -0.08361063898 -0.17002743483 0.00850624777 0.12935590744 -0.07867908478 0.04793708026 -0.08200079203 0.03623574972 -0.14051364362 0.04288348556 0.12579677999 0.14207379520
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
0.84850394726 0.54447954893
2-
0.18077912927 -0.46775090694
3-
0.18750473857 0.24129742384
4-
-1.18516445160 0.60362786055
5-
0.19229166210 -0.28935742378
6-
0.81479763985 -0.13418117166
7-
-0.49571675062 -1.11198866367
8-
0.35243910551 0.44407421350
9-
-1.10759198666 0.13096280396
10-
-0.68522387743 -1.59267818928
11-
-0.97859632969 -0.15166762471
12-
-0.04674031213 -0.06437162310
13-
-0.78190171719 0.46248430014
14-
0.49818855524 0.67419129610
15-
-1.38197875023 0.24851255119
16-
-1.91425549984 -1.94214677811
17-
0.00466748513 -0.07990094274
18-
0.82022666931 -0.80422240496
19-
0.78273588419 -0.37542298436
20-
-0.41129338741 -0.92066723108
21-
-1.14460301399 -1.91602575779
22-
-1.68509554863 -1.53499996662
23-
-0.82508271933 0.90257191658
24-
0.29412892461 -0.45091140270
25-
-0.08274416625 -0.73493307829
26-
0.30916801095 0.60584396124
27-
-0.79933214188 -0.92620187998
28-
-0.67604005337 -0.86511319876
1+
-0.55282199383 -1.48869013786
2+
-1.33806550503 0.82382029295
3+
-0.93287909031 -0.79204231501
4+
-0.79855328798 -0.99974471331
5+
-0.12330394983 -1.77908039093
6+
-0.18734696507 -0.68596726656
7+
0.79529213905 0.11040164530
8+
-1.05346035957 -1.82430791855
9+
-1.43282771111 -1.37845826149
10+
-1.00911426544 -0.57517397404
11+
-1.31637191772 -1.87753391266
12+
0.22551876307 0.56240743399
13+
-0.11033470929 0.58037948608
14+
0.72517007589 -0.06812343001
15+
-1.25448429585 -1.96512079239
16+
-1.51364541054 -1.83087491989
17+
-1.90684139729 -0.65523403883
18+
-0.70537197590 -1.52377331257
19+
-1.29761123657 -0.79503589869
20+
0.26874101162 -1.60347783566
21+
0.90732210875 0.83232426643
22+
-1.75887799263 -1.36176300049
23+
-1.90675556660 -0.53596884012
24+
-0.45646676421 0.51447242498
25+
-0.06104682386 0.67738342285
26+
0.31129336357 -1.58941233158
27+
-1.12890195847 0.37683039904
28+
-0.13439214230 -1.93271124363
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
-0.36973053217 0.59947794676 -0.86793744564 0.58711421490 0.34405353665 -0.59677964449 0.23377805948 0.63076764345 -0.46215364337 0.64657652378 -0.78857016563 0.68019890785 -0.68718338013 0.84952348471 0.91254925728 -0.58837294579 0.07401360571 -0.99978798628 -0.27824229002 -0.03501671553 -0.06565977633 -0.75092375278 0.42006489635 -0.19380262494 -0.67729419470 -0.48383027315 0.53636884689 -0.02129899152
2-
-0.79299306870 -0.23062452674 -0.25029277802 0.56816661358 -0.93247961998 0.09776661545 0.89846479893 0.81578874588 -0.43782067299 -0.08472426981 0.87201523781 0.10938736051 0.78513801098 -0.80813735723 -0.45005890727 -0.86553174257 0.14640317857 -0.34216964245 -0.19704891741 0.92956548929 0.92524790764 -0.22041150928 -0.14710965753 -0.12993064523 -0.58742105961 -0.55798602104 -0.53959494829 0.74785876274
3-
0.15783229470 0.46279016137 -0.55345791578 -0.23921290040 -0.11647964269 -0.59725099802 0.52365428209 0.50187969208 0.31353425980 0.94694560766 -0.64770060778 0.89565402269 -0.80774110556 0.35525262356 -0.69884228706 -0.11344311386 -0.56604969501 -0.82142806053 0.44858062267 -0.70860803127 0.58448469639 -0.26654914021 0.77053117752 -0.39888793230 0.26253929734 0.01810504496 -0.25985768437 0.79144543409
4-
0.06873693317 -0.16427475214 0.01422033273 -0.13086344302 -0.11683374643 -0.18078704178 0.05475123599 -0.08494130522 -0.03724271059 -0.13001354039 0.11961603165 -0.09708122909 -0.08131416142 0.19562697411 0.06451602280 -0.04556246847 -0.16742092371 0.10050830245 -0.07844925672 0.09351625293 -0.01620135643 0.19954691827 -0.02670445293 0.17666064203 -0.01316694170 0.03706429526 0.05100888014 0.18185466528
5-
0.99642014503 -0.42868033051 -0.60571175814 0.32690957189 -0.27604436874 0.10390478373 0.13244803250 -0.92646670341 0.74865078926 -0.57555991411 0.85003930330 0.84483242035 -0.38034352660 0.58821880817 0.67331546545 -0.91658467054 0.28238132596 0.35177034140 0.12143133581 -0.80319356918 -0.04914867878 0.14775536954 0.04584767669 0.76029461622 -0.23614701629 -0.64379960299 0.13913436234 -0.89029252529
6-
-0.73140108585 -0.18128134310 -0.24050323665 0.60270053148 -0.67094528675 0.61664646864 -0.30583459139 0.59350514412 -0.58802527189 0.80383610725 -0.69534903765 0.81384938955 0.76442700624 0.45988741517 0.67517226934 0.85727781057 0.84357953072 -0.91476011276 -0.54776138067 -0.68183416128 0.86500459909 0.57652527094 0.19584746659 -0.37079766393 0.68227463961 -0.81707042456 0.44720923901 0.33439898491
1+
-0.15187828243 0.09229380637 -0.00257935189 -0.13449221849 -0.02118024603 0.10919152200 0.00417439314 0.05270624906 -0.11781196296 0.13849808276 0.08128109574 0.11358596385 0.12022089958 -0.09942422807 -0.00857584458 -0.01881923154 -0.07830753922 -0.07282365113 0.07364641875 0.04961930215 -0.06395774335 0.07867963612 -0.15074716508 0.07392071933 -0.06739383191 -0.11685746163 0.01265097409 -0.14716385305
2+
0.18453267217 0.10176143050 0.16431467235 0.10324993730 -0.00682878308 0.15209646523 -0.11679937690 0.02747481503 -0.03207992390 -0.04954764247 0.02638608404 0.01743670925 0.06517786533 -0.15782059729 -0.18951313198 0.08201754838 -0.08132551610 0.13429300487 -0.16745649278 0.06896813214 0.19374312460 -0.16368842125 -0.07738216966 0.00530706486 -0.03693070263 0.02025382593 0.00156172831 0.16746686399
3+
0.17613610625 0.06654926389 0.13375245035 -0.13708268106 -0.18471701443 0.18273679912 -0.11920930445 0.10100778937 0.09906219691 0.19952309132 0.14628712833 0.09852022678 -0.12513446808 -0.17172311246 0.09733323753 0.01941599324 0.05040989071 -0.02040884085 0.18628785014 0.17790514231 -0.19088746607 -0.08932547271 -0.02548219450 -0.11074806005 -0.09413211793 -0.11280904710 -0.12237159163 -0.13375355303
4+
0.16856546700 0.18327009678 -0.08965478837 0.15536621213 -0.01395557355 0.11332013458 0.02999859862 -0.01680222154 0.05065923557 -0.12016289681 0.15380419791 0.00240294170 0.13946889341 0.14001318812 0.11994133890 0.18516933918 0.04559151083 0.08047540486 0.04173139483 -0.08143686503 0.14721435308 -0.14047375321 -0.01828250475 -0.13068959117 -0.03507445753 -0.08487580717 -0.02712112665 -0.11203888059
5+
0.12314139307 -0.02478526160 -0.01188601367 0.09549932927 0.02285283990 0.16054052114 0.04773806781 -0.02943749540 -0.04761998728 -0.13705217838 -0.07649653405 -0.14529609680 0.19630056620 0.04843864962 -0.06609395891 0.18291296065 0.12117855251 0.06518803537 0.17188990116 0.03572027013 0.00769444183 -0.08869940788 0.07314161956 0.02002328262 0.04405522719 -0.05955605954 0.16450323164 -0.04595652595
6+
-0.15741553903 -0.10168852657 0.17228828371 0.07863883674 -0.06329447031 -0.16302466393 -0.00260299793 0.01537345350 0.05586158857 0.12757800519 0.01527035888 -0.18293571472 -0.14052282274 -0.06633287668 -0.09465920925 -0.13552451134 -0.08361063898 -0.17002743483 0.00850624777 0.12935590744 -0.07867908478 0.04793708026 -0.08200079203 0.03623574972 -0.14051364362 0.04288348556 0.12579677999 0.14207379520
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
-0.72557657957 -0.40614634752
2-
-0.36994007230 -0.77179467678
3-
0.54482358694 0.66125631332
4-
-1.18516445160 0.60362786055
5-
0.19229166210 -0.28935742378
6-
0.81479763985 -0.13418117166
7-
-0.49571675062 -1.11198866367
8-
0.35243910551 0.44407421350
9-
-1.10759198666 0.13096280396
10-
-0.32269579172 -0.71746587753
11-
-0.97859632969 -0.15166762471
12-
-0.04674031213 -0.06437162310
13-
-0.78190171719 0.46248430014
14-
0.49818855524 0.67419129610
15-
-1.38197875023 0.24851255119
16-
-1.91425549984 -1.94214677811
17-
0.50927275419 -1.73625540733
18-
0.50397294760 0.82367759943
19-
0.78273588419 -0.37542298436
20-
-0.41129338741 -0.92066723108
21-
-1.14460301399 -1.91602575779
22-
0.21300297976 -1.81829798222
23-
-1.11847698689 -0.68426817656
24-
0.29412892461 -0.45091140270
25-
-0.08274416625 -0.73493307829
26-
0.30916801095 0.60584396124
27-
-0.79933214188 -0.92620187998
28-
-0.67604005337 -0.86511319876
1+
0.10471227765 -0.99183839560
2+
0.04748635367 -0.98766791821
3+
0.83867520094 -1.22834658623
4+
0.42154788971 -0.92872446775
5+
-1.11650478840 -1.72806942463
6+
-0.18734696507 -0.68596726656
7+
0.98674309254 -1.43744444847
8+
-1.05346035957 -1.82430791855
9+
-1.43282771111 -1.37845826149
10+
-0.99770987034 0.49665865302
11+
-0.94316536188 -0.44816532731
12+
-0.65998065472 -1.91676521301
13+
-1.46612870693 -0.81314557791
14+
-0.40269783139 -1.56849920750
15+
-1.57373428345 -1.69930315018
16+
-1.63856422901 -1.59266173840
17+
-0.71024322510 0.89822936058
18+
-1.81898069382 -0.76668244600
19+
0.14721588790 -1.70641863346
20+
0.33364710212 -0.79052972794
21+
0.90732210875 0.83232426643
22+
-0.37773668766 0.18230673671
23+
-0.20985427499 -0.88042598963
24+
-0.63976234198 -0.55460107327
25+
-1.26887774467 0.44946801662
26+
0.17659169436 -0.55301088095
27+
0.62445342541 -0.81522792578
28+
-0.54445606470 -1.65574288368

0 commit comments

Comments
 (0)