hi, i am developing a word game thats played in a board similar to that of connect four. you drop a letter in, and it falls to the bottom. you gain points for every word you make by dropping that letter. the word must be 3=7 letters long to count. the words can be up, down, left right, and diagnally, also in reverse order.
i will be using a list of words in a txt document to compare to the words being claimed.
my questions is... is there an easier way to search the board for created words other than going in and manually testing every possible solution (242 of them) on the board and seeing if the letter you just dropped is included in the word?
my board currently is created as follows
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
|
void creategrid ()
{
for (int i=0; i<=5; i++){
a1 [i]='.';
a2 [i]='.';
a3 [i]='.';
a4 [i]='.';
a4 [i]='.';
a5 [i]='.';
a6 [i]='.';
a7 [i]='.';
}}
void printgrid (){
for (int i=0; i<=5; i++){
cout<<a1 [i]<<a2 [i]<<a3 [i]<<a4 [i]<<a5 [i]<<a6 [i]<<a7 [i]<<endl;
}
cout<<"What column would you like to drop that in? (1-7)"<<endl;
cin>>column;
if (column==1){
a1counter--;
setcount=a1counter;
a1[setcount]=letter;
}
if (column==2){
a2counter--;
setcount=a2counter;
a2[setcount]=letter;
}
if (column==3){
a3counter--;
setcount=a3counter;
a3[setcount]=letter;
}
if (column==4){
a4counter--;
setcount=a4counter;
a4[setcount]=letter;
}
if (column==5){
a5counter--;
setcount=a5counter;
a5[setcount]=letter;
}
if (column==6){
a6counter--;
setcount=a6counter;
a6[setcount]=letter;
}
if (column==7){
a7counter--;
setcount=a7counter;
a7[setcount]=letter;
}
}
| |
but i am thinking this may be easier to deal with if its in one dynamic array like so
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
int main () {
char letter;
char board[6][7];
for (int i=0; i<=5; i++){
for (int j=0; j<=6; j++)
{board [i][j]='.';
}}
for (int i=0; i<=5; i++){
for (int j=0; j<=6; j++){
cout<<board[i][j];}
cout<<endl;}
cout<<"1234567";
cout<<endl<<end;
| |
*i would post the entire code, compilable code up, but its way to long, so i just posted the few pieces that i thought would be needed to give advice.
thanks for any responses, any and all ideas are welcome.. doing it the only way i can think of is going to take forever