Example #1
0
void glttt_callbacks_kb( unsigned char c )
{
	if (globals.game_state==GAMESTATE_IN_GAME || globals.game_state==GAMESTATE_GAME_OVER)
		switch (c)
		{
			case (char)27:
				exit(1);
			case '4':
				globals.rot -= ROTATE_FACTOR;
				break;

			case '6':
				globals.rot += ROTATE_FACTOR;
				break;

			case '8':
				globals.zoom += ZOOM_FACTOR;
				break;

			case '2':
				globals.zoom -= ZOOM_FACTOR;
				if (globals.zoom < MIN_ZOOM)
					globals.zoom=MIN_ZOOM;
				break;

			case 'a': case 'b': case 'c': case 'd':
			case 'e': case 'f': case 'g': case 'h':
				if (globals.human_turn)
					do_turn((int)c - 'a');
				break;
		}
}
void Engine::set_turn( int allegiance ){
	TurnTransitionControl* ttc = new TurnTransitionControl( display, world, allegiance );
	FrameControl* fc = (FrameControl*)(ttc);
	world->add_control( fc, CONTROL_SEQ );

	if( allegiance == 0 ){

	} else if( allegiance == 1 ){
		do_turn( allegiance );
	}
}
Example #3
0
void manager::start(){
	welcome();

	int numplayers;
	cout << "How many players are playing today? (max supported currently is 2): ";
	cin >> numplayers;
	cin.ignore(100, '\n');

	gameplayer = new player * [numplayers];

	for(int i = 0; i < numplayers; ++i){
		char tempname[100];
		cout << "Player " <<i+1 <<", please enter your name: ";
		cin.get(tempname, 100, '\n');
		cin.ignore(100, '\n');
		char * playername = new char[strlen(tempname)+1];
		strcpy(playername, tempname); //now have the players name
		gameplayer[i] = new player;
		gameplayer[i]->add_name(playername); //added their name
		
		
		char tempdeck[100];
		cout << "Player " <<i+1 << ", " << gameplayer[i]->get_name() <<", please enter the your deck file name: " ;
		cin.get(tempdeck, 100, '\n');
		cin.ignore(100, '\n');
		char * deckfile = new char[strlen(tempdeck)+1];
		strcpy(deckfile, tempdeck);
		gameplayer[i]->get_deck()->build_deck(deckfile);
	}
	//now we have a dynamically allocated array of players and their names set
	playercount = numplayers; //set the number of players in the manager class object data
	turn = 1; //1st players turn now
	//call the turn function
	
	while(do_turn() == 0){
		do_turn(); //while you can play, give the other player a turn
	}

}
Example #4
0
void glttt_callback_command_action_stop( int xp, int yp )
{
	switch (globals.game_state)
	{
		case GAMESTATE_IN_GAME:
			if (globals.peg_select_hover == globals.peg_select_down && globals.peg_select_down != PEG_NONE && globals.human_turn)
			{
				do_turn(globals.peg_select_hover);
			}
			break;
	}

	globals.peg_select_down = PEG_NONE;
}
Example #5
0
//int main(int argc, char *argv[]) {
int main()
{
    int action = -1;
    struct game_info Info;
    struct game_state Game;
    struct odor_map odor_map;

    Info.map = 0;
    Game.my_ants = 0;
    Game.enemy_ants = 0;
    Game.my_hives = 0;
    Game.enemy_hives = 0;
    Game.food = 0;
//    Game.dead_ants = 0;

    odor_map.ant_freq = 0;
    odor_map.perma = 0;
//    srand ( time(NULL) );

    while (1) {
        int initial_buffer = 100000;
        char *data = calloc(1, initial_buffer);

        *data = '\n';

        char *ins_data = data + 1;
        int i = 0;

        while (++i) {

            if (i > initial_buffer) {
                initial_buffer *= 2;
                data = realloc(data, initial_buffer);
                memset(ins_data, 0, initial_buffer/2);
            }

            *ins_data = getchar();

            if (*ins_data == '\n') {
                char *backup = ins_data;

                while (*(backup - 1) != '\n') {
                    --backup;
                }

                char *test_cmd = get_line(backup);

                if (strcmp(test_cmd, "go") == 0) {
                    action = 0;
                    free(test_cmd);
                    break;
                }
                else if (strcmp(test_cmd, "ready") == 0) {
                    action = 1;
                    free(test_cmd);
                    break;
                }
                free(test_cmd);
            }

            ++ins_data;
        }

        if (action == 0) {
            char *skip_line = data + 1;
            while (*++skip_line != '\n');
            ++skip_line;

            _init_map(skip_line, &Info, &odor_map);
            _init_game(&Info, &Game);
            do_turn(&Game, &Info, &odor_map);
            fprintf(stdout, "go\n");
            fflush(stdout);
        }
        else if (action == 1) {
            _init_ants(data + 1, &Info);

            Game.my_ant_index = -1;

            fprintf(stdout, "go\n");
            fflush(stdout);
        }

        free(data);
    }
}
Example #6
0
int main(int argc, char *argv[]) {
	int action = -1;

	struct game_info Info;
	struct game_state Game;
	Info.map = 0;

	Game.my_ants = 0;
	Game.enemy_ants = 0;
	Game.food = 0;
	Game.dead_ants = 0;
	Game.hill = 0;

	while (42) {
		int initial_buffer = 100000;

		char *data = malloc(initial_buffer);
		memset(data, 0, initial_buffer);

		*data = '\n';

		char *ins_data = data + 1;

		int i = 0;

		while (1 > 0) {
			++i;

			if (i >= initial_buffer) {
				initial_buffer *= 2;
				data = realloc(data, initial_buffer);
				ins_data = data + i;
				memset(ins_data, 0, initial_buffer - i);
			}

			*ins_data = getchar();

			if (*ins_data == '\n') {
				char *backup = ins_data;

				while (*(backup - 1) != '\n') {
					--backup;
				}

				char *test_cmd = get_line(backup);

				if (strcmp(test_cmd, "go") == 0) {
					action = 0; 
					free(test_cmd);
					break;
				}
				else if (strcmp(test_cmd, "ready") == 0) {
					action = 1;
					free(test_cmd);
					break;
				}
				free(test_cmd);
			}

			++ins_data;
		}

		if (action == 0) {
			char *skip_line = data + 1;
			while (*++skip_line != '\n');
			++skip_line;

			_init_map(skip_line, &Info);
			_init_game(&Info, &Game);
			do_turn(&Game, &Info);
			fprintf(stdout, "go\n");
			fflush(stdout);
		}
		else if (action == 1) {
			_init_ants(data + 1, &Info);

			Game.my_ant_index = -1;

			do_init(&Game, &Info);
			fprintf(stdout, "go\n");
			fflush(stdout);
		}

		free(data);
	}
}
Example #7
0
int main_game_interface() {
    //int lolx=0, loly=0;
    //int city=-1;
    // sanity checks, do take care to see that they are always used whenever unit count changes
    int unitcount, citycount;
    int oldx, oldy;
    
    bool done = false;
    while (!done) {
        unitcount = count_units();
        citycount = count_cities();
        
        SDL_Event event;
        while (SDL_PollEvent(&event))
        {
            // check for messages
            switch (event.type)
            {
                // exit if the window is closed
            case SDL_QUIT:
                done = true;
                break;
                // check for keypresses
                /// BUG: Cursor goes off grid
                /// BUG: Cursor behaves strangely in relation to viewscreen around edges
            case SDL_KEYDOWN:
                {
                    if (event.key.keysym.sym == SDLK_LEFT || event.key.keysym.sym == SDLK_KP4) {
                        if (gs.selected_type == SELECTED_UNIT && gs.selected_thing >= 0) {
                            oldx = gs.units[gs.selected_thing].x;
                            gs.units[gs.selected_thing].x--; 
                            if (!sanitize_unit_coords(gs.selected_thing) && gs.units[gs.selected_thing].curmove > 0 && is_unit_allowed_there(gs.selected_thing)) { 
                                gs.units[gs.selected_thing].curmove--;
                                gs.curx = gs.units[gs.selected_thing].x-5;
                                gs.cury = gs.units[gs.selected_thing].y-3;
                                gs.selx = gs.units[gs.selected_thing].x;
                                gs.sely = gs.units[gs.selected_thing].y;
                                // combat here
                                detect_and_do_combat(gs.selected_thing);
                            } else {
                                gs.units[gs.selected_thing].x = oldx; 
                            }
                        } else {
                            gs.curx--; 
                            gs.selx--;
                        }
                        sanitize_coords();
                        print_map(gs.curx,gs.cury);
                        break;
                    }
                    if (event.key.keysym.sym == SDLK_RIGHT || event.key.keysym.sym == SDLK_KP6) {
                        if (gs.selected_type == SELECTED_UNIT && gs.selected_thing >= 0) {
                            oldx = gs.units[gs.selected_thing].x;
                            gs.units[gs.selected_thing].x++; 
                            if (!sanitize_unit_coords(gs.selected_thing) && gs.units[gs.selected_thing].curmove > 0 && is_unit_allowed_there(gs.selected_thing)) { 
                                gs.units[gs.selected_thing].curmove--;
                                gs.curx = gs.units[gs.selected_thing].x-5;
                                gs.cury = gs.units[gs.selected_thing].y-3;
                                gs.selx = gs.units[gs.selected_thing].x;
                                gs.sely = gs.units[gs.selected_thing].y;
                                // combat here
                                detect_and_do_combat(gs.selected_thing);
                            } else {
                                gs.units[gs.selected_thing].x = oldx; 
                            }
                        } else {
                            gs.curx++; 
                            gs.selx++;
                        }
                        sanitize_coords();
                        print_map(gs.curx,gs.cury);
                        break;
                    }
                    if (event.key.keysym.sym == SDLK_UP || event.key.keysym.sym == SDLK_KP8) {
                        if (gs.selected_type == SELECTED_UNIT && gs.selected_thing >= 0) {
                            oldy = gs.units[gs.selected_thing].y;
                            gs.units[gs.selected_thing].y--; 
                            if (!sanitize_unit_coords(gs.selected_thing) && gs.units[gs.selected_thing].curmove > 0 && is_unit_allowed_there(gs.selected_thing)) { 
                                gs.units[gs.selected_thing].curmove--;
                                gs.curx = gs.units[gs.selected_thing].x-5;
                                gs.cury = gs.units[gs.selected_thing].y-3;
                                gs.selx = gs.units[gs.selected_thing].x;
                                gs.sely = gs.units[gs.selected_thing].y;
                                // combat here
                                detect_and_do_combat(gs.selected_thing);
                            } else {
                                gs.units[gs.selected_thing].y = oldy; 
                            }
                        } else {
                            gs.cury--; 
                            gs.sely--;
                        }
                        sanitize_coords();
                        print_map(gs.curx,gs.cury);
                        break;
                    }
                    if (event.key.keysym.sym == SDLK_DOWN || event.key.keysym.sym == SDLK_KP2) {
                        if (gs.selected_type == SELECTED_UNIT && gs.selected_thing >= 0) {
                            oldy = gs.units[gs.selected_thing].y;
                            gs.units[gs.selected_thing].y++; 
                            if (!sanitize_unit_coords(gs.selected_thing) && gs.units[gs.selected_thing].curmove > 0 && is_unit_allowed_there(gs.selected_thing)) { 
                                gs.units[gs.selected_thing].curmove--;
                                gs.curx = gs.units[gs.selected_thing].x-5;
                                gs.cury = gs.units[gs.selected_thing].y-3;
                                gs.selx = gs.units[gs.selected_thing].x;
                                gs.sely = gs.units[gs.selected_thing].y;
                                // combat here
                                detect_and_do_combat(gs.selected_thing);
                            } else {
                                gs.units[gs.selected_thing].y = oldy; 
                            }
                        } else {
                            gs.cury++; 
                            gs.sely++;
                        }
                        sanitize_coords();
                        print_map(gs.curx,gs.cury);
                        break;
                    }
                    if (event.key.keysym.sym == SDLK_KP7) { // up-left
                        if (gs.selected_type == SELECTED_UNIT && gs.selected_thing >= 0) {
                            oldx = gs.units[gs.selected_thing].x;
                            oldy = gs.units[gs.selected_thing].y;
                            gs.units[gs.selected_thing].x--; 
                            gs.units[gs.selected_thing].y--;
                            if (!sanitize_unit_coords(gs.selected_thing) && gs.units[gs.selected_thing].curmove > 0 && is_unit_allowed_there(gs.selected_thing)) { 
                                gs.units[gs.selected_thing].curmove--;
                                gs.curx = gs.units[gs.selected_thing].x-5;
                                gs.cury = gs.units[gs.selected_thing].y-3;
                                gs.selx = gs.units[gs.selected_thing].x;
                                gs.sely = gs.units[gs.selected_thing].y;
                                // combat here
                                detect_and_do_combat(gs.selected_thing);
                            } else {
                                gs.units[gs.selected_thing].x = oldx; 
                                gs.units[gs.selected_thing].y = oldy; 
                            }
                        } else {
                            gs.curx--; 
                            gs.cury--;
                            gs.selx--;
                            gs.sely--;
                        }
                        sanitize_coords();
                        print_map(gs.curx,gs.cury);
                        break;
                    }
                    if (event.key.keysym.sym == SDLK_KP9) { // up-right
                        if (gs.selected_type == SELECTED_UNIT && gs.selected_thing >= 0) {
                            oldx = gs.units[gs.selected_thing].x;
                            oldy = gs.units[gs.selected_thing].y;
                            gs.units[gs.selected_thing].x++; 
                            gs.units[gs.selected_thing].y--;
                            if (!sanitize_unit_coords(gs.selected_thing) && gs.units[gs.selected_thing].curmove > 0 && is_unit_allowed_there(gs.selected_thing)) { 
                                gs.units[gs.selected_thing].curmove--;
                                gs.curx = gs.units[gs.selected_thing].x-5;
                                gs.cury = gs.units[gs.selected_thing].y-3;
                                gs.selx = gs.units[gs.selected_thing].x;
                                gs.sely = gs.units[gs.selected_thing].y;
                                // combat here
                                detect_and_do_combat(gs.selected_thing);
                            } else {
                                gs.units[gs.selected_thing].x = oldx; 
                                gs.units[gs.selected_thing].y = oldy; 
                            }
                        } else {
                            gs.curx++; 
                            gs.cury--;
                            gs.selx++;
                            gs.sely--;
                        }
                        sanitize_coords();
                        print_map(gs.curx,gs.cury);
                        break;
                    }
                    if (event.key.keysym.sym == SDLK_KP1) { // down-left
                        if (gs.selected_type == SELECTED_UNIT && gs.selected_thing >= 0) {
                            oldx = gs.units[gs.selected_thing].x;
                            oldy = gs.units[gs.selected_thing].y;
                            gs.units[gs.selected_thing].x--; 
                            gs.units[gs.selected_thing].y++;
                            if (!sanitize_unit_coords(gs.selected_thing) && gs.units[gs.selected_thing].curmove > 0 && is_unit_allowed_there(gs.selected_thing)) { 
                                gs.units[gs.selected_thing].curmove--;
                                gs.curx = gs.units[gs.selected_thing].x-5;
                                gs.cury = gs.units[gs.selected_thing].y-3;
                                gs.selx = gs.units[gs.selected_thing].x;
                                gs.sely = gs.units[gs.selected_thing].y;
                                // combat here
                                detect_and_do_combat(gs.selected_thing);
                            } else {
                                gs.units[gs.selected_thing].x = oldx; 
                                gs.units[gs.selected_thing].y = oldy; 
                            }
                        } else {
                            gs.curx--; 
                            gs.cury++;
                            gs.selx--;
                            gs.sely++;
                        }
                        sanitize_coords();
                        print_map(gs.curx,gs.cury);
                        break;
                    }
                    if (event.key.keysym.sym == SDLK_KP3) { // down-right
                        if (gs.selected_type == SELECTED_UNIT && gs.selected_thing >= 0) {
                            oldx = gs.units[gs.selected_thing].x;
                            oldy = gs.units[gs.selected_thing].y;
                            gs.units[gs.selected_thing].x++; 
                            gs.units[gs.selected_thing].y++;
                            if (!sanitize_unit_coords(gs.selected_thing) && gs.units[gs.selected_thing].curmove > 0 && is_unit_allowed_there(gs.selected_thing)) { 
                                gs.units[gs.selected_thing].curmove--;
                                gs.curx = gs.units[gs.selected_thing].x-5;
                                gs.cury = gs.units[gs.selected_thing].y-3;
                                gs.selx = gs.units[gs.selected_thing].x;
                                gs.sely = gs.units[gs.selected_thing].y;
                                // combat here
                                detect_and_do_combat(gs.selected_thing);
                            } else {
                                gs.units[gs.selected_thing].x = oldx; 
                                gs.units[gs.selected_thing].y = oldy; 
                            }
                        } else {
                            gs.curx++; 
                            gs.cury++;
                            gs.selx++;
                            gs.sely++;
                        }
                        sanitize_coords();
                        print_map(gs.curx,gs.cury);
                        break;
                    }
                    if (event.key.keysym.sym == SDLK_c) { // cycle city
                        // find the next extant city
                        // sanity check for now, redo later
                        if (gs.selected_type == SELECTED_UNIT || gs.selected_type == -1 || gs.selected_thing == -1) { 
                            gs.selected_type = SELECTED_CITY;
                            gs.selected_thing = -1;
                        }
                        if (citycount == 0) break;
                        do {
                            gs.selected_thing++;
                            if (gs.selected_thing >= MAX_CITIES) gs.selected_thing = 0;
                            gs.curx = gs.cities[gs.selected_thing].x;
                            gs.cury = gs.cities[gs.selected_thing].y;
                            gs.selx = gs.cities[gs.selected_thing].x;
                            gs.sely = gs.cities[gs.selected_thing].y;
                        } while (gs.cities[gs.selected_thing].size < 1 || gs.cities[gs.selected_thing].faction_id != gs.player_faction);
                        gs.curx -= 5; gs.cury -= 3;
                        sanitize_coords();
                        print_map(gs.curx,gs.cury);
                        break;
                    }
                    if (event.key.keysym.sym == SDLK_u) { // cycle unit
                        // find the next extant unit
                        // sanity check for now, redo later
                        if (gs.selected_type == SELECTED_CITY || gs.selected_type == -1 || gs.selected_thing == -1) { 
                            gs.selected_type = SELECTED_UNIT;
                            gs.selected_thing = -1;
                        }
                        if (unitcount == 0) break; // no active units, go away
                        // finds the closest active unit and centers on it
                        do {
                            gs.selected_thing++;
                            if (gs.selected_thing >= MAX_UNITS) gs.selected_thing = 0;
                            gs.curx = gs.units[gs.selected_thing].x;
                            gs.cury = gs.units[gs.selected_thing].y;
                            gs.selx = gs.units[gs.selected_thing].x;
                            gs.sely = gs.units[gs.selected_thing].y;
                        } while (gs.units[gs.selected_thing].active == UNIT_INACTIVE);
                        gs.curx -= 5; gs.cury -= 3;
                        sanitize_coords();
                        print_map(gs.curx,gs.cury);
                        break;
                    }
                    // Build city command!
                    if (event.key.keysym.sym == SDLK_b) {
                        // make sure a unit is actually selected and can build
                        if (gs.selected_type != SELECTED_UNIT) break; // no unit selected
                        if (gs.selected_thing == -1) break; // nothing selected
                        if ((gs.units[gs.selected_thing].flags&UNIT_FLAG_SETTLER) == 0) break; // unit can't build
                        /// TODO: Checks for if there is a city too close
                        gs.units[gs.selected_thing].hp = 0; // kill the unit
                        // build the city
                        build_new_city(gs.units[gs.selected_thing].x,gs.units[gs.selected_thing].y,gs.units[gs.selected_thing].faction_id);
                        break;
                    }
                    if (event.key.keysym.sym == SDLK_p) { // production
                        if (gs.selected_type != SELECTED_CITY) break; // no city selected
                        if (gs.selected_thing == -1) break; // nothing selected
                        
                        // placeholder code until I can think of something better
                        // toggles production of random unit
                        if (gs.cities[gs.selected_thing].production_order == CITY_NO_PRODUCTION) {
                            gs.cities[gs.selected_thing].production_order = rand()%65536; // fix this later, should be a parameter or something
                            gs.cities[gs.selected_thing].production_type = rand()%3+1; // random type
                        } else {
                            gs.cities[gs.selected_thing].production_order = CITY_NO_PRODUCTION;
                        }
                        
                        
                    }
                    if (event.key.keysym.sym == SDLK_s) { // save
                        return CODE_SAVE_GAME;
                    } 
                    if (event.key.keysym.sym == SDLK_ESCAPE) { // quit
                        return CODE_MAIN_MENU;
                    }
                    if (event.key.keysym.sym == SDLK_BACKSPACE) { // turn
                        // end turn hack
                        do_turn();
                        break;
                    }
                }
            } // end switch
        } // end of message processing
        
        print_map(gs.curx,gs.cury);
        print_interface();
        
        SDL_Flip(MAIN_SCREEN);
        SDL_Delay(100);
    }
    
    return 0;
}
Example #8
0
int main()
{
	struct Game *game = malloc(sizeof(struct Game));
	char buf[BUFSIZ];
	char *index;
	char *arg[4];
	int arg_num;

	while (fgets(buf, sizeof(buf), stdin) != NULL) {
		index = buf;
		arg_num = 0;
		arg[arg_num] = index;
		for (;(*index != '\n'); index++) {
			if (*index == ' ') {
				*index = '\0';
				arg[arg_num+1] = index+1;
				arg_num++;
			}
		}
		*index = '\0';

		if (!strcmp(arg[0], "turn")) {
			game->turn = atoi(arg[1]);
			fprintf(stderr, "Got turn %d\n", game->turn);
			if (game->turn) {
				game->state = INGAME;
				do_preturn(game);
			} else {
				game->state = SETUP;
			}
		} else if (!strcmp(arg[0], "end")) {
			break;
		}

		if (game->state == SETUP) {
			if (!strcmp(arg[0], "loadtime")) {
				game->loadtime = atoi(arg[1]);
			} else if (!strcmp(arg[0], "turntime")) {
				game->turntime = atoi(arg[1]);
			} else if (!strcmp(arg[0], "rows")) {
				game->rows = atoi(arg[1]);
			} else if (!strcmp(arg[0], "cols")) {
				game->cols = atoi(arg[1]);
			} else if (!strcmp(arg[0], "turns")) {
				game->turns = atoi(arg[1]);
			} else if (!strcmp(arg[0], "viewradius2")) {
				game->viewradius2 = atoi(arg[1]);
			} else if (!strcmp(arg[0], "attackradius2")) {
				game->attackradius2 = atoi(arg[1]);
			} else if (!strcmp(arg[0], "spawnradius2")) {
				game->spawnradius2 = atoi(arg[1]);
			} else if (!strcmp(arg[0], "player_seed")) {
				game->player_seed = atoi(arg[1]);
			} else if (!strcmp(arg[0], "ready")) {
				do_setup(game);
				fprintf(stdout, "go\n");
				fflush(NULL);
			}
		} else {
			int row,col,owner;
			switch (*arg[0]) {
				case 'w':
					row = atoi(arg[1]);
					col = atoi(arg[2]);
					game->watermap[loc(row,col)] = 1;
					break;
				case 'f':
					row = atoi(arg[1]);
					col = atoi(arg[2]);
					game->foodmap[loc(row,col)] = 1;
					break;
				case 'h':
					row = atoi(arg[1]);
					col = atoi(arg[2]);
					owner = atoi(arg[3]);
					game->hillmap[loc(row,col)] = owner+1;
					break;
				case 'a':
					row = atoi(arg[1]);
					col = atoi(arg[2]);
					owner = atoi(arg[3]);
					game->antmap[loc(row,col)] = owner+1;
					break;
				case 'd':
					// Dead ants, meh
					break;
			}
			if (!strcmp(arg[0], "go")) {
				do_turn(game);
				fprintf(stdout, "go\n");
				fflush(NULL);
			}
		}
	}
	do_cleanup(game);
	return 0;
}
Example #9
0
File: MyBot.c Project: bol/Ants
int main() {
    int action = -1;

    Info = calloc(1, sizeof(struct game_info));
    Game = calloc(1, sizeof(struct game_state));
    Game->map = 0;

    Game->my_ants = 0;
    Game->enemy_ants = 0;
    Game->food = 0;
    Game->dead_ants = 0;

#ifdef DEBUG
	init_log();
#endif

    while (42) {
        int initial_buffer = 100000;

        char *data = malloc(initial_buffer);
        memset(data, 0, initial_buffer);

        *data = '\n';

        char *ins_data = data + 1;

        int i = 0;

        while (1 > 0) {
            ++i;

            if (i > initial_buffer) {
                initial_buffer *= 2;
                data = realloc(data, initial_buffer);
                memset(ins_data, 0, initial_buffer/2);
            }

            *ins_data = getchar();

            if (*ins_data == '\n') {
                char *backup = ins_data;

                while (*(backup - 1) != '\n') {
                    --backup;
                }

                char *test_cmd = get_line(backup);

                if (strcmp(test_cmd, "go") == 0) {
                    action = 0; 
                    free(test_cmd);
                    break;
                }
                else if (strcmp(test_cmd, "ready") == 0) {
                    action = 1;
                    free(test_cmd);
                    break;
                }
                free(test_cmd);
            }
            
            ++ins_data;
        }

        if (action == 0) {
			Log("Playing turn %d\n", Game->turn);
            char *skip_line = data + 1;
            while (*++skip_line != '\n');
            ++skip_line;

			init_lists();
            _init_map(skip_line);
            do_turn();
            fprintf(stdout, "go\n");
            fflush(stdout);
        }
        else if (action == 1) {
			Log("Read game start data\n");
            _init_ants(data + 1);
            Game->my_ant_index = -1;
			Log("Initializing memory\n");
			allocate_map();
			allocate_lists();
			Game->turn = 1;
			Log("Ready to play, signaling engine\n");
            fprintf(stdout, "go\n");
            fflush(stdout);
        }

        free(data);
    }
}