I'm recreating a game called "Bubble Blast 2" (found on the Play Store, you can watch it on YT) in C using the ncurses library.
I've already coded the physics of the game and I need a code that will calculate the fewest moves to solve the game.
Everything in the game is saved in a struct and I need to also use it to calculate the moves in the recursive function.
The struct is modified by the game physics as the game goes.
The recursive function must (at least I think) use the same game physics code (that modifies the struct).
So how can I use the struct in the recursion if it gets modified by the game physics?
This is the game struct:
struct game;
typedef struct point {
int x;
int y;
} POINT, *POINT_P;
typedef struct bubble {
POINT point;
int state;
} BUBBLE, *BUBBLE_P;
typedef struct bubbles {
BUBBLE* bubbles;
int length;
int allocated;
} BUBBLES, *BUBBLES_P;
typedef struct projectile {
POINT point;
char direction;
int restoreChar;
int restoreColor;
} PROJECTILE, *PROJECTILE_P;
typedef struct projectiles {
PROJECTILE* projectiles;
int length;
int allocated;
} PROJECTILES, *PROJECTILES_P;
typedef struct game {
BUBBLES bubbles;
PROJECTILES projectiles;
int rows;
int columns;
int selected;
int array[6][5];
int moves;
int minMoves;
bool finished;
bool movesCalc;
} GAME, *GAME_P;
I don't think the rest of the code is needed because it's just the physics of the game and you just need to know that it modifies the struct as the you play the game, but I might be wrong, if you think more code would help tell me and I'll add it as soon as possible.