Prześlij pliki do ''

This commit is contained in:
Jarosław Zbąski 2020-06-06 16:04:24 +00:00
parent 75ae2eeeb2
commit efe3723b57

112
Main.cpp
View File

@ -7,6 +7,7 @@
#include<set>
#include<math.h>
#include<stack>
#include<fstream>
using namespace std;
@ -21,7 +22,7 @@ struct cell
double f, g, h;
};
char pole[27][27][2];
char pole[27][27][6];
int pozycjaTraktoraX = 1, pozycjaTraktoraY = 1;
char currentWay = 'S';
@ -130,6 +131,10 @@ void updatePola()
{
color("purple", "dark_yellow");
}break;
case 'Z':
{
color("cyan", "dark_yellow");
}break;
case 'T':
{
color("red", "dark_yellow");
@ -501,7 +506,7 @@ void test1()
{
pole[1][3][0] = 'B';
pole[1][3][1] = '9';
pole[3][1][0] = 'B';
pole[3][1][0] = 'Z';
pole[3][1][1] = '9';
}
void test2()
@ -518,15 +523,116 @@ void test2()
updatePola();
}
void testSI1()
{
for (int i = 1; i < 26; i++)
{
for (int j = 1; j < 26; j++)
{
if (j % 3 == 0)
{
pole[i][j][2] = 'z'; //zyzne
pole[i][j][3] = 'n'; //nawodnione
pole[i][j][4] = 'c'; //w cieniu
pole[i][j][5] = 'k'; //kwasne
}
else
{
if (j % 3 == 1)
{
pole[i][j][2] = 'j'; //jalowe
pole[i][j][3] = 'n'; //nawodnione
pole[i][j][4] = 's'; //w sloncu
pole[i][j][5] = 'n'; //neutralne
}
else
{
pole[i][j][2] = 'z'; //zyzne
pole[i][j][3] = 's'; //suche
pole[i][j][4] = 's'; //sloneczne
pole[i][j][5] = 'z'; //zasadowe
}
}
}
}
}
void sendState()
{
ofstream write("dane.txt");
for (int i = 1; i < 26; i++)
{
for (int j = 1; j < 26; j++)
{
string a;
a += pole[i][j][2];
a += ' ';
a += pole[i][j][3];
a += ' ';
a += pole[i][j][4];
a += ' ';
a += pole[i][j][5];
write << a << endl;
}
}
write.close();
}
void reciveState()
{
ifstream read("decyzje.txt");
if (read.is_open())
{
char plant;
int i = 1;
int j = 1;
while (read >> plant)
{
if (j == 25)
{
gogo(1, i+1);
}
else
{
gogo(j+1 , i );
}
pole[i][j][0] = plant;
if (plant == '.')
{
pole[i][j][1] = '1';
}
else
{
pole[i][j][1] = '9';
}
if (j == 25)
{
j = 1;
i += 1;
}
else
{
j += 1;
}
}
}
}
void start1()
{
int goalX = 3, goalY = 4;
test1();
testSI1();
pole[1][1][0] = 'T';
pole[1][1][1] = '1';
pole[goalY][goalX][0] = 'G';
pole[goalY][goalX][1] = '9';
gogo(goalX, goalY);
gogo(goalX - 1, goalY);
pole[goalY][goalX][0] = 'Z';
pole[goalY][goalX][1] = '9';
updatePola();
//sendState(); //trzeba ręcznie zmieniać między wysyłaniem stanu a pobieraniem stanu pola
reciveState();
}
void start2()
{
@ -581,7 +687,7 @@ int main()
updatePola();
start3(); // testy start 1-3
start1(); // testy start 1-3
//---------start---------//
bool traktorDziala = true;