原图比例如下,很明显实际大小已经超出屏幕显示范围:
参考这篇文章的代码,新定义一个函数:
def get_scaling():user32 = windll.user32# 获取现在的尺寸(缩放后now_width = user32.GetSystemMetrics(0)now_height = user32.GetSystemMetrics(1)# 限制UI缩放user32.SetProcessDPIAware()# 获取屏幕真实的尺寸origin_width = user32.GetSystemMetrics(0)origin_height = user32.GetSystemMetrics(1)# 计算缩放比例scaling = round(origin_width / now_width, 2)print('现在的尺寸 =>', now_width, now_height)print('真实的尺寸 =>', origin_width, origin_height)print('缩放比例为 =>', scaling)return scaling
然后在主函数处调用这个函数:
if __name__ == "__main__":env = Warehouse(10, 5, 6, 20, 3, 1, 200, None, None, RewardType.GLOBAL)env.reset()import timefrom tqdm import tqdmtime.sleep(2)#env.render()#env.step(18 * [Action.LOAD] + 2 * [Action.NOOP])get_scaling()for _ in tqdm(range(1000000)):#time.sleep(2) #推迟执行env.render() #显示环境actions = env.action_space.sample()env.step(actions)
实际效果如下: