本文整理匯總了Python中glfw.KEY_N屬性的典型用法代碼示例。如果您正苦於以下問題:Python glfw.KEY_N屬性的具體用法?Python glfw.KEY_N怎麽用?Python glfw.KEY_N使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類glfw
的用法示例。
在下文中一共展示了glfw.KEY_N屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: key_callback
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import KEY_N [as 別名]
def key_callback(self, window, key, scancode, action, mods):
super().key_callback(window, key, scancode, action, mods)
# Trigger on keyup only:
if action != glfw.RELEASE:
return
# Increment experiment seed
if key == glfw.KEY_N:
self.reset_increment()
# Decrement experiment trial
elif key == glfw.KEY_P:
print("Pressed P")
self.seed = max(self.seed - 1, 0)
self.env.seed(self.seed)
self.ob = self.env.reset()
for policy in self.policies:
policy.reset()
if hasattr(self.env, "reset_goal"):
self.goal = self.env.reset_goal()
self.update_sim(self.env.unwrapped.sim)
示例2: key_callback
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import KEY_N [as 別名]
def key_callback(self, window, key, scancode, action, mods):
# Trigger on keyup only:
if action != glfw.RELEASE:
return
if key == glfw.KEY_ESCAPE:
self.env.close()
# Increment experiment seed
elif key == glfw.KEY_N:
self.seed[0] += 1
self.env.seed(self.seed)
self.env_reset()
self.action = self.zero_action(self.env.action_space)
# Decrement experiment trial
elif key == glfw.KEY_P:
self.seed = [max(self.seed[0] - 1, 0)]
self.env.seed(self.seed)
self.env_reset()
self.action = self.zero_action(self.env.action_space)
if key == glfw.KEY_A:
if isinstance(self.env.action_space, Box):
self.action[self.action_mod_index] -= 0.05
elif key == glfw.KEY_Z:
if isinstance(self.env.action_space, Box):
self.action[self.action_mod_index] += 0.05
elif key == glfw.KEY_K:
self.action_mod_index = (self.action_mod_index + 1) % self.num_action
elif key == glfw.KEY_J:
self.action_mod_index = (self.action_mod_index - 1) % self.num_action
super().key_callback(window, key, scancode, action, mods)
示例3: keyboard_callback
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import KEY_N [as 別名]
def keyboard_callback(self, window, key, scancode, action, mods):
self.impl.keyboard_callback(window, key, scancode, action, mods)
if not imgui.get_io().want_capture_keyboard:
if key == glfw.KEY_B or key == glfw.KEY_LEFT:
self.currentTimestep = self.sliderValue = max(0, self.currentTimestep - 1)
if key == glfw.KEY_N or key == glfw.KEY_RIGHT:
self.currentTimestep = self.sliderValue = min(self.num_scans - 1, self.currentTimestep + 1)
if key == glfw.KEY_Q or key == glfw.KEY_ESCAPE:
exit(0)
示例4: key_callback
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import KEY_N [as 別名]
def key_callback(self, window, key, scancode, action, mods):
# Trigger on keyup only:
if action != glfw.RELEASE:
return
if key == glfw.KEY_ESCAPE:
self.env.close()
# Increment experiment seed
elif key == glfw.KEY_N:
self.seed[0] += 1
self.env.seed(self.seed)
self.env_reset()
self.action = self.zero_action(self.env.action_space)
# Decrement experiment trial
elif key == glfw.KEY_P:
self.seed = [max(self.seed[0] - 1, 0)]
self.env.seed(self.seed)
self.env_reset()
self.action = self.zero_action(self.env.action_space)
current_action_space = self.env.action_space.spaces[self.action_types[self.action_type_mod_index]].spaces[0]
if key == glfw.KEY_A:
if isinstance(current_action_space, Box):
self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] -= 0.05
elif isinstance(current_action_space, Discrete):
self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index] = \
(self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index] - 1) % current_action_space.n
elif isinstance(current_action_space, MultiDiscrete):
self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] = \
(self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] - 1) \
% current_action_space.nvec[self.action_mod_index]
elif key == glfw.KEY_Z:
if isinstance(current_action_space, Box):
self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] += 0.05
elif isinstance(current_action_space, Discrete):
self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index] = \
(self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index] + 1) % current_action_space.n
elif isinstance(current_action_space, MultiDiscrete):
self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] = \
(self.action[self.action_types[self.action_type_mod_index]][self.agent_mod_index][self.action_mod_index] + 1) \
% current_action_space.nvec[self.action_mod_index]
elif key == glfw.KEY_K:
self.action_mod_index = (self.action_mod_index + 1) % self.num_action[self.action_type_mod_index]
elif key == glfw.KEY_J:
self.action_mod_index = (self.action_mod_index - 1) % self.num_action[self.action_type_mod_index]
elif key == glfw.KEY_Y:
self.agent_mod_index = (self.agent_mod_index + 1) % self.n_agents
elif key == glfw.KEY_U:
self.agent_mod_index = (self.agent_mod_index - 1) % self.n_agents
elif key == glfw.KEY_G:
self.action_type_mod_index = (self.action_type_mod_index + 1) % self.num_action_types
self.action_mod_index = 0
elif key == glfw.KEY_B:
self.action_type_mod_index = (self.action_type_mod_index - 1) % self.num_action_types
self.action_mod_index = 0
super().key_callback(window, key, scancode, action, mods)