Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a C++ Expert!

Join 244,295 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 893 people online right now. Registration is fast and FREE... Join Now!




Extended Tic Tac Toe AI

 
Reply to this topicStart new topic

Extended Tic Tac Toe AI

omega18
28 Nov, 2008 - 12:17 PM
Post #1

New D.I.C Head
*

Joined: 28 Nov, 2008
Posts: 3

Let's start saying I've started C this year, or most likely in the last 2 months (2-3 hours of lesson per week).
After a pair of lab classes, I heard that in the other class they had done a Tic Tac Toe (which is called Tris, here) program, which let you play in 2 player mode. Something easy.
I thought I could do more and in fact I'd say I did.
My program (about 6-7 hours of work) lets you play player vs player or player vs pc, see an example (pc vs pc, turn by turn or all at once), change the game field dimensions (up to 100x100 cells), modify the required stright cells to win, change player names, keep record of win, loses and draws, erase records and finally quit.

What I can't do is making an unbeatable AI for the general case.
At the moment the pc plays totally random (dumb mode), but I could make it play with a little more sense, with quite few work (normal mode).
The complete AI, altough, is far from my abilities.
Can anyone help in this?

This is the code. If you don't understand some of the Italian text ask and I'll translate (altough I believe it isn't necessary to actually understand that).

CODE
#include <stdio.h>
#include <time.h>
#define ROW 100
#define COLUMN 100

char player1[12],player2[12];
int WIN=3,i,k,j,l=0,row=3,column=3,tris[ROW][COLUMN& #93;,curr=0,player=0,check,lose1=0,lose2=0,losepc=0,score=0,score0=0,scorepc=0,s
core1=0,score2=0;
void Scan_player(){
     j=1;
     do{
        if (player!=0){
           printf("Digita '1' per modificare il nome del giocatore 1 o '0' per lasciarlo invariato\n");
           scanf("%d",&j);
           printf("\n");
           if (j!=0&&j!=1) printf("\nOpzione inesistente\n\n");
           }
        if (j==1){
           printf("\nScrivi il nome del giocatore 1 (max 12 caratteri)\n\n");
           _flushall();
           gets(player1);
           printf("\n\n");
           }
     }
     while(strlen(player2)>12&&j!=0);
     j=1;
     do{
        if (player!=0){
           printf("Digita '1' per modificare il nome del giocatore 2 o '0' per lasciarlo invariato\n");
           scanf("%d",&j);
           printf("\n");
           if (j!=0&&j!=1) printf("\nOpzione inesistente\n\n");
           }
        if (j==1){
           printf("\nScrivi il nome del giocatore 2 (max 12 caratteri)\n\n");
           _flushall();
           gets(player2);
           printf("\n\n");
           }
        }
     while(strlen(player2)>12&&j!=0);
}
void Score_clear(){
     score=0;
     scorepc=0;
     score0=0;
     score1=0;
     score2=0;
     losepc=0;
     lose1=0;
     lose2=0;
}
void Show_name(char player[]){
     j=0;
     while (j<strlen(player)){
           printf("%c",player[j]);
           j++;
           }
}
void Show_score(){
     printf("Numero totale di partite: [%d]\n\n",score);
     printf("Partite vinte da ");
     Show_name(player1);
     printf(": [%d]\n\n",score1);
     printf("Partite perse da ");
     Show_name(player1);
     printf(": [%d]\n\n",lose1);
     printf("Partite vinte da ");
     Show_name(player2);
     printf(": [%d]\n\n",score2);
     printf("Partite perse da ");
     Show_name(player2);
     printf(": [%d]\n\n",lose2);
     printf("Partite vinte dal computer: [%d]\n\n",scorepc);
     printf("Partite perse dal computer: [%d]\n\n",losepc);
     printf("Partite in parita': [%d]\n\n",score0);
}
int win_check(int row,int column,int WIN,int player){
    //controllo colonne
     check=0;
     i=0;
     while(i<row){
           k=0;
           while(k<column){
                           if (tris[i][k]==player){
                              check++;
                              if (check==WIN)return 1;
                              }else{
                              check=0;
                              }
                           k++;
                           }
           check=0;
           i++;
           }
     //controllo righe
     check=0;
     k=0;
     while(k<column){
           i=0;
           while(i<row){
                           if (tris[i][k]==player){
                              check++;
                              if (check==WIN)return 1;
                              }else{
                              check=0;
                              }
                           i++;
                           }
           check=0;
           k++;
           }
     //controllo inferiore diagonali (sx-dx)
     check=0;
     j=0;
     while(j<row){
           k=0;
           i=j;
           while((i<row)&&(k<column)){
                           if (tris[i][k]==player){
                              check++;
                              if (check==WIN)return 1;
                              }else{
                              check=0;
                              }
                           k++;
                           i++;
                           }
           check=0;
           j++;
           }
     //controllo superiore diagonali (sx-dx)
     check=0;
     j=1;
     while(j<row){
           k=j;
           i=0;
           while((i<row)&&(k<column)){
                           if (tris[i][k]==player){
                              check++;
                              if (check==WIN)return 1;
                              }else{
                              check=0;
                              }
                           k++;
                           i++;
                           }
           check=0;
           j++;
           }
     //controllo inferiore diagonali (dx-sx)
     check=0;
     j=0;
     while(j<column){
           k=column-1;
           i=j;
           while((i<row)&&(k<column)){
                           if (tris[i][k]==player){
                              check++;
                              if (check==WIN)return 1;
                              }else{
                              check=0;
                              }
                           k--;
                           i++;
                           }
           check=0;
           j++;
           }
     //controllo superiore diagonali (dx-sx)
     check=0;
     j=1;
     while(j<column){
           k=column-1-j;
           i=0;
           while((i<row)&&(k<column)){
                           if (tris[i][k]==player){
                              check++;
                              if (check==WIN)return 1;
                              }else{
                              check=0;
                              }
                           k--;
                           i++;
                           }
           check=0;
           j++;
           }
return 0;
}
void play(){
            check=curr+1;
            printf("Ora e' il turno di ");
            if (player==1){
               Show_name(player1);
               }else{
               Show_name(player2);
               }
            printf("\n\n");
            while (curr<check){
                  do {
                     printf("Inserisci un numero di riga\n");
                     scanf("%d",&i);
                     printf("Inserisci un numero di colonna\n");
                     scanf("%d",&k);
                     }
                     while (i>row||k>column);
                  if (tris[i-1][k-1]==player){
                     printf("Hai gia' selezionato questa casella\n");
                     printf("Eseguire un'altra selezione\n\n");
                     }
                  if ((tris[i-1][k-1]!=player)&&(tris[i-1][k-1]!=0)){
                     printf("La posizione selezionata e' gia' occupata da ");
                     if (player==1){
                        Show_name(player2);
                        }else{
                        Show_name(player1);
                        }
                     printf("\n\n");
                     printf("Eseguire un'altra selezione\n\n");
                     }
                  if (tris[i-1][k-1]==0){
                     printf("La posizione [%d,%d] e' ora occupata da ",i,k);
                     if (player==1){
                        Show_name(player1);
                        }else{
                        Show_name(player2);
                        }
                     printf("\n\n");
                     tris[i-1][k-1]=player;
                     curr++;
                     }
                  }
}
void pc_play(){
               check=curr+1;
               printf("Ora e' il turno del computer\n\n");
               while(curr<check){
                  srand(time(NULL));
                  i=rand()%row;
                  k=rand()%column;
                  if (tris[i][k]==0){
                     tris[i][k]=player;
                     curr++;
                     }
                  }
            printf("\nIl computer ha giocato\n\n");
}
void show(){
     i=0;
     k=0;
     printf("  ");
     while(k<column){
                 j=k+1;
                 printf(" ");
                 printf(" ");
                 printf("%d",j);
                 printf(" ");
                 printf(" ");
                 k++;
                 }
     printf("\n\n");
     while(i<row){
           j=i+1;
           printf("%d",j);
           if(j<10)printf(" ");
           k=0;
           while(k<column){
                 printf(" ");
                 printf("[");
                 if (tris[i][k]==0)
                 printf("_");
                 if (tris[i][k]==1)
                 printf("X");
                 if (tris[i][k]==2)
                 printf("O");
                 printf("]");
                 printf(" ");
                 k++;
                 }
           i++;
           printf("\n");
           printf("\n");
           }
}
void clear(){
     curr=0;
     i=0;
     while(i<row){
          k=0;
          while(k<column){
                tris[i][k]=0;
                k++;
                }
          i++;
          }
}

int main(){
    printf("Partita a Tris: vince chi riesce a mettere in fila %d dei suoi oggetti\n",WIN);
    printf("Il campo ha dimensioni %d per %d\n\n",row,column);
    printf("Il giocatore 1 usa il simbolo [X]\nil giocatore 2 usa il simbolo [O]\n");
    printf("Una casella vuota e' rappresentata dall'underscore: [_]\n\n");
    printf("La partita e' strutturata a turni\n\n");
    printf("E' possibile giocare in player vs player (modalita' due giocatori)\n\
o contro il pc (modalita' 1 giocatore)\n\n");
    Scan_player();
    player=1;
    int MODE=0;
    clear();
    while(MODE!=9){
                   MODE=0;
                   printf("\n\nDigita: \n\
             '1' per modalita' 1 giocatore\n\
             '2' per modalita' 2 giocatori\n\
             '3' per visualizzare i risultati\n\
             '4' per annullare i risultati\n\
             '5' per vedere un esempio\n\
             '6' per modificare il numero di oggetti in fila\n\
                 necessario per vincere\n\
             '7' per modificare il numero di righe e colonne\n\
             '8' per modificare il nome dei giocatori\n\
             '9' per uscire\n\n");
                 scanf("%d",&MODE);
                 printf("\n");
                 switch(MODE){
    case 1:
                clear();
                printf("Hai selezionato: modalita' 1 giocatore\n\n");
                while((curr<(row*column))&&(win_check(row,column,WIN,player)==0)){
                      if (player==1){
                         printf("Situazione attuale:\n");
                         show();
                         play();
                         if(win_check(row,column,WIN,player)==0)player=2;
                         }else{
                         pc_play();
                         if(win_check(row,column,WIN,player)==0)player=1;
                         }
                      }
                printf("Situazione finale:\n");
                show();
                printf("\n");
                if (win_check(row,column,WIN,player)){
                   if (player==1){
                      printf("Vince ");
                      Show_name(player1);
                      printf("\n\n");
                      score1++;
                      losepc++;
                      }else{
                      printf("Vince il pc");
                      scorepc++;
                      lose1++;
                      }
                   score++;
                   }
                if (curr==(row*column)){
                   printf("Partita patta\n\n");
                   score0++;
                   score++;
                   }
                break;
    case 2:
                clear();
                printf("Hai selezionato: modalita' 2 giocatori\n\n");
                while ((curr<(row*column))&&(win_check(row,column,WIN,player)==0)){
                      printf("Situazione attuale:\n");
                      show();
                      play();
                      if (win_check(row,column,WIN,player)==0){
                         if (player==1)
                         player=2;else player=1;
                         }
                      }
                printf("Situazione finale:\n");
                show();
                printf("\n");
                if (win_check(row,column,WIN,player)){
                   if (player==1){
                      printf("Vince ");
                      Show_name(player1);
                      printf("\n\n");
                      score1++;
                      lose2++;
                      }else{
                      printf("Vince ");
                      Show_name(player2);
                      printf("\n\n");
                      score2++;
                      lose1++;
                      }
                   score++;
                   }
                if (curr==(row*column)){
                   printf("Partita patta\n");
                   score0++;
                   score++;
                   }
                break;
    case 3:
                Show_score();
                break;
    case 4:
                Score_clear();
                break;
    case 5:
                clear();
                printf("Esempio in corso\n\n");
                do {
                   printf("Digita '1' per gioco continuo o '0' per partita turno per turno\n");
                   scanf("%d",&l);
                   printf("\n");
                   }
                while ((l!=0)&&(l!=1));
                while ((curr<(row*column))&&(win_check(row,column,WIN,player)==0)){
                      printf("Situazione attuale:\n");
                      show();
                      pc_play();
                      if (win_check(row,column,WIN,player)==0){
                         if(player==1)
                         player=2;else player=1;
                         }
                      if (l==0){
                         do {
                            printf("Digita '1' per continuare o '0' per chiudere\n");
                            scanf("%d",&j);
                            printf("\n");
                            if (j==0)curr=(row*column);
                            }
                         while ((j!=0)&&(j!=1));
                         }
                      }
                printf("Situazione finale:\n");
                show();
                printf("\n");
                if (win_check(row,column,WIN,player)){
                   printf("Vince il giocatore 'pc %d'\n",player);
                   }
                if(curr==(row*column))printf("Partita patta\n");
                break;
    case 6:
                printf("Digita il nuovo numero di oggetti\n");
                scanf("%d",&WIN);
                printf("\n");
                break;
    case 7:
                do    {
                      printf("Digita il nuovo numero di righe (<=%d)\n",ROW);
                      scanf("%d",&row);
                      printf("\n");
                      }
                while (row>100);
                do    {
                      printf("Digita il nuovo numero di colonne (<=%d)\n",COLUMN);
                      scanf("%d",&column);
                      printf("\n");
                      }
                while (column>100);
                printf("Il campo ha dimensioni %d per %d\n\n",row,column);
                break;
    case 8:
                Scan_player();
                break;
                }
    }
system("PAUSE");
return 0;
}


User is offlineProfile CardPM
+Quote Post


KYA
RE: Extended Tic Tac Toe AI
28 Nov, 2008 - 12:29 PM
Post #2

#include <nerd.h>
Group Icon

Joined: 14 Sep, 2007
Posts: 9,508



Thanked: 363 times
Dream Kudos: 2550
Expert In: C, C++, Java

My Contributions
In order to be "unbeatable" or advanced, the AI needs to plan out the next few moves if not the entire game, store them (array, vector, whatever) and pick from the best one. That's how Deep Blue beat Gary in chess; it could think more then he could. This would have to be done every move and could be resource and time consuming on the PC's part.

An easier way to make the computer seem smarter is have it check the board and make the best move according to just that one set of data. This still won't make it unbeatable though.
User is offlineProfile CardPM
+Quote Post

omega18
RE: Extended Tic Tac Toe AI
28 Nov, 2008 - 01:31 PM
Post #3

New D.I.C Head
*

Joined: 28 Nov, 2008
Posts: 3

QUOTE(KYA @ 28 Nov, 2008 - 12:29 PM) *

In order to be "unbeatable" or advanced, the AI needs to plan out the next few moves if not the entire game, store them (array, vector, whatever) and pick from the best one. That's how Deep Blue beat Gary in chess; it could think more then he could. This would have to be done every move and could be resource and time consuming on the PC's part.

An easier way to make the computer seem smarter is have it check the board and make the best move according to just that one set of data. This still won't make it unbeatable though.

Yeah, I think I can do, more or less, the "easier way".
What I really don't know how to do is storing the whole game chance and make the pc play relying to that.
For this kind of game, the required amount shouldn't be so prohibitive, being it the simplest.
Altough, knowing nothing about how to actually do it, I can't be sure of it.
So, how do I make the AI plan the whole game?
Hope it won't need an array per game chance...
User is offlineProfile CardPM
+Quote Post

KYA
RE: Extended Tic Tac Toe AI
28 Nov, 2008 - 01:38 PM
Post #4

#include <nerd.h>
Group Icon

Joined: 14 Sep, 2007
Posts: 9,508



Thanked: 363 times
Dream Kudos: 2550
Expert In: C, C++, Java

My Contributions
That's actually what I thinking sad.gif

You'll need some sort of data structure to save the information for later retrieval. The choice really depends on how much information you want to save and in what manner.

Probably a sequence of moves that ends with victory would be the easiest way to "plan" out the whole game on the computer's part.
User is offlineProfile CardPM
+Quote Post

janotte
RE: Extended Tic Tac Toe AI
28 Nov, 2008 - 09:55 PM
Post #5

code > sword
Group Icon

Joined: 28 Sep, 2006
Posts: 2,137



Thanked: 150 times
Expert In: C/C++

My Contributions
QUOTE(omega18 @ 28 Nov, 2008 - 01:31 PM) *

So, how do I make the AI plan the whole game?
Hope it won't need an array per game chance...


If you map out the strategy detailed here:
http://www.chessandpoker.com/tic_tac_toe_strategy.html
I think it would be challenging but not beyond you given the skills and abilities you have described so far.
The rules to follow are not trivial but neither are they hugely onerous.

PS
I wasn't able to compile the code you supplied so I'm not sure how far you are away from your goal at this point.

$ gcc -Wall dic.c -o a.out
dic.c:7: error: syntax error before ‘;’ token
dic.c: In function ‘Scan_player’:
dic.c:12: error: ‘player’ undeclared (first use in this function)
dic.c:12: error: (Each undeclared identifier is reported only once
dic.c:12: error: for each function it appears in.)
dic.c:20: warning: implicit declaration of function ‘_flushall’
dic.c:25: warning: implicit declaration of function ‘strlen’
dic.c:25: warning: incompatible implicit declaration of built-in function ‘strlen’
dic.c: In function ‘Score_clear’:
dic.c:44: error: ‘score’ undeclared (first use in this function)
dic.c:45: error: ‘scorepc’ undeclared (first use in this function)
dic.c:46: error: ‘score0’ undeclared (first use in this function)
dic.c:47: error: ‘score1’ undeclared (first use in this function)
dic.c:48: error: ‘score2’ undeclared (first use in this function)
dic.c:49: error: ‘losepc’ undeclared (first use in this function)
dic.c:50: error: ‘lose1’ undeclared (first use in this function)
dic.c:51: error: ‘lose2’ undeclared (first use in this function)
dic.c: In function ‘Show_name’:
dic.c:55: warning: incompatible implicit declaration of built-in function ‘strlen’
dic.c: In function ‘Show_score’:
dic.c:61: error: ‘score’ undeclared (first use in this function)
dic.c:64: error: ‘score1’ undeclared (first use in this function)
dic.c:67: error: ‘lose1’ undeclared (first use in this function)
dic.c:70: error: ‘score2’ undeclared (first use in this function)
dic.c:73: error: ‘lose2’ undeclared (first use in this function)
dic.c:74: error: ‘scorepc’ undeclared (first use in this function)
dic.c:75: error: ‘losepc’ undeclared (first use in this function)
dic.c:76: error: ‘score0’ undeclared (first use in this function)
dic.c: In function ‘win_check’:
dic.c:80: error: ‘check’ undeclared (first use in this function)
dic.c:85: error: ‘tris’ undeclared (first use in this function)
dic.c: In function ‘play’:
dic.c:192: error: ‘check’ undeclared (first use in this function)
dic.c:192: error: ‘curr’ undeclared (first use in this function)
dic.c:194: error: ‘player’ undeclared (first use in this function)
dic.c:208: error: ‘tris’ undeclared (first use in this function)
dic.c: In function ‘pc_play’:
dic.c:236: error: ‘check’ undeclared (first use in this function)
dic.c:236: error: ‘curr’ undeclared (first use in this function)
dic.c:239: warning: implicit declaration of function ‘srand’
dic.c:240: warning: implicit declaration of function ‘rand’
dic.c:242: error: ‘tris’ undeclared (first use in this function)
dic.c:243: error: ‘player’ undeclared (first use in this function)
dic.c: In function ‘show’:
dic.c:271: error: ‘tris’ undeclared (first use in this function)
dic.c: In function ‘clear’:
dic.c:287: error: ‘curr’ undeclared (first use in this function)
dic.c:292: error: ‘tris’ undeclared (first use in this function)
dic.c: In function ‘main’:
dic.c:308: error: ‘player’ undeclared (first use in this function)
dic.c:330: error: ‘curr’ undeclared (first use in this function)
dic.c:349: error: ‘score1’ undeclared (first use in this function)
dic.c:350: error: ‘losepc’ undeclared (first use in this function)
dic.c:353: error: ‘scorepc’ undeclared (first use in this function)
dic.c:354: error: ‘lose1’ undeclared (first use in this function)
dic.c:356: error: ‘score’ undeclared (first use in this function)
dic.c:360: error: ‘score0’ undeclared (first use in this function)
dic.c:385: error: ‘lose2’ undeclared (first use in this function)
dic.c:390: error: ‘score2’ undeclared (first use in this function)
$

User is offlineProfile CardPM
+Quote Post

omega18
RE: Extended Tic Tac Toe AI
1 Dec, 2008 - 09:33 AM
Post #6

New D.I.C Head
*

Joined: 28 Nov, 2008
Posts: 3

QUOTE(janotte @ 28 Nov, 2008 - 09:55 PM) *

QUOTE(omega18 @ 28 Nov, 2008 - 01:31 PM) *

So, how do I make the AI plan the whole game?
Hope it won't need an array per game chance...


If you map out the strategy detailed here:
http://www.chessandpoker.com/tic_tac_toe_strategy.html
I think it would be challenging but not beyond you given the skills and abilities you have described so far.
The rules to follow are not trivial but neither are they hugely onerous.

PS
I wasn't able to compile the code you supplied so I'm not sure how far you are away from your goal at this point.

$ gcc -Wall dic.c -o a.out
dic.c:7: error: syntax error before ‘;’ token
dic.c: In function ‘Scan_player’:
dic.c:12: error: ‘player’ undeclared (first use in this function)
dic.c:12: error: (Each undeclared identifier is reported only once
dic.c:12: error: for each function it appears in.)
dic.c:20: warning: implicit declaration of function ‘_flushall’
dic.c:25: warning: implicit declaration of function ‘strlen’
dic.c:25: warning: incompatible implicit declaration of built-in function ‘strlen’
dic.c: In function ‘Score_clear’:
dic.c:44: error: ‘score’ undeclared (first use in this function)
dic.c:45: error: ‘scorepc’ undeclared (first use in this function)
dic.c:46: error: ‘score0’ undeclared (first use in this function)
dic.c:47: error: ‘score1’ undeclared (first use in this function)
dic.c:48: error: ‘score2’ undeclared (first use in this function)
dic.c:49: error: ‘losepc’ undeclared (first use in this function)
dic.c:50: error: ‘lose1’ undeclared (first use in this function)
dic.c:51: error: ‘lose2’ undeclared (first use in this function)
dic.c: In function ‘Show_name’:
dic.c:55: warning: incompatible implicit declaration of built-in function ‘strlen’
dic.c: In function ‘Show_score’:
dic.c:61: error: ‘score’ undeclared (first use in this function)
dic.c:64: error: ‘score1’ undeclared (first use in this function)
dic.c:67: error: ‘lose1’ undeclared (first use in this function)
dic.c:70: error: ‘score2’ undeclared (first use in this function)
dic.c:73: error: ‘lose2’ undeclared (first use in this function)
dic.c:74: error: ‘scorepc’ undeclared (first use in this function)
dic.c:75: error: ‘losepc’ undeclared (first use in this function)
dic.c:76: error: ‘score0’ undeclared (first use in this function)
dic.c: In function ‘win_check’:
dic.c:80: error: ‘check’ undeclared (first use in this function)
dic.c:85: error: ‘tris’ undeclared (first use in this function)
dic.c: In function ‘play’:
dic.c:192: error: ‘check’ undeclared (first use in this function)
dic.c:192: error: ‘curr’ undeclared (first use in this function)
dic.c:194: error: ‘player’ undeclared (first use in this function)
dic.c:208: error: ‘tris’ undeclared (first use in this function)
dic.c: In function ‘pc_play’:
dic.c:236: error: ‘check’ undeclared (first use in this function)
dic.c:236: error: ‘curr’ undeclared (first use in this function)
dic.c:239: warning: implicit declaration of function ‘srand’
dic.c:240: warning: implicit declaration of function ‘rand’
dic.c:242: error: ‘tris’ undeclared (first use in this function)
dic.c:243: error: ‘player’ undeclared (first use in this function)
dic.c: In function ‘show’:
dic.c:271: error: ‘tris’ undeclared (first use in this function)
dic.c: In function ‘clear’:
dic.c:287: error: ‘curr’ undeclared (first use in this function)
dic.c:292: error: ‘tris’ undeclared (first use in this function)
dic.c: In function ‘main’:
dic.c:308: error: ‘player’ undeclared (first use in this function)
dic.c:330: error: ‘curr’ undeclared (first use in this function)
dic.c:349: error: ‘score1’ undeclared (first use in this function)
dic.c:350: error: ‘losepc’ undeclared (first use in this function)
dic.c:353: error: ‘scorepc’ undeclared (first use in this function)
dic.c:354: error: ‘lose1’ undeclared (first use in this function)
dic.c:356: error: ‘score’ undeclared (first use in this function)
dic.c:360: error: ‘score0’ undeclared (first use in this function)
dic.c:385: error: ‘lose2’ undeclared (first use in this function)
dic.c:390: error: ‘score2’ undeclared (first use in this function)
$

Ahem, what program are you using?
My code works fine to me...
Anyway, I'll write again as soon as I've time to check the game again...
Atm I'm kinda busy^^
User is offlineProfile CardPM
+Quote Post

janotte
RE: Extended Tic Tac Toe AI
1 Dec, 2008 - 09:57 PM
Post #7

code > sword
Group Icon

Joined: 28 Sep, 2006
Posts: 2,137



Thanked: 150 times
Expert In: C/C++

My Contributions
QUOTE(omega18 @ 1 Dec, 2008 - 09:33 AM) *

Ahem, what program are you using?
My code works fine to me...
Anyway, I'll write again as soon as I've time to check the game again...
Atm I'm kinda busy^^


Ahem, hmm *cough* *arggh* *huckhuck* *arrgghhhllle* *ahhhhmmmm* <ROFL>

I'm using GCC to try and compile what you posted.

I'm not suggesting what you posted is what you have at your end. Look at this for a start:
CODE
int WIN=3,i,k,j,l=0,row=3,column=3,tris[ROW][COLUMN& #93;,curr=0,player=0,check,lose1=0,lose2=0,losepc=0,score=0,score0=0,scorepc=0,s


That & #93; is some kind of artifact added in during the cut and past process.

But I haven't got the time or energy to go through looking for all of them so I'll leave it with you for now.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic

Time is now: 7/4/09 04:26PM

Live C++ Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month