Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- версия Alpha 3.6
- работает неправильно
- 1)игрок всегда ноmер 1
- 2)начал переделывать ИИ
- 3)хз сколько буду дорабатывать,но после доработки,это будет Beta 1.0
- */
- #include <string>
- #include <iostream>
- #include <ctime>
- using namespace std;
- int pole[3][3];
- /* y x
- a b c x
- 0 0 1 2
- 1 0 1 2
- 2 0 1 2
- y
- */
- int play=0;
- int y,x;
- void out()//готово
- {
- cout<<"_____________________________________"<<endl;
- cout<<pole[0][0]<<pole[0][1]<<pole[0][2]<<endl;
- cout<<pole[1][0]<<pole[1][1]<<pole[1][2]<<endl;
- cout<<pole[2][0]<<pole[2][1]<<pole[2][2]<<endl;
- cout<<"_____________________________________"<<endl;
- }
- int bestplay()
- {
- int win=0,dun=0;
- if(play>=3)
- {
- //вертикали
- for(int i=0;i<3;i++)
- {
- for(int j=0;j<3;j++)
- {
- if(pole[i][j]==2)
- {
- win++;
- }
- if(win==2)
- {
- for(int k=0;k<3;k++)
- {
- pole[k][j]==0;
- pole[k][j]=2;
- return 0;
- }
- }
- }
- }
- //_________________________________________________________________________________________________________
- for(int i=0;i<3;i++)
- {
- for(int j=0;j<3;j++)
- {
- if(pole[i][j]==2)
- {
- win++;
- }
- if(win==2)
- {
- for(int k=0;k<3;k++)
- {
- pole[k][j]==0;
- pole[k][j]=2;
- return 0;
- }
- }
- }
- }
- }
- else
- {
- if(pole[1][1]==0)
- {
- pole[1][1]==2;
- return 0;
- }
- pole[0][2]==2;
- return 0;
- }
- }
- void input()//готово
- {
- char a;
- int y;
- int x;
- cin>>y>>x;
- pole[y][x]=1;
- }
- void newgame()//готово
- {
- for(int i=0;i<3;i++)
- {
- for(int j=0;j<3;j++)
- {
- pole[i][j]=0;
- }
- }
- out();
- }
- int main()
- {
- srand(time(NULL));
- setlocale(LC_ALL,"Russian");
- string kom;
- cin>>kom;
- if(kom=="играть")
- {
- newgame();
- for(int i=0;play<9;i++)
- {
- play++;
- input();
- out();
- play++;
- bestplay();
- out();
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement