From: Christian Heller Date: Fri, 25 Jan 2019 02:44:35 +0000 (+0100) Subject: Fix FOV floating point bugs by using fractions.Fraction for fractions. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7B%20web_path%20%7D%7D/static/todo?a=commitdiff_plain;h=8ddccb6e5601f8df54f9cbc4c376ad76aee2fe78;p=plomrogue2-experiments Fix FOV floating point bugs by using fractions.Fraction for fractions. --- diff --git a/server_/map_.py b/server_/map_.py index 6e14c5a..291130c 100644 --- a/server_/map_.py +++ b/server_/map_.py @@ -2,6 +2,7 @@ import sys sys.path.append('../') import game_common import server_.game +import fractions class Map(game_common.Map): @@ -170,7 +171,7 @@ class MapFovHex(MapHex): self.shadow_cones += [cone] #print('DEBUG', yx) - step_size = (CIRCLE/6)/distance_to_center + step_size = fractions.Fraction(CIRCLE, 6) / distance_to_center number_steps = dir_i * distance_to_center + dir_progress left_arm = correct_arm(-(step_size/2) - step_size*number_steps) right_arm = correct_arm(left_arm - step_size) @@ -288,7 +289,7 @@ class MapFovSquare(MapSquare): self.shadow_cones += [cone] #print('DEBUG', yx) - step_size = (CIRCLE/4)/distance_to_center + step_size = fractions.Fraction(CIRCLE, 4) / distance_to_center number_steps = dir_i * distance_to_center + dir_progress left_arm = correct_arm(-(step_size/2) - step_size*number_steps) right_arm = correct_arm(left_arm - step_size)