From 9b3d413df7248e8096178f0c98dc68e75c9b89b6 Mon Sep 17 00:00:00 2001 From: "Alex J. Champandard" Date: Thu, 14 Jul 2016 19:52:10 +0200 Subject: [PATCH] Copied over missing files. --- animation/bootstrap.py | 26 ++++++++++++++++++++++++++ animation/display.py | 7 +++---- animation/params.py | 10 ++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 animation/bootstrap.py create mode 100644 animation/params.py diff --git a/animation/bootstrap.py b/animation/bootstrap.py new file mode 100644 index 0000000..c8ca95f --- /dev/null +++ b/animation/bootstrap.py @@ -0,0 +1,26 @@ +import os +import sys + +# Setup the path to known locations of GLFW's DLL on Windows +if sys.platform == 'win32': + import platform + bits = platform.architecture()[0][:2] + os.environ['PATH'] += os.pathsep + r'C:\ProgramData\chocolatey\msvc120-{}\bin'.format(bits) + +# Inject support for local font loading into VisPy. +def _get_vispy_font_filename(face, bold, italic): + return os.path.join(os.path.dirname(__file__), 'data/questrial.ttf') + +# Fonts on Mac OSX. +if sys.platform == 'darwin': + from vispy.util.fonts import _quartz + _quartz._vispy_fonts = ('Questrial',) + _quartz._get_vispy_font_filename = _get_vispy_font_filename + del _quartz + +# Fonts on Windows and Linux. +if sys.platform in ['win32', 'linux']: + from vispy.util.fonts import _freetype + _freetype._vispy_fonts = ('Questrial',) + _freetype._get_vispy_font_filename = _get_vispy_font_filename + del _freetype diff --git a/animation/display.py b/animation/display.py index cdcfd99..5b3d3b9 100644 --- a/animation/display.py +++ b/animation/display.py @@ -1,8 +1,7 @@ import os import sys import bootstrap # Demonstration specific setup. -# import scipy.misc # Image loading and manipulation. -import vispy.scene # Canvas & visuals for rendering. +import vispy.scene # Canvas & visuals for rendering. import numpy import collections @@ -24,7 +23,7 @@ class Application(object): - def __init__(self, example_idx, title='nucl.ai16'): #, range=(0,850)): + def __init__(self, example_idx, title='nucl.ai Motion Matching'): #, range=(0,850)): self.canvas = vispy.scene.SceneCanvas( title=title, size=(1280, 720), @@ -64,7 +63,7 @@ def __init__(self, example_idx, title='nucl.ai16'): #, range=(0,850)): self.timer_toggle = True self.player_position = numpy.asarray([0,0]) - self.paths_data = paths_data.PathsData(os.path.join('csv', 'data.csv'), self.params, follow_player=(example_idx == 3), advancing=(example_idx == 3 or example_idx == 2)) + self.paths_data = paths_data.PathsData('dota2.csv', self.params, follow_player=(example_idx == 3), advancing=(example_idx == 3 or example_idx == 2)) # init the searched point with some random value - after first mouse move it's a self.paths_data.mouse_xy = ( ( numpy.random.rand(2) * 10 - 5 ) - numpy.asarray(self.canvas.size) / 2 ) * self.params.SCALE_FACTOR diff --git a/animation/params.py b/animation/params.py new file mode 100644 index 0000000..5fdb566 --- /dev/null +++ b/animation/params.py @@ -0,0 +1,10 @@ +class Params: + SEGMENT_SIZE = 10 + TOP_PATHS_NUMBER = 5 + SAMPLE_SIZE = 150 + SCALE_FACTOR = 200 + TELEPORT_THRESHOLD = 40 # it defines a disatnce where we elimiate a segment - we skip all teleports + + def __init__(self): + self.VECTOR_POINT = int(self.SEGMENT_SIZE / 2) + self.MOVE_ALONG_STEP_SIZE = int(self.SEGMENT_SIZE / 2)