From: Christian Heller Date: Tue, 1 Mar 2016 01:46:36 +0000 (+0100) Subject: Server: Performance optimization in init_score_map(). X-Git-Tag: tce~109 X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/static/%7B%7Bdb.prefix%7D%7D/%27%29;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20chunks.push%28escapeHTML%28span%5B2%5D%29%29;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20chunks.push%28%27?a=commitdiff_plain;h=37026869d919c828452ab1680188c7342d5f02a5;p=plomrogue Server: Performance optimization in init_score_map(). --- diff --git a/server/ai.py b/server/ai.py index 0d1effc..070ecad 100644 --- a/server/ai.py +++ b/server/ai.py @@ -161,9 +161,16 @@ def get_dir_to_target(t, filter): if get_map_score(world_db["Things"][id]["T_POSY"] * maplength + world_db["Things"][id]["T_POSX"])] elif "a" != filter: - [set_map_score_at_thingpos(id, 65535) - for id in world_db["Things"] - if animate_in_fov(world_db["Things"][id], maplength)] + #[set_map_score_at_thingpos(tid, 65535) + # for tid in world_db["Things"] + # if animate_in_fov(world_db["Things"][tid], maplength)] + # ABOVE INLINED FOR PERFORMANCE REASONS BY BLOCK BELOW + for Thing in world_db["Things"].values(): + if Thing["T_LIFEPOINTS"] and not Thing["carried"] and not \ + Thing == t: + pos = Thing["T_POSY"] * maplength + Thing["T_POSX"] + if 118 == t["fovmap"][pos]: + set_map_score(pos, 65535) def rand_target_dir(neighbors, cmp, dirs): candidates = []