Prześlij pliki do ''
This commit is contained in:
parent
5978098747
commit
2fdd4767d0
718
Main.cpp
718
Main.cpp
@ -1,4 +1,4 @@
|
|||||||
//Main drzewa decyzyjne 1 + algorytm genetyczny
|
//Main drzewa decyzyjne 1 + algorytm genetyczny
|
||||||
|
|
||||||
#include<iostream>
|
#include<iostream>
|
||||||
#include<stdlib.h>
|
#include<stdlib.h>
|
||||||
@ -13,13 +13,14 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
//#include<bits/stdc++.h>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
//#include<bits/stdc++.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const float maxFloat=FLT_MAX;
|
const float maxFloat = FLT_MAX;
|
||||||
const int ROW = 27;
|
const int ROW = 27;
|
||||||
const int COL = 27;
|
const int COL = 27;
|
||||||
typedef pair<int, int> Pair;
|
typedef pair<int, int> Pair;
|
||||||
@ -34,15 +35,90 @@ char pole[27][27][6];
|
|||||||
int pozycjaTraktoraX = 1, pozycjaTraktoraY = 1;
|
int pozycjaTraktoraX = 1, pozycjaTraktoraY = 1;
|
||||||
char currentWay = 'S';
|
char currentWay = 'S';
|
||||||
|
|
||||||
|
//========================================================
|
||||||
|
|
||||||
|
//drzewo decyzyjne
|
||||||
|
|
||||||
|
int stan[27][27][2];
|
||||||
|
string polecenie;
|
||||||
|
int decyzja = NULL;
|
||||||
|
|
||||||
|
// Do dodania wywołanie odpowiednich funkcji - zbieranie - nawożenie -
|
||||||
|
void akcja() {
|
||||||
|
if (decyzja == 0) {
|
||||||
|
//nic nie rób
|
||||||
|
}
|
||||||
|
else if (decyzja == 1) {
|
||||||
|
//Zastosuj nawoz
|
||||||
|
}
|
||||||
|
else if (decyzja == 2) {
|
||||||
|
//Zastosuj srodek
|
||||||
|
}
|
||||||
|
else if (decyzja == 4) {
|
||||||
|
//Zbierz rośline i licznik++
|
||||||
|
}
|
||||||
|
else if (decyzja == 5) {
|
||||||
|
//Zbierz rośline ale nie dodawaj do licznika
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void decisionTree(string polecenie) {
|
||||||
|
|
||||||
|
std::string str = polecenie;
|
||||||
|
const char* c = str.c_str();
|
||||||
|
system(c);
|
||||||
|
|
||||||
|
int line = 0;
|
||||||
|
ifstream inFile;
|
||||||
|
inFile.open("pliki/dec.txt");
|
||||||
|
if (!inFile) {
|
||||||
|
cout << "Unable to open file";
|
||||||
|
exit(1); // terminate with error
|
||||||
|
}
|
||||||
|
|
||||||
|
while (inFile >> line) {
|
||||||
|
decyzja = line;
|
||||||
|
}
|
||||||
|
|
||||||
|
inFile.close();
|
||||||
|
akcja();
|
||||||
|
}
|
||||||
|
|
||||||
|
void stanPola(int x, int y) {
|
||||||
|
//[x][x][0] = 0 - brak chemii
|
||||||
|
//[x][x][0] = 1 - tylko nawóz
|
||||||
|
//[x][x][0] = 2 - tylko środek
|
||||||
|
//[x][x][0] = 3 - środek i nawóz
|
||||||
|
//[x][x][1] - wartość wzrostu rośliny
|
||||||
|
|
||||||
|
polecenie = "python pliki/injectCode.py 1 ";
|
||||||
|
|
||||||
|
if (stan[x][y][0] == 0)
|
||||||
|
polecenie.append("0 0 ");
|
||||||
|
if (stan[x][y][0] == 1)
|
||||||
|
polecenie.append("1 0 ");
|
||||||
|
if (stan[x][y][0] == 2)
|
||||||
|
polecenie.append("0 1 ");
|
||||||
|
if (stan[x][y][0] == 3)
|
||||||
|
polecenie.append("1 1 ");
|
||||||
|
int w = (stan[x][y][1]);
|
||||||
|
std::string s = std::to_string(w);
|
||||||
|
polecenie.append(s);
|
||||||
|
|
||||||
|
decisionTree(polecenie);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================
|
||||||
|
|
||||||
//algorytm genetyczny
|
//algorytm genetyczny
|
||||||
int scoreBuraki = 0;
|
int scoreBuraki = 0;
|
||||||
int scoreZiemniaki = 0;
|
int scoreZiemniaki = 0;
|
||||||
int rozmiarPopulacji = 500;
|
int rozmiarPopulacji = 500;
|
||||||
string * zebraneBuraki = new string[rozmiarPopulacji];
|
string* zebraneBuraki = new string[rozmiarPopulacji];
|
||||||
string * zebraneZiemniaki = new string[rozmiarPopulacji];
|
string* zebraneZiemniaki = new string[rozmiarPopulacji];
|
||||||
string * burakiDoSadzenia = new string[20];
|
string* burakiDoSadzenia = new string[20];
|
||||||
string * ziemniakiDoSadzenia = new string[20];
|
string* ziemniakiDoSadzenia = new string[20];
|
||||||
int gmoLeftBuraki;
|
int gmoLeftBuraki;
|
||||||
int gmoLeftZiemniaki;
|
int gmoLeftZiemniaki;
|
||||||
string kod_genetyczny[27][27];
|
string kod_genetyczny[27][27];
|
||||||
@ -65,7 +141,6 @@ string generateValue() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string generateVegetable() {
|
string generateVegetable() {
|
||||||
|
|
||||||
string taste = generateValue();
|
string taste = generateValue();
|
||||||
@ -76,117 +151,109 @@ string generateVegetable() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void generatePopulation(string* population, int length) {
|
||||||
void generatePopulation(string * population,int length) {
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<length;i++) {
|
for (i = 0;i < length;i++) {
|
||||||
population[i] = generateVegetable();
|
population[i] = generateVegetable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int power(int x, int y) {
|
int power(int x, int y) {
|
||||||
|
|
||||||
if (y == 0) return 1;
|
if (y == 0) return 1;
|
||||||
if (y == 1) return x;
|
if (y == 1) return x;
|
||||||
|
|
||||||
int temp = power(x, y/2);
|
int temp = power(x, y / 2);
|
||||||
if (y%2 == 0) return temp * temp;
|
if (y % 2 == 0) return temp * temp;
|
||||||
else return x * temp * temp;
|
else return x * temp * temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int stringToInt(string str, int size) {
|
||||||
int stringToInt(string str,int size) {
|
|
||||||
|
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int i;
|
int i;
|
||||||
reverse(str.begin(),str.end());
|
reverse(str.begin(), str.end());
|
||||||
|
|
||||||
for(i=0;i<size;i++) {
|
for (i = 0;i < size;i++) {
|
||||||
x += (str[i] - '0') * power(10,i);
|
x += (str[i] - '0') * power(10, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
reverse(str.begin(),str.end());
|
reverse(str.begin(), str.end());
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int fitness(string vegetable) {
|
int fitness(string vegetable) {
|
||||||
|
|
||||||
int taste = stringToInt(vegetable.substr(0,3),3);
|
int taste = stringToInt(vegetable.substr(0, 3), 3);
|
||||||
int colour = stringToInt(vegetable.substr(3,3),3);
|
int colour = stringToInt(vegetable.substr(3, 3), 3);
|
||||||
int size = stringToInt(vegetable.substr(6,3),3);
|
int size = stringToInt(vegetable.substr(6, 3), 3);
|
||||||
|
|
||||||
return (taste+colour+size)/3;
|
return (taste + colour + size) / 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool comparePair(const pair<int, string>& i, const pair<int, string>& j)
|
||||||
bool comparePair(const pair<int, string>&i, const pair<int, string>&j)
|
|
||||||
{
|
{
|
||||||
return i.first > j.first;
|
return i.first > j.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ranking(string* population, string* parents, int populationSize, int parentsNumber) {
|
||||||
void ranking(string * population,string * parents, int populationSize, int parentsNumber) {
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
pair <int,string> *fitnessTable=new pair <int, string>[populationSize];
|
pair <int, string>* fitnessTable = new pair <int, string>[populationSize];
|
||||||
for(i=0;i<populationSize;i++) {
|
for (i = 0;i < populationSize;i++) {
|
||||||
fitnessTable[i] = make_pair(fitness(population[i]),population[i]);
|
fitnessTable[i] = make_pair(fitness(population[i]), population[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
sort(fitnessTable,fitnessTable+populationSize,comparePair);
|
sort(fitnessTable, fitnessTable + populationSize, comparePair);
|
||||||
|
|
||||||
for(i=0;i<parentsNumber;i++) {
|
for (i = 0;i < parentsNumber;i++) {
|
||||||
parents[i] = fitnessTable[i].second;
|
parents[i] = fitnessTable[i].second;
|
||||||
}
|
}
|
||||||
delete[] fitnessTable;
|
delete[] fitnessTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool exists(int len, int* array, int element) {
|
||||||
bool exists(int len, int * array, int element) {
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<len;i++) {
|
for (i = 0;i < len;i++) {
|
||||||
if (array[i] == element) return true;
|
if (array[i] == element) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void selection(string* population, string* parents, int populationSize, int parentsNumber) {
|
||||||
|
|
||||||
void selection(string * population,string * parents, int populationSize, int parentsNumber) {
|
int i, j, k;
|
||||||
|
pair <int, string>* fitnessTable = new pair <int, string>[populationSize];
|
||||||
int i,j,k;
|
for (i = 0;i < populationSize;i++) {
|
||||||
pair <int,string> *fitnessTable= new pair <int, string>[populationSize];
|
fitnessTable[i] = make_pair(fitness(population[i]), population[i]);
|
||||||
for(i=0;i<populationSize;i++) {
|
|
||||||
fitnessTable[i] = make_pair(fitness(population[i]),population[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sort(fitnessTable,fitnessTable+populationSize,comparePair);
|
sort(fitnessTable, fitnessTable + populationSize, comparePair);
|
||||||
|
|
||||||
int roulette;
|
int roulette;
|
||||||
int *taken=new int[parentsNumber];
|
int* taken = new int[parentsNumber];
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for(i=0;i<parentsNumber;i++) {
|
for (i = 0;i < parentsNumber;i++) {
|
||||||
for(j = populationSize - 1;j>=0;j--) {
|
for (j = populationSize - 1;j >= 0;j--) {
|
||||||
if(not exists(parentsNumber,taken,j)) {
|
if (not exists(parentsNumber, taken, j)) {
|
||||||
sum += fitnessTable[j].first;
|
sum += fitnessTable[j].first;
|
||||||
fitnessTable[j].first = sum;
|
fitnessTable[j].first = sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
roulette = rand() % fitnessTable[0].first;
|
roulette = rand() % fitnessTable[0].first;
|
||||||
j = 0;
|
j = 0;
|
||||||
while(exists(parentsNumber,taken,j)) {
|
while (exists(parentsNumber, taken, j)) {
|
||||||
j += 1;
|
j += 1;
|
||||||
}
|
}
|
||||||
while(roulette > fitnessTable[j].first and j<populationSize) {
|
while (roulette > fitnessTable[j].first && j < populationSize) {
|
||||||
if(not exists(parentsNumber,taken,j)) {
|
if (not exists(parentsNumber, taken, j)) {
|
||||||
roulette -= fitnessTable[j].first;
|
roulette -= fitnessTable[j].first;
|
||||||
}
|
}
|
||||||
j+=1;
|
j += 1;
|
||||||
}
|
}
|
||||||
parents[i] = fitnessTable[j].second;
|
parents[i] = fitnessTable[j].second;
|
||||||
taken[i] = j;
|
taken[i] = j;
|
||||||
@ -196,49 +263,47 @@ void selection(string * population,string * parents, int populationSize, int par
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string mutate(string child) {
|
string mutate(string child) {
|
||||||
|
|
||||||
int d3 = rand() % 3;
|
int d3 = rand() % 3;
|
||||||
string mutation = generateValue();
|
string mutation = generateValue();
|
||||||
switch(d3) {
|
switch (d3) {
|
||||||
case 0:
|
case 0:
|
||||||
child = mutation + child.substr(3,6);
|
child = mutation + child.substr(3, 6);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
child = child.substr(0,3) + mutation + child.substr(6,3);
|
child = child.substr(0, 3) + mutation + child.substr(6, 3);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
child = child.substr(0,6) + mutation;
|
child = child.substr(0, 6) + mutation;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string cross(string parent[2]) {
|
string cross(string parent[2]) {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
string child = "";
|
string child = "";
|
||||||
for(i=0;i<3;i++) {
|
for (i = 0;i < 3;i++) {
|
||||||
child += parent[rand() % 2].substr(i*3,3);
|
child += parent[rand() % 2].substr(i * 3, 3);
|
||||||
}
|
}
|
||||||
if (child == parent[0] or child == parent[1]) {
|
if (child == parent[0] or child == parent[1]) {
|
||||||
string other;
|
string other;
|
||||||
if (child == parent[0]) other = parent[1];
|
if (child == parent[0]) other = parent[1];
|
||||||
else other = parent[0];
|
else other = parent[0];
|
||||||
int d3 = rand() % 3;
|
int d3 = rand() % 3;
|
||||||
switch(d3) {
|
switch (d3) {
|
||||||
case 0:
|
case 0:
|
||||||
child = other.substr((rand() % 3)*3,3) + child.substr(3,6);
|
child = other.substr((rand() % 3) * 3, 3) + child.substr(3, 6);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
child = child.substr(0,3) + other.substr((rand() % 3)*3,3) + child.substr(6,3);
|
child = child.substr(0, 3) + other.substr((rand() % 3) * 3, 3) + child.substr(6, 3);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
child = child.substr(0,6) + other.substr((rand() % 3)*3,3);
|
child = child.substr(0, 6) + other.substr((rand() % 3) * 3, 3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int d1000 = rand() % 1000;
|
int d1000 = rand() % 1000;
|
||||||
@ -248,29 +313,28 @@ string cross(string parent[2]) {
|
|||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void crossover(string* parents, string* nextGen, int parentsNumber, int nextGenSize) {
|
||||||
void crossover(string * parents,string * nextGen,int parentsNumber,int nextGenSize) {
|
|
||||||
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
int i,j;
|
int i, j;
|
||||||
for(i=0;i<parentsNumber;i++) {
|
for (i = 0;i < parentsNumber;i++) {
|
||||||
if (counter >= nextGenSize) {
|
if (counter >= nextGenSize) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nextGen[counter] = parents[i];
|
nextGen[counter] = parents[i];
|
||||||
counter +=1;
|
counter += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(counter < nextGenSize) {
|
while (counter < nextGenSize) {
|
||||||
for(i=0;i<parentsNumber;i++) {
|
for (i = 0;i < parentsNumber;i++) {
|
||||||
if (counter >= nextGenSize) {
|
if (counter >= nextGenSize) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for(j=i;j<parentsNumber;j++) {
|
for (j = i;j < parentsNumber;j++) {
|
||||||
if (counter >= nextGenSize) {
|
if (counter >= nextGenSize) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
string couple[2];
|
string couple[2];
|
||||||
@ -285,110 +349,105 @@ void crossover(string * parents,string * nextGen,int parentsNumber,int nextGenSi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void genetic_algorithm(string* population, int populationSize, int parentsNumber, string* outcome, int outcomeSize) {
|
||||||
|
|
||||||
void genetic_algorithm(string * population, int populationSize, int parentsNumber,string * outcome, int outcomeSize) {
|
int iteration, i;
|
||||||
|
for (iteration = 0;iteration < 5;iteration++) {
|
||||||
|
string* parents = new string[parentsNumber];
|
||||||
|
selection(population, parents, populationSize, parentsNumber);
|
||||||
|
|
||||||
int iteration,i;
|
string* nextGen = new string[populationSize];
|
||||||
for(iteration=0;iteration<5;iteration++) {
|
crossover(parents, nextGen, parentsNumber, populationSize);
|
||||||
string * parents = new string[parentsNumber];
|
|
||||||
selection(population,parents,populationSize,parentsNumber);
|
|
||||||
|
|
||||||
string * nextGen = new string[populationSize];
|
for (i = 0;i < populationSize;i++) {
|
||||||
crossover(parents,nextGen,parentsNumber,populationSize);
|
|
||||||
|
|
||||||
for(i=0;i<populationSize;i++) {
|
|
||||||
population[i] = nextGen[i];
|
population[i] = nextGen[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ranking(population,outcome,populationSize,outcomeSize);
|
ranking(population, outcome, populationSize, outcomeSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string przypiszKod(string warzywa) {
|
string przypiszKod(string warzywa) {
|
||||||
if (warzywa=="buraki") {
|
if (warzywa == "buraki") {
|
||||||
if (gmoLeftBuraki > 0) {
|
if (gmoLeftBuraki > 0) {
|
||||||
string temp = burakiDoSadzenia[gmoLeftBuraki - 1];
|
string temp = burakiDoSadzenia[gmoLeftBuraki - 1];
|
||||||
gmoLeftBuraki -= 1;
|
gmoLeftBuraki -= 1;
|
||||||
return temp;
|
return temp;
|
||||||
}
|
|
||||||
else {
|
|
||||||
return generateVegetable();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (gmoLeftZiemniaki > 0) {
|
return generateVegetable();
|
||||||
string temp = ziemniakiDoSadzenia[gmoLeftZiemniaki - 1];
|
|
||||||
gmoLeftZiemniaki -= 1;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return generateVegetable();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (gmoLeftZiemniaki > 0) {
|
||||||
|
string temp = ziemniakiDoSadzenia[gmoLeftZiemniaki - 1];
|
||||||
|
gmoLeftZiemniaki -= 1;
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return generateVegetable();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void przypiszKodGenetyczny(int i, int j, char plant) {
|
void przypiszKodGenetyczny(int i, int j, char plant) {
|
||||||
if (plant == 'B') {
|
if (plant == 'B') {
|
||||||
kod_genetyczny[i][j] = przypiszKod("buraki");
|
kod_genetyczny[i][j] = przypiszKod("buraki");
|
||||||
}
|
}
|
||||||
else if (plant == 'Z') {
|
else if (plant == 'Z') {
|
||||||
kod_genetyczny[i][j] = przypiszKod("ziemniaki");
|
kod_genetyczny[i][j] = przypiszKod("ziemniaki");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void obslugaAlgorytmuGenetycznego() {
|
void obslugaAlgorytmuGenetycznego() {
|
||||||
cout << "Zebrane buraki: " << scoreBuraki << endl;
|
cout << "Zebrane buraki: " << scoreBuraki << endl;
|
||||||
cout << "Zebrane ziemniaki: " << scoreZiemniaki << endl;
|
cout << "Zebrane ziemniaki: " << scoreZiemniaki << endl;
|
||||||
if(scoreBuraki>=rozmiarPopulacji) {
|
if (scoreBuraki >= rozmiarPopulacji) {
|
||||||
scoreBuraki = 0;
|
scoreBuraki = 0;
|
||||||
|
|
||||||
for(int i = 0;i<20;i++) {
|
for (int i = 0;i < 20;i++) {
|
||||||
burakiDoSadzenia[i] = "000000000";
|
burakiDoSadzenia[i] = "000000000";
|
||||||
}
|
}
|
||||||
genetic_algorithm(zebraneBuraki, rozmiarPopulacji, rozmiarPopulacji - 5, burakiDoSadzenia, 20);
|
genetic_algorithm(zebraneBuraki, rozmiarPopulacji, rozmiarPopulacji - 5, burakiDoSadzenia, 20);
|
||||||
gmoLeftBuraki = 20;
|
gmoLeftBuraki = 20;
|
||||||
for(int i = 0; i<rozmiarPopulacji;i++) {
|
for (int i = 0; i < rozmiarPopulacji;i++) {
|
||||||
zebraneBuraki[i] = "000000000";
|
zebraneBuraki[i] = "000000000";
|
||||||
}
|
}
|
||||||
for(int i=0;i<20;i++) {
|
for (int i = 0;i < 20;i++) {
|
||||||
cout << burakiDoSadzenia[i] << endl;
|
cout << burakiDoSadzenia[i] << endl;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(scoreZiemniaki>=rozmiarPopulacji) {
|
|
||||||
scoreZiemniaki = 0;
|
|
||||||
|
|
||||||
for(int i = 0;i<20;i++) {
|
|
||||||
ziemniakiDoSadzenia[i] = "000000000";
|
|
||||||
}
|
|
||||||
genetic_algorithm(zebraneZiemniaki, rozmiarPopulacji, rozmiarPopulacji - 5, ziemniakiDoSadzenia, 20);
|
|
||||||
gmoLeftZiemniaki = 20;
|
|
||||||
for(int i = 0; i<rozmiarPopulacji;i++) {
|
|
||||||
zebraneZiemniaki[i] = "000000000";
|
|
||||||
}
|
|
||||||
for(int i=0;i<20;i++) {
|
|
||||||
cout << ziemniakiDoSadzenia[i] << endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
if (scoreZiemniaki >= rozmiarPopulacji) {
|
||||||
|
scoreZiemniaki = 0;
|
||||||
|
|
||||||
|
for (int i = 0;i < 20;i++) {
|
||||||
void generujKody() {
|
ziemniakiDoSadzenia[i] = "000000000";
|
||||||
for(int i=0;i<27;i++) {
|
}
|
||||||
for(int j=0;j<27;j++) {
|
genetic_algorithm(zebraneZiemniaki, rozmiarPopulacji, rozmiarPopulacji - 5, ziemniakiDoSadzenia, 20);
|
||||||
if (pole[i][j][0] == 'B') {
|
gmoLeftZiemniaki = 20;
|
||||||
kod_genetyczny[i][j] = przypiszKod("buraki");
|
for (int i = 0; i < rozmiarPopulacji;i++) {
|
||||||
}
|
zebraneZiemniaki[i] = "000000000";
|
||||||
else if (pole[i][j][0] == 'Z') {
|
}
|
||||||
kod_genetyczny[i][j] = przypiszKod("ziemniaki");
|
for (int i = 0;i < 20;i++) {
|
||||||
}
|
cout << ziemniakiDoSadzenia[i] << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
void generujKody() {
|
||||||
|
for (int i = 0;i < 27;i++) {
|
||||||
|
for (int j = 0;j < 27;j++) {
|
||||||
|
if (pole[i][j][0] == 'B') {
|
||||||
|
kod_genetyczny[i][j] = przypiszKod("buraki");
|
||||||
|
}
|
||||||
|
else if (pole[i][j][0] == 'Z') {
|
||||||
|
kod_genetyczny[i][j] = przypiszKod("ziemniaki");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//========================================================
|
||||||
|
|
||||||
|
|
||||||
void color(string foregroundColor, string backgroundColor)
|
void color(string foregroundColor, string backgroundColor)
|
||||||
@ -532,34 +591,34 @@ void correctMovement(char wantedWay)
|
|||||||
{
|
{
|
||||||
switch (currentWay)
|
switch (currentWay)
|
||||||
{
|
{
|
||||||
case 'N':
|
case 'N':
|
||||||
{
|
{
|
||||||
if (wantedWay == 'S')
|
if (wantedWay == 'S')
|
||||||
currentWay = wantedWay;
|
currentWay = wantedWay;
|
||||||
else
|
else
|
||||||
currentWay = 'W';
|
currentWay = 'W';
|
||||||
}break;
|
}break;
|
||||||
case 'S':
|
case 'S':
|
||||||
{
|
{
|
||||||
if (wantedWay == 'N')
|
if (wantedWay == 'N')
|
||||||
currentWay = wantedWay;
|
currentWay = wantedWay;
|
||||||
else
|
else
|
||||||
currentWay = 'W';
|
currentWay = 'W';
|
||||||
}break;
|
}break;
|
||||||
case 'W':
|
case 'W':
|
||||||
{
|
{
|
||||||
if (wantedWay == 'E')
|
if (wantedWay == 'E')
|
||||||
currentWay = wantedWay;
|
currentWay = wantedWay;
|
||||||
else
|
else
|
||||||
currentWay = 'N';
|
currentWay = 'N';
|
||||||
}break;
|
}break;
|
||||||
case 'E':
|
case 'E':
|
||||||
{
|
{
|
||||||
if (wantedWay == 'W')
|
if (wantedWay == 'W')
|
||||||
currentWay = wantedWay;
|
currentWay = wantedWay;
|
||||||
else
|
else
|
||||||
currentWay = 'N';
|
currentWay = 'N';
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -568,103 +627,103 @@ void Move(char kierunek)
|
|||||||
switch (kierunek)
|
switch (kierunek)
|
||||||
{
|
{
|
||||||
//gA3ra-(w)
|
//gA3ra-(w)
|
||||||
case 'w':
|
case 'w':
|
||||||
|
{
|
||||||
|
if (pole[pozycjaTraktoraY - 1][pozycjaTraktoraX][0] != '#')
|
||||||
{
|
{
|
||||||
if (pole[pozycjaTraktoraY - 1][pozycjaTraktoraX][0] != '#')
|
if (pole[pozycjaTraktoraY - 1][pozycjaTraktoraX][0] == 'B') {
|
||||||
{
|
zebraneBuraki[scoreBuraki] = kod_genetyczny[pozycjaTraktoraY - 1][pozycjaTraktoraX];
|
||||||
if (pole[pozycjaTraktoraY - 1][pozycjaTraktoraX][0] == 'B') {
|
scoreBuraki += 1;
|
||||||
zebraneBuraki[scoreBuraki] = kod_genetyczny[pozycjaTraktoraY - 1][pozycjaTraktoraX];
|
kod_genetyczny[pozycjaTraktoraY - 1][pozycjaTraktoraX] = "000000000";
|
||||||
scoreBuraki+=1;
|
|
||||||
kod_genetyczny[pozycjaTraktoraY - 1][pozycjaTraktoraX] = "000000000";
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (pole[pozycjaTraktoraY - 1][pozycjaTraktoraX][0] == 'Z') {
|
|
||||||
zebraneZiemniaki[scoreZiemniaki] = kod_genetyczny[pozycjaTraktoraY - 1][pozycjaTraktoraX];
|
|
||||||
scoreZiemniaki+=1;
|
|
||||||
kod_genetyczny[pozycjaTraktoraY - 1][pozycjaTraktoraX] = "000000000";
|
|
||||||
}
|
|
||||||
|
|
||||||
correctMovement('N');
|
|
||||||
pole[pozycjaTraktoraY][pozycjaTraktoraX][0] = '.';
|
|
||||||
pozycjaTraktoraY--;
|
|
||||||
pole[pozycjaTraktoraY][pozycjaTraktoraX][0] = 'T';
|
|
||||||
}
|
}
|
||||||
updatePola();
|
|
||||||
}break;
|
else if (pole[pozycjaTraktoraY - 1][pozycjaTraktoraX][0] == 'Z') {
|
||||||
//dA3A‚-(s)
|
zebraneZiemniaki[scoreZiemniaki] = kod_genetyczny[pozycjaTraktoraY - 1][pozycjaTraktoraX];
|
||||||
case 's':
|
scoreZiemniaki += 1;
|
||||||
|
kod_genetyczny[pozycjaTraktoraY - 1][pozycjaTraktoraX] = "000000000";
|
||||||
|
}
|
||||||
|
|
||||||
|
correctMovement('N');
|
||||||
|
pole[pozycjaTraktoraY][pozycjaTraktoraX][0] = '.';
|
||||||
|
pozycjaTraktoraY--;
|
||||||
|
pole[pozycjaTraktoraY][pozycjaTraktoraX][0] = 'T';
|
||||||
|
}
|
||||||
|
updatePola();
|
||||||
|
}break;
|
||||||
|
//dA3A‚-(s)
|
||||||
|
case 's':
|
||||||
|
{
|
||||||
|
if (pole[pozycjaTraktoraY + 1][pozycjaTraktoraX][0] != '#')
|
||||||
{
|
{
|
||||||
if (pole[pozycjaTraktoraY + 1][pozycjaTraktoraX][0] != '#')
|
if (pole[pozycjaTraktoraY + 1][pozycjaTraktoraX][0] == 'B') {
|
||||||
{
|
zebraneBuraki[scoreBuraki] = kod_genetyczny[pozycjaTraktoraY + 1][pozycjaTraktoraX];
|
||||||
if (pole[pozycjaTraktoraY +1][pozycjaTraktoraX][0] == 'B') {
|
scoreBuraki += 1;
|
||||||
zebraneBuraki[scoreBuraki] = kod_genetyczny[pozycjaTraktoraY + 1][pozycjaTraktoraX];
|
kod_genetyczny[pozycjaTraktoraY + 1][pozycjaTraktoraX] = "000000000";
|
||||||
scoreBuraki+=1;
|
|
||||||
kod_genetyczny[pozycjaTraktoraY + 1][pozycjaTraktoraX] = "000000000";
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (pole[pozycjaTraktoraY +1][pozycjaTraktoraX][0] == 'Z') {
|
|
||||||
zebraneZiemniaki[scoreZiemniaki] = kod_genetyczny[pozycjaTraktoraY + 1][pozycjaTraktoraX];
|
|
||||||
scoreZiemniaki+=1;
|
|
||||||
kod_genetyczny[pozycjaTraktoraY + 1][pozycjaTraktoraX] = "000000000";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
correctMovement('S');
|
|
||||||
pole[pozycjaTraktoraY][pozycjaTraktoraX][0] = '.';
|
|
||||||
pozycjaTraktoraY++;
|
|
||||||
pole[pozycjaTraktoraY][pozycjaTraktoraX][0] = 'T';
|
|
||||||
}
|
}
|
||||||
updatePola();
|
|
||||||
}break;
|
else if (pole[pozycjaTraktoraY + 1][pozycjaTraktoraX][0] == 'Z') {
|
||||||
//lewo-(a)
|
zebraneZiemniaki[scoreZiemniaki] = kod_genetyczny[pozycjaTraktoraY + 1][pozycjaTraktoraX];
|
||||||
case 'a':
|
scoreZiemniaki += 1;
|
||||||
|
kod_genetyczny[pozycjaTraktoraY + 1][pozycjaTraktoraX] = "000000000";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
correctMovement('S');
|
||||||
|
pole[pozycjaTraktoraY][pozycjaTraktoraX][0] = '.';
|
||||||
|
pozycjaTraktoraY++;
|
||||||
|
pole[pozycjaTraktoraY][pozycjaTraktoraX][0] = 'T';
|
||||||
|
}
|
||||||
|
updatePola();
|
||||||
|
}break;
|
||||||
|
//lewo-(a)
|
||||||
|
case 'a':
|
||||||
|
{
|
||||||
|
if (pole[pozycjaTraktoraY][pozycjaTraktoraX - 1][0] != '#')
|
||||||
{
|
{
|
||||||
if (pole[pozycjaTraktoraY][pozycjaTraktoraX - 1][0] != '#')
|
if (pole[pozycjaTraktoraY][pozycjaTraktoraX - 1][0] == 'B') {
|
||||||
{
|
zebraneBuraki[scoreBuraki] = kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX - 1];
|
||||||
if (pole[pozycjaTraktoraY][pozycjaTraktoraX - 1][0] == 'B') {
|
scoreBuraki += 1;
|
||||||
zebraneBuraki[scoreBuraki] = kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX - 1];
|
kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX - 1] = "000000000";
|
||||||
scoreBuraki+=1;
|
|
||||||
kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX - 1] = "000000000";
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (pole[pozycjaTraktoraY][pozycjaTraktoraX - 1][0] == 'Z') {
|
|
||||||
zebraneZiemniaki[scoreZiemniaki] = kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX - 1];
|
|
||||||
scoreZiemniaki+=1;
|
|
||||||
kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX - 1] = "000000000";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
correctMovement('W');
|
|
||||||
pole[pozycjaTraktoraY][pozycjaTraktoraX][0] = '.';
|
|
||||||
pozycjaTraktoraX--;
|
|
||||||
pole[pozycjaTraktoraY][pozycjaTraktoraX][0] = 'T';
|
|
||||||
}
|
}
|
||||||
updatePola();
|
|
||||||
}break;
|
else if (pole[pozycjaTraktoraY][pozycjaTraktoraX - 1][0] == 'Z') {
|
||||||
//prawo-(d)
|
zebraneZiemniaki[scoreZiemniaki] = kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX - 1];
|
||||||
case 'd':
|
scoreZiemniaki += 1;
|
||||||
|
kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX - 1] = "000000000";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
correctMovement('W');
|
||||||
|
pole[pozycjaTraktoraY][pozycjaTraktoraX][0] = '.';
|
||||||
|
pozycjaTraktoraX--;
|
||||||
|
pole[pozycjaTraktoraY][pozycjaTraktoraX][0] = 'T';
|
||||||
|
}
|
||||||
|
updatePola();
|
||||||
|
}break;
|
||||||
|
//prawo-(d)
|
||||||
|
case 'd':
|
||||||
|
{
|
||||||
|
if (pole[pozycjaTraktoraY][pozycjaTraktoraX + 1][0] != '#')
|
||||||
{
|
{
|
||||||
if (pole[pozycjaTraktoraY][pozycjaTraktoraX + 1][0] != '#')
|
if (pole[pozycjaTraktoraY][pozycjaTraktoraX + 1][0] == 'B') {
|
||||||
{
|
zebraneBuraki[scoreBuraki] = kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX + 1];
|
||||||
if (pole[pozycjaTraktoraY][pozycjaTraktoraX + 1][0] == 'B') {
|
scoreBuraki += 1;
|
||||||
zebraneBuraki[scoreBuraki] = kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX + 1];
|
kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX + 1] = "000000000";
|
||||||
scoreBuraki+=1;
|
|
||||||
kod_genetyczny[pozycjaTraktoraY ][pozycjaTraktoraX + 1] = "000000000";
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (pole[pozycjaTraktoraY][pozycjaTraktoraX + 1][0] == 'Z') {
|
|
||||||
zebraneZiemniaki[scoreZiemniaki] = kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX + 1];
|
|
||||||
scoreZiemniaki+=1;
|
|
||||||
kod_genetyczny[pozycjaTraktoraY ][pozycjaTraktoraX + 1] = "000000000";
|
|
||||||
}
|
|
||||||
|
|
||||||
correctMovement('E');
|
|
||||||
pole[pozycjaTraktoraY][pozycjaTraktoraX][0] = '.';
|
|
||||||
pozycjaTraktoraX++;
|
|
||||||
pole[pozycjaTraktoraY][pozycjaTraktoraX][0] = 'T';
|
|
||||||
}
|
}
|
||||||
updatePola();
|
|
||||||
}break;
|
else if (pole[pozycjaTraktoraY][pozycjaTraktoraX + 1][0] == 'Z') {
|
||||||
|
zebraneZiemniaki[scoreZiemniaki] = kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX + 1];
|
||||||
|
scoreZiemniaki += 1;
|
||||||
|
kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX + 1] = "000000000";
|
||||||
|
}
|
||||||
|
|
||||||
|
correctMovement('E');
|
||||||
|
pole[pozycjaTraktoraY][pozycjaTraktoraX][0] = '.';
|
||||||
|
pozycjaTraktoraX++;
|
||||||
|
pole[pozycjaTraktoraY][pozycjaTraktoraX][0] = 'T';
|
||||||
|
}
|
||||||
|
updatePola();
|
||||||
|
}break;
|
||||||
}
|
}
|
||||||
|
|
||||||
obslugaAlgorytmuGenetycznego();
|
obslugaAlgorytmuGenetycznego();
|
||||||
@ -680,7 +739,7 @@ bool isValid(int x, int y)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool isDestination(int x, int y,Pair dest)
|
bool isDestination(int x, int y, Pair dest)
|
||||||
{
|
{
|
||||||
if (dest.first == x && dest.second == y)
|
if (dest.first == x && dest.second == y)
|
||||||
{
|
{
|
||||||
@ -730,7 +789,7 @@ void tracePath(cell cellDetails[][COL], Pair dest)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void aStarSearch(int grid[][COL],Pair src, Pair dest)
|
void aStarSearch(int grid[][COL], Pair src, Pair dest)
|
||||||
{
|
{
|
||||||
bool closedList[ROW][COL];
|
bool closedList[ROW][COL];
|
||||||
memset(closedList, false, sizeof(closedList));
|
memset(closedList, false, sizeof(closedList));
|
||||||
@ -770,7 +829,7 @@ void aStarSearch(int grid[][COL],Pair src, Pair dest)
|
|||||||
|
|
||||||
double gNew, hNew, fNew;
|
double gNew, hNew, fNew;
|
||||||
double waga = 1.0;
|
double waga = 1.0;
|
||||||
waga = ((double)pole[j][i][1] - 48)*1.0;//----waga
|
waga = ((double)pole[j][i][1] - 48) * 1.0;//----waga
|
||||||
|
|
||||||
//----------- 1st Successor (North) ------------
|
//----------- 1st Successor (North) ------------
|
||||||
if (isValid(i - 1, j) == true)
|
if (isValid(i - 1, j) == true)
|
||||||
@ -905,7 +964,7 @@ void aStarSearch(int grid[][COL],Pair src, Pair dest)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gogo(int endX,int endY)
|
void gogo(int endX, int endY)
|
||||||
{
|
{
|
||||||
updatePola();
|
updatePola();
|
||||||
Sleep(1000);
|
Sleep(1000);
|
||||||
@ -985,7 +1044,7 @@ void testSI1()
|
|||||||
|
|
||||||
void sendState()
|
void sendState()
|
||||||
{
|
{
|
||||||
ofstream write("dane.txt");
|
ofstream write("pliki/dane.txt");
|
||||||
for (int i = 1; i < 26; i++)
|
for (int i = 1; i < 26; i++)
|
||||||
{
|
{
|
||||||
for (int j = 1; j < 26; j++)
|
for (int j = 1; j < 26; j++)
|
||||||
@ -1005,7 +1064,7 @@ void sendState()
|
|||||||
}
|
}
|
||||||
void reciveState()
|
void reciveState()
|
||||||
{
|
{
|
||||||
ifstream read("decyzje.txt");
|
ifstream read("pliki/decyzje.txt");
|
||||||
if (read.is_open())
|
if (read.is_open())
|
||||||
{
|
{
|
||||||
char plant;
|
char plant;
|
||||||
@ -1015,15 +1074,15 @@ void reciveState()
|
|||||||
{
|
{
|
||||||
if (j == 25)
|
if (j == 25)
|
||||||
{
|
{
|
||||||
gogo(1, i+1);
|
gogo(1, i + 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gogo(j+1 , i );
|
gogo(j + 1, i);
|
||||||
}
|
}
|
||||||
pole[i][j][0] = plant;
|
pole[i][j][0] = plant;
|
||||||
|
|
||||||
przypiszKodGenetyczny(i,j,plant);
|
przypiszKodGenetyczny(i, j, plant);
|
||||||
|
|
||||||
if (plant == '.')
|
if (plant == '.')
|
||||||
{
|
{
|
||||||
@ -1091,6 +1150,68 @@ void start3()
|
|||||||
gogo(goalX, goalY);
|
gogo(goalX, goalY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testTree() {
|
||||||
|
int x, y;
|
||||||
|
x = 3;
|
||||||
|
y = 3;
|
||||||
|
//Nie podejmuj
|
||||||
|
stan[x][y][0] = 0;
|
||||||
|
stan[x][y][1] = 10;
|
||||||
|
stanPola(x, y);
|
||||||
|
cout << decyzja;
|
||||||
|
}
|
||||||
|
void testTree1() {
|
||||||
|
int x, y;
|
||||||
|
x = 3;
|
||||||
|
y = 3;
|
||||||
|
//Nawoz
|
||||||
|
stan[x][y][0] = 0;
|
||||||
|
stan[x][y][1] = 15;
|
||||||
|
stanPola(x, y);
|
||||||
|
cout << decyzja;
|
||||||
|
}
|
||||||
|
void testTree2() {
|
||||||
|
int x, y;
|
||||||
|
x = 3;
|
||||||
|
y = 3;
|
||||||
|
//Nie podejmuj
|
||||||
|
stan[x][y][0] = 1;
|
||||||
|
stan[x][y][1] = 20;
|
||||||
|
stanPola(x, y);
|
||||||
|
cout << decyzja;
|
||||||
|
}
|
||||||
|
void testTree3() {
|
||||||
|
int x, y;
|
||||||
|
x = 3;
|
||||||
|
y = 3;
|
||||||
|
//Zbierz
|
||||||
|
stan[x][y][0] = 1;
|
||||||
|
stan[x][y][1] = 41;
|
||||||
|
stanPola(x, y);
|
||||||
|
cout << decyzja;
|
||||||
|
}
|
||||||
|
void testTree4() {
|
||||||
|
int x, y;
|
||||||
|
x = 3;
|
||||||
|
y = 3;
|
||||||
|
//Nie podejmuj
|
||||||
|
stan[x][y][0] = 1;
|
||||||
|
stan[x][y][1] = 90;
|
||||||
|
stanPola(x, y);
|
||||||
|
cout << decyzja;
|
||||||
|
|
||||||
|
}
|
||||||
|
void testTree5() {
|
||||||
|
int x, y;
|
||||||
|
x = 3;
|
||||||
|
y = 3;
|
||||||
|
//Srodek
|
||||||
|
stan[x][y][0] = 3;
|
||||||
|
stan[x][y][1] = 90;
|
||||||
|
stanPola(x, y);
|
||||||
|
cout << decyzja;
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
srand(time(0));
|
srand(time(0));
|
||||||
@ -1123,14 +1244,14 @@ int main()
|
|||||||
pole[i + 1][i + 1][1] = '9';
|
pole[i + 1][i + 1][1] = '9';
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i <25; i++) {
|
for (int i = 0; i < 25; i++) {
|
||||||
for (int j = 0; j <10; j++) {
|
for (int j = 0; j < 10; j++) {
|
||||||
pole[j + 1][i + 1][0] = 'B';
|
pole[j + 1][i + 1][0] = 'B';
|
||||||
pole[j + 1][i + 1][1] = '9';
|
pole[j + 1][i + 1][1] = '9';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i <25; i++) {
|
for (int i = 0; i < 25; i++) {
|
||||||
for (int j = 10; j <20; j++) {
|
for (int j = 10; j < 20; j++) {
|
||||||
pole[j + 1][i + 1][0] = 'Z';
|
pole[j + 1][i + 1][0] = 'Z';
|
||||||
pole[j + 1][i + 1][1] = '9';
|
pole[j + 1][i + 1][1] = '9';
|
||||||
}
|
}
|
||||||
@ -1142,6 +1263,7 @@ int main()
|
|||||||
|
|
||||||
start1(); // testy start 1-3
|
start1(); // testy start 1-3
|
||||||
|
|
||||||
|
|
||||||
//---------start---------//
|
//---------start---------//
|
||||||
bool traktorDziala = true;
|
bool traktorDziala = true;
|
||||||
|
|
||||||
|
31
Traktor_DrzewaDecyzyjne.sln
Normal file
31
Traktor_DrzewaDecyzyjne.sln
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 16
|
||||||
|
VisualStudioVersion = 16.0.29503.13
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Traktor_DrzewaDecyzyjne", "Traktor_DrzewaDecyzyjne.vcxproj", "{C2FF0872-AC9D-4BD9-A46D-DC65A728BFF5}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{C2FF0872-AC9D-4BD9-A46D-DC65A728BFF5}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{C2FF0872-AC9D-4BD9-A46D-DC65A728BFF5}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{C2FF0872-AC9D-4BD9-A46D-DC65A728BFF5}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{C2FF0872-AC9D-4BD9-A46D-DC65A728BFF5}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{C2FF0872-AC9D-4BD9-A46D-DC65A728BFF5}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{C2FF0872-AC9D-4BD9-A46D-DC65A728BFF5}.Release|x64.Build.0 = Release|x64
|
||||||
|
{C2FF0872-AC9D-4BD9-A46D-DC65A728BFF5}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{C2FF0872-AC9D-4BD9-A46D-DC65A728BFF5}.Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {891B470F-58C4-41E4-A102-A1D8CBB6BD64}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
159
Traktor_DrzewaDecyzyjne.vcxproj
Normal file
159
Traktor_DrzewaDecyzyjne.vcxproj
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<ProjectGuid>{C2FF0872-AC9D-4BD9-A46D-DC65A728BFF5}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>TraktorDrzewaDecyzyjne</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Main.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
4
Traktor_DrzewaDecyzyjne.vcxproj.user
Normal file
4
Traktor_DrzewaDecyzyjne.vcxproj.user
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup />
|
||||||
|
</Project>
|
Loading…
Reference in New Issue
Block a user