#include #include using namespace std; char table[3][3][3]; struct Field{ int index; int x(){ return index %3; } int y(){ return (index/3)%3; } int z(){ return index/3; } int Value(){ switch(table[x()][y()][z()]){ case 'o' : return 2; case 'x' : return 1; default : return 0; } } void setValue(char c){ table[x()][y()][z()] =c; } }; vector fields(27); struct Triple{ Field first; Field second; Field Third(){ Field f; f.index = (second.index+first.index)/2; } int AdaPoints(){ int a = 0; if (first.Value()==1) a++; if (second.Value()==1) a++; if (Third().Value()==1) a++; return a; } int VinitPoints(){ int a = 0; if (first.Value()==2) a++; if (second.Value()==2) a++; if (Third().Value()==2) a++; return a; } bool Finished(){ if (AdaPoints()+VinitPoints()==3) return true; return false; } int Winner(){ if (Finished()) return 0; if (AdaPoints()==2) return 1; if (VinitPoints()==2) return 2; return 0; } void toString(){ cout << "(" << first.index << " " << second.index << " )"; } int findEmpty(){ if (first.Value()=='.') return first.index; if (second.Value()=='.') return second.index; return Third().index; } }; vector allTriples; vector > triplesContainingField(27); bool makingTriple(int a, int b){ return ((fields[a].x()+fields[b].x())%2==0 && (fields[a].y()+fields[b].y())%2==0 && (fields[a].z()+fields[b].z())%2 == 0); } void showGame(){ for (int i=0; i<3; i++) for (int j = 0; j<3; j++){ for (int k = 0; k<3; k++) cout << table[i][j][k] << " "; cout << endl; } } void FirstTurn(bool AdasTurn, int * criticalField){ if (AdasTurn){ for (int i=0; imaxInd) maxInd = i; if (imaxInd) maxInd = i; if (i> table[i][j][k]; if (table[i][j][k] =='x') dif++; if (table[i][j][k]=='o') dif--; if (table[i][j][k] =='.') fieldsLeft++; } bool AdasTurn; if (dif==0) AdasTurn = true; else AdasTurn = false; int criticalField = -1; FirstTurn(AdasTurn, &criticalField); if (criticalField ==-1) return; } int main(){ /* for (int i=0; i<27; i++) fields[i].index = i; Triple t; for (int i=0; i<27; i++) for (int j = i+1; j<27; j++){ if (makingTriple(i,j)){ t = {fields[i], fields[j]}; allTriples.push_back(t); triplesContainingField[i].push_back(t); triplesContainingField[(i+j)/2].push_back(t); triplesContainingField[j].push_back(t); } Game(); showGame();*/ cout << "Hello world"; return 0; } for (int i=0; imaxInd) maxInd = i; if (i