diff --git a/Main.cpp b/Main.cpp index 29f8d6a..100d013 100644 --- a/Main.cpp +++ b/Main.cpp @@ -35,8 +35,9 @@ struct cell char pole[27][27][6]; int pozycjaTraktoraX = 1, pozycjaTraktoraY = 1; char currentWay = 'S'; +bool gleba[27][27][2]; //======================================================== - +//neuro start double poleInt[27][27][2]; char underTraktor = '.'; char underTraktorWeight = '1'; @@ -60,24 +61,6 @@ 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; @@ -97,7 +80,7 @@ void decisionTree(string polecenie) { } inFile.close(); - akcja(); + //akcja(); } void stanPola(int x, int y) { //[x][x][0] = 0 - brak chemii @@ -752,6 +735,34 @@ void plantVeg() } } } +void akcja() { + if (decyzja == 0) { + //nic nie rób + } + else if (decyzja == 1) { + gleba[pozycjaTraktoraY][pozycjaTraktoraX][0] = true; + } + else if (decyzja == 2) { + gleba[pozycjaTraktoraY][pozycjaTraktoraX][1] = true; + } + else if (decyzja == 4) { + if (underTraktor == 'B') { + zebraneBuraki[scoreBuraki] = kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX]; + scoreBuraki += 1; + kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX] = "000000000"; + } + else if (underTraktor == 'Z') { + zebraneZiemniaki[scoreZiemniaki] = kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX]; + scoreZiemniaki += 1; + kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX] = "000000000"; + } + obslugaAlgorytmuGenetycznego(); + plantVeg(); + } + else if (decyzja == 5) { + //Zbierz rośline ale nie dodawaj do licznika + } +} void tracePath(cell cellDetails[][COL], Pair dest, string action) { //printf("\nThe Path is "); //----start info @@ -787,6 +798,7 @@ void tracePath(cell cellDetails[][COL], Pair dest, string action) Move('s'); if (p.second < pozycjaTraktoraY) Move('w'); + decyzja = 4; Sleep(1000); } if (action == "time" || action == "moveWithTime") @@ -801,18 +813,7 @@ void tracePath(cell cellDetails[][COL], Pair dest, string action) } if (action == "moveWithPick") { - if (underTraktor == 'B') { - zebraneBuraki[scoreBuraki] = kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX]; - scoreBuraki += 1; - kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX] = "000000000"; - } - else if (underTraktor == 'Z') { - zebraneZiemniaki[scoreZiemniaki] = kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX]; - scoreZiemniaki += 1; - kod_genetyczny[pozycjaTraktoraY][pozycjaTraktoraX] = "000000000"; - } - obslugaAlgorytmuGenetycznego(); - plantVeg(); + akcja(); } return; @@ -1040,7 +1041,6 @@ void test2() test1(); updatePola(); } - void testSI1() { for (int i = 1; i < 26; i++) @@ -1075,33 +1075,6 @@ void testSI1() } } -/*void plantVeg() -{ - int x = pozycjaTraktoraX, y = pozycjaTraktoraY; - underTraktor = poleRecive[x][y]; - przypiszKodGenetyczny(x, y, poleRecive[x][y]); - if (poleRecive[x][y] == '.') - { - underTraktorWeight = '1'; - poleInt[x][y][0] = 0; - poleInt[x][y][1] = 0; - } - else - { - if (poleRecive[x][y] == 'Z') - { - underTraktorWeight = '5'; - poleInt[x][y][0] = 0; - poleInt[x][y][1] = 1; - } - else - { - underTraktorWeight = '9'; - poleInt[x][y][0] = 0; - poleInt[x][y][1] = 1; - } - } -}*/ void sendState() { ofstream write("dane.txt");