Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Ant::update( GameState* state ) {
- enemiesinsight = 0;
- foodinsight = 0;
- friendsinsight = 0;
- std::queue<Location> locqueue;
- Location cloc, nloc;
- std::vector<std::vector<bool> > visited(state->rows, std::vector<bool>( state->cols, 0 ));
- locqueue.push(loc);
- state->map[loc.row][loc.col].flags |= S_VISIBLE_BIT;
- visited[loc.row][loc.col] = 1;
- while( !locqueue.empty() ) {
- cloc = locqueue.front();
- locqueue.pop();
- for ( int d = 0; d < TDIRECTIONS; ++d ) {
- nloc = getloc( cloc, d );
- if (!visited[nloc.row][nloc.col] && GameState::distance2(loc, nloc) <= state->viewrange) {
- locqueue.push(nloc);
- }
- }
- state->map[cloc.row][cloc.col].flags |= S_VISIBLE_BIT;
- if ( state->map[cloc.row][cloc.col].ant > 0 ) enemiesinsight++;
- if ( state->map[cloc.row][cloc.col].flags & S_FOOD_BIT ) foodinsight++;
- if ( state->map[cloc.row][cloc.col].ant == 0 ) friendsinsight++;
- visited[cloc.row][cloc.col] = 1;
- }
- }
Add Comment
Please, Sign In to add comment