I'm trying to create a reverse 4x3 tick tac toe game using depth and first use of minimax . Some different things are wrong in my code, but only of them are making proper nodes for the tree.
Each of my nodes contains an array called Balves, which considers the minimum value for each child and a 4x3 array that holds the board.
I have a variable which is how many children are in the current node, which is called elderly, and I am trying to use it to create separate boards for each of my children Here's my code for creating a board in the child's node:
int openSpace = 0; // (How much open space (int i = 0; i ; Board [i] [J] == 'X' || Child-> Board [i] [J] == 'O') {// Go to the next position} and {if (Open Space == Hair New) {if (node-> gtmove) {Child-> Board [i] [j] = 'x';} and {hair-> board [i] [j] = 'o';} breakage;} And {openSpace ++;}} if (openspace == child new) {brake;}}}
My idea was for the number of children, it was all different children To make Many more will leave the vacant place. Now I get the baby after getting it first:
| X || || || x || || || | x || | || x || || ||
when I really wanted it:
| x || || || || || || || | | || || || || || || || ||
I know it can be easy and I'm sorry to feel so dense, but any help would be greatly appreciated! Thanks!
break
will be broken only by the nearest loop, both of you will be broken An extra break
may be required to break out of the form (if I understand your goal correctly).
Try it, maybe:
for (int i = 0; i <4; i ++) {for (int j = 0; j & Lt; 3; j ++) {if-> child-> board [i] [j] == 'x' || child - & gt; board [i] [j] == 'o') {// Go to the next place} and {if (openspace == hair new) {if (node-> gtmove) {child-> board [i] [j] = 'x'; } And {hair-> board [i] [j] = 'hey'; } break; } And {openSpace ++; }} If (OpenSpace == Children New) {Break; // breaks only with internal loop}} if (openspace == child new) {break; // external loop}}
No comments:
Post a Comment