I have a game board for printing with ASCII, which, I hope, by the end looks something like this.
___ 3 ___/ 1 \___ ___ ___/ 2 \___/ 2 \/ 3 \ 2 / 1 \___/ 3 \___/\___/___ \___/ 2 \___/ / 2 \ 1 / 1 \___/ 1 \___ \___/ \___/ 2 \___/ 2 \ 0 \___/ \___/ 1 2 3 4
The map is distributed along the x and y axis, the size of the map is also fixed. The numbers to be printed are stored in the 2d array. Some of them may also be empty, as shown above. Here is what I tried to do. map-> sizeX and map-> sizeY gives the x-axis and y-axis sizes of the map. If the number in this block is 0, this means that the block does not exist, and we do not print it. Any help would be greatly appreciated.
void printMap(struct Map *map) { for (int i = 0; i < map->sizeX; ++i) { for (int k = 0; k < map->sizeX && i == 0; ++k) printf(" ___ "); printf("\n"); for (int j = 0; j < map->sizeY; ++j) { if(i == 0) { printf("/ %d \\", giveFloe(map, i, j)->numbOfFish); } else { printf("/ %d \\", giveFloe(map, i, j)->numbOfFish); } } printf("\n"); for (int l = 0; l < map->sizeX; ++l) printf("\\___/"); } printf("\n"); }
This is what I got as output, since I could not print the first line correctly, I did not continue. The card does not exceed 15 x 15, so Iām sure that it can be printed in the terminal window.
___ ___ ___ ___ ___ ___ ___ ___ ___ ___ / 3 \/ 0 \/ 2 \/ 0 \/ 2 \/ 0 \/ 3 \/ 0 \/ 1 \/ 0 \ \___/\___/\___/\___/\___/\___/\___/\___/\___/\___/ / 0 \/ 0 \/ 0 \/ 2 \/ 0 \/ 1 \/ 0 \/ 3 \/ 0 \/ 3 \ \___/\___/\___/\___/\___/\___/\___/\___/\___/\___/ / 2 \/ 0 \/ 3 \/ 0 \/ 3 \/ 0 \/ 3 \/ 0 \/ 1 \/ 0 \ \___/\___/\___/\___/\___/\___/\___/\___/\___/\___/ / 0 \/ 1 \/ 0 \/ 2 \/ 0 \/ 2 \/ 0 \/ 2 \/ 0 \/ 3 \ \___/\___/\___/\___/\___/\___/\___/\___/\___/\___/ / 3 \/ 0 \/ 0 \/ 0 \/ 2 \/ 0 \/ 3 \/ 0 \/ 1 \/ 0 \ \___/\___/\___/\___/\___/\___/\___/\___/\___/\___/ / 0 \/ 3 \/ 0 \/ 2 \/ 0 \/ 1 \/ 0 \/ 3 \/ 0 \/ 1 \ \___/\___/\___/\___/\___/\___/\___/\___/\___/\___/ / 3 \/ 0 \/ 2 \/ 0 \/ 2 \/ 0 \/ 3 \/ 0 \/ 2 \/ 0 \ \___/\___/\___/\___/\___/\___/\___/\___/\___/\___/ / 0 \/ 2 \/ 0 \/ 3 \/ 0 \/ 3 \/ 0 \/ 2 \/ 0 \/ 2 \ \___/\___/\___/\___/\___/\___/\___/\___/\___/\___/ / 3 \/ 0 \/ 2 \/ 0 \/ 3 \/ 0 \/ 3 \/ 0 \/ 2 \/ 0 \ \___/\___/\___/\___/\___/\___/\___/\___/\___/\___/ / 0 \/ 2 \/ 0 \/ 3 \/ 0 \/ 1 \/ 0 \/ 3 \/ 0 \/ 3 \ \___/\___/\___/\___/\___/\___/\___/\___/\___/\___/
This is as far as I can get, it is assumed that the card will not exceed the terminal window. I need the map to look like the hexagons pictured above.
struct Map { struct Floe *mapPointer; int sizeX; int sizeY; struct Box *changelog; int changeCount; int maxChanges; struct Player *players; int playerCount; };
giveFloe() takes a structural map and returns a floe to this coordinate.
struct Floe { int numbOfFish; int whosPenguin; };