problem with checking fields in a board

Hi, I've already written here about my 6x6 board. I have a code like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <windows.h>

using namespace std;
const int MAX_WIERSZ = 6;
const int MAX_KOLUMNA = 6;

void inicjuj_plansze(char **plansza);
void rysuj_plansze(char **plansza);
void wybierz_pole1(int *numer_wiersza, int *numer_kolumny);
void rysuj_kamien(char **plansza, int *numer_wiersza, int *numer_kolumny);
bool sprawdzenie_miejsca (char **plansza);


void inicjuj_plansze(char **plansza)
{ for(int i = 0; i < MAX_WIERSZ; i++)  {
        for(int j = 0; j < MAX_KOLUMNA; j++)
             plansza[i][j] = ' ';
        
    }
}
void rysuj_plansze(char **plansza)
{ for( int i = 0; i < MAX_WIERSZ; i++ )
    {
        cout << " +-----+-----+-----+-----+-----+-----+" << endl;
        cout << i + 1 << "|";
        for( int j = 0; j < MAX_KOLUMNA; j++ )
        if( plansza[ i ][ j ] == '#' )
             cout << " ### |";
        else
             cout << "     |";
        
        cout << endl;
        cout << " |";
        for( int j = 0; j < MAX_KOLUMNA; j++ )
        if( plansza[ i ][ j ] == '#' )
             cout << " ### |";
        else
             cout << "     |";
        
        cout << endl;
    }
    cout << " +-----+-----+-----+-----+-----+-----+" << endl;
    cout << "    A     B     C     D     E     F   " << endl;
    cout << endl;
}
void wybierz_pole1(int *numer_wiersza, int *numer_kolumny)
{
    char litera;
    cout << "podaj wiersz: ";
    cin >> * numer_wiersza;
    cout << "podaj kolumne (A=1, B=2, C=3, D=4, E=5, F=6): ";
    cin >> * numer_kolumny;
    if(*numer_kolumny == 1)
    {
        litera = 'A';
    }
    if(*numer_kolumny == 2)
    {
        litera = 'B';
    }
    if(*numer_kolumny == 3)
    {
        litera = 'C';
    }
    if(*numer_kolumny == 4 )
    {
        litera = 'D';
    }
    if(*numer_kolumny == 5 )
    {
        litera = 'E';
    }
    if(*numer_kolumny == 6 )
    {
        litera = 'F';
    }
  
    if(*numer_wiersza >= 1 && *numer_wiersza <= MAX_WIERSZ && *numer_kolumny >= 1 && *numer_kolumny <= MAX_KOLUMNA ){
         cout << "wybrane pole to: " << *numer_wiersza << litera << endl << endl << endl;
         Sleep(1000);}
        
    else{
         cout << "takie pole nie istnieje, podaj inne pole: "<<endl << endl << endl;
         Sleep(1000);}
   
}

void rysuj_kamien(char **plansza, int *numer_wiersza, int *numer_kolumny)
{
    if(*numer_wiersza >= 1 and *numer_wiersza <= MAX_WIERSZ and *numer_kolumny >= 1 and *numer_kolumny <= MAX_KOLUMNA )
         plansza[*numer_wiersza - 1][*numer_kolumny - 1] = '#';
    
    cout << plansza[MAX_WIERSZ - 1][MAX_KOLUMNA - 1];
}
bool sprawdzenie_miejsca (char **plansza)
{  for (int i=0; i<MAX_WIERSZ; i++) 
   { for( int j=0; j<MAX_KOLUMNA; j++)
      {  if (plansza[i][j] == ' ')
             return false;  // No point in checking further
      }          
    } 
    return true;  // No spaces found
}




int main()
{
    char **plansza = new char *[MAX_WIERSZ]; //alokacja pamięci dla tablicy dynamicznej
    for(int i = 0; i < MAX_WIERSZ; i++)
         plansza[i] = new char[MAX_KOLUMNA];
    
    int *numer_wiersza = new int;
    int *numer_kolumny = new int;
    
    inicjuj_plansze(plansza);
    for(int i = 0; i < 36; i++)
    {
        cout << endl;
        rysuj_plansze(plansza);
        wybierz_pole1(numer_wiersza, numer_kolumny);
        sprawdzenie_miejsca(plansza);
        rysuj_kamien(plansza, numer_wiersza, numer_kolumny);
        system("cls");    
    } 
    
    system("pause");
    return 0;
}



I have a problem in function "bool sprawdzenie_miejsca()". How can I select, that I want to make cout <<"this field is full"? I want to ephasize, that when player types the field like "A4" and this field is full, he will see "this field is full". How can i do this?
Second of my problem is that one of the two players must be a computer player and plays randomly. I must say that players make them moves in turns. Could You help me? :)
if(table[letter][number]==' ')cout<<"field full";

Use for loop andd modulo operator
like
1
2
3
4
(i=2;plyrwin==true||comwin==true;i++){
   if(i%2==0) //playerturn
   else //comturn
}
Topic archived. No new replies allowed.