Skip to content

Commit

Permalink
增加cpu版本
Browse files Browse the repository at this point in the history
  • Loading branch information
ZYX committed Jun 29, 2024
1 parent 323161a commit 48a5504
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 21 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,41 @@ jobs:
$files = Get-ChildItem -Path AutoSimulatedUniverse
Compress-Archive -Path $files.FullName -DestinationPath "AutoSimulatedUniverse_${{ github.ref_name }}.zip" -Force
- name: Install dependencies for cpu mode
run:
pip uninstall onnxruntime-directml -y
pip install onnxruntime

- name: Pack Flet Application
run: flet pack gui.py --icon imgs/icon_m.png --uac-admin --add-data "utils/models;utils/models" -y

- name: Pyinstaller Application
run: |
pyinstaller --uac-admin -F --i imgs/icon.png -w notif.py
- name: Move assets to dist directory
run: |
xcopy imgs dist\imgs /I /E
xcopy actions dist\actions /I /E
xcopy info_example.yml dist
xcopy info_example_old.yml dist
xcopy README.md dist
ren dist AutoSimulatedUniverse_cpu
- name: Create zip archive
if: startsWith(github.ref, 'refs/tags/')
run: |
$files = Get-ChildItem -Path AutoSimulatedUniverse_cpu
Compress-Archive -Path $files.FullName -DestinationPath "AutoSimulatedUniverse_${{ github.ref_name }}_cpu.zip" -Force
- name: Create release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
name: ${{ github.ref_name }}
files: |
AutoSimulatedUniverse_${{ github.ref_name }}.zip
AutoSimulatedUniverse_${{ github.ref_name }}_cpu.zip
prerelease: true

- name: Upload artifact
Expand Down
14 changes: 8 additions & 6 deletions diver.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from copy import deepcopy
from utils.log import log, set_debug
from utils.log import my_print as print
from utils.log import print_exc
from utils.diver.args import args
from utils.diver.utils import UniverseUtils, set_forground, notif
import os
Expand All @@ -38,9 +39,10 @@ def __init__(self, debug=0, nums=-1, speed=0):
self.floor = 0
self.allow_e = 1
self.count = self.my_cnt = 0
self.debug = debug
self.nums = nums
self.speed = speed
if not hasattr(self, 'hot_init'):
self.debug = debug
self.nums = nums
self.speed = speed
self.init_tm = time.time()
self.area_now = None
self.action_history = []
Expand Down Expand Up @@ -908,12 +910,12 @@ def stop(self, *_, **__):
self._stop = True

def on_key_press(self, event):
global stop_flag
if event.name == "f8":
print("F8 已被按下,尝试停止运行")
self.stop()

def start(self):
self.hot_init = 1
self.__init__()
self._stop = False
keyboard.on_press(self.on_key_press)
Expand All @@ -929,7 +931,7 @@ def start(self):
if not self._stop:
self.stop()
except Exception as e:
self.print_exc()
print_exc()
traceback.print_exc()
log.info(str(e))
log.info("发生错误,尝试停止运行")
Expand All @@ -943,7 +945,7 @@ def main():
# except ValueError as e:
# pass
except Exception:
traceback.print_exc()
print_exc()
finally:
su.stop()

Expand Down
8 changes: 4 additions & 4 deletions info_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ config:
# 传送门优先级,1-3,3代表优先级最高,1代表优先级最低
# 如需自定义请将enable_portal_prior设为1
# 只能修改数字,不要修改名称
enable_portal_prior: 0
enable_portal_prior: 1
portal_prior:
商店: 1
财富: 1
战斗: 2
遭遇: 2
战斗: 1
遭遇: 1
奖励: 3
事件: 3
事件: 1

key_mapping:
# 交互键,只能是单个字母
Expand Down
9 changes: 2 additions & 7 deletions utils/diver/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import math
import random
import win32gui, win32com.client, pythoncom
import io
import os
import sys
import ctypes
Expand All @@ -27,6 +26,7 @@
from utils.screenshot import Screen
import threading
from utils.log import my_print as print
from utils.log import print_exc


def notif(title, msg, cnt=None):
Expand Down Expand Up @@ -153,7 +153,7 @@ def __init__(self):
else:
time.sleep(0.3)
except Exception:
self.print_exc()
print_exc()
pass
self.sct = Screen()

Expand Down Expand Up @@ -1252,11 +1252,6 @@ def print_stack(self, num=1, force=0):
print(stk[-2].name,stk[-3-i].filename.split('\\')[-1].split('.')[0],stk[-3-i].name,stk[-3-i].lineno)
except:
pass

def print_exc(self):
with io.StringIO() as buf, open("logs/error_log.txt", "a") as f:
traceback.print_exc(file=buf)
f.write(buf.getvalue())

def check_auto(self):
auto = self.check("z", 0.0878,0.9630, large=False, mask="mask_auto")
Expand Down
6 changes: 3 additions & 3 deletions utils/gui/choose.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from utils.simul.update_map import update_map
from utils.simul.utils import notif
from utils.diver.args import args
from utils.log import my_print as print
from utils.log import print_exc
import time


Expand All @@ -34,11 +36,9 @@ def run(func, *args, **kwargs):
res = func(*args, **kwargs)
change_all_button(False)
return res
except ValueError as e:
pass
except Exception:
print("E: 运行函数时出现错误")
traceback.print_exc()
print_exc()
finally:
change_all_button(False)

Expand Down
9 changes: 8 additions & 1 deletion utils/log.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
import io
import traceback
from logging import (
getLogger,
StreamHandler,
Expand Down Expand Up @@ -50,4 +52,9 @@ def set_debug(debug: bool = False):

def my_print(*args, **kwargs):
log.info(" ".join(map(str, args)))
print(*args, **kwargs)
print(*args, **kwargs)

def print_exc(self):
with io.StringIO() as buf, open("logs/error_log.txt", "a") as f:
traceback.print_exc(file=buf)
f.write(buf.getvalue())

0 comments on commit 48a5504

Please sign in to comment.