Review: Approve

LGTM - just 1 nit for a comment. Please merge once it's fixed :)

Diff comments:

> 
> === modified file 'src/ai/defaultai.cc'
> --- src/ai/defaultai.cc       2018-04-02 08:44:26 +0000
> +++ src/ai/defaultai.cc       2018-04-06 10:10:52 +0000
> @@ -1471,10 +1471,23 @@
>               }
>       }
>  
> -     // counting fields with fish
> -     if (field.water_nearby > 0 && (field.fish_nearby == kUncalculated || 
> resource_count_now)) {
> -             field.fish_nearby = map.find_fields(Area<FCoords>(field.coords, 
> kProductionArea), nullptr,
> -                                                 
> FindNodeResource(world.get_resource("fish")));
> +     // counting fields with fish, doing it roughly every 10-th minute is 
> enough
> +     if (field.water_nearby > 0 && (field.fish_nearby == kUncalculated || 
> (resource_count_now && gametime % 10 == 0))) {
> +             CheckStepWalkOn fisher_cstep(MOVECAPS_WALK, true);
> +             static std::vector<Coords> fish_fields_list; // pity this 
> contains duplicities

duplicities -> duplicates

> +             fish_fields_list.clear();
> +             map.find_reachable_fields(Area<FCoords>(field.coords, 
> kProductionArea),
> +                     &fish_fields_list, fisher_cstep, 
> FindNodeResource(world.get_resource("fish")));
> +
> +             // This is "list" of unique fields in fish_fields_list we got 
> above
> +             static std::set<Coords> counted_fields;
> +             counted_fields.clear();
> +             field.fish_nearby = 0;
> +             for (auto fish_coords : fish_fields_list) {
> +                     if (counted_fields.insert(fish_coords).second) {
> +                             field.fish_nearby += 
> map.get_fcoords(fish_coords).field->get_resources_amount();
> +                     }
> +             }
>       }
>  
>       // Counting resources that do not change fast


-- 
https://code.launchpad.net/~widelands-dev/widelands/ai_fisher_fix/+merge/342427
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/ai_fisher_fix.

_______________________________________________
Mailing list: https://launchpad.net/~widelands-dev
Post to     : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to