Skip to content

Commit

Permalink
修复理智识别不正确的问题,更改默认ADB端口至明日方舟官方推荐的MuMu模拟器的ADB端口,添加鸣谢
Browse files Browse the repository at this point in the history
  • Loading branch information
Rcmcpe committed Aug 24, 2020
1 parent 493976a commit 085dda8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
31 changes: 24 additions & 7 deletions Arknights Automation Library/LevelRepeater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public enum Mode
WaitWhileNoSanity
}

private Sanity? _previousSanity;

private int _requiredSanity;

public LevelRepeater(Device device, Mode mode, int repeatTime) : base(device)
Expand Down Expand Up @@ -56,9 +58,20 @@ private void EnsureSanityEnough()

private bool HaveEnoughSanity()
{
Sanity sanity = Device.GetCurrentSanity();
Log.Info($"当前理智[{sanity}],需要理智[{_requiredSanity}]");
return sanity.Value >= _requiredSanity;
Sanity nowSanity = Device.GetCurrentSanity();
// 防止OCR抽风
if (_previousSanity != null)
{
int dSanity = _previousSanity.Value - nowSanity.Value; //20
if (Math.Abs(nowSanity.Max - _previousSanity.Max) > 1 // 理智上限变动大于1
|| dSanity > 0 && _requiredSanity - dSanity > 10) // 没有嗑药,且理智对于一般情况下的刷关后理智差大于10
nowSanity = Device.GetCurrentSanity();
}

_previousSanity = nowSanity;

Log.Info($"当前理智[{nowSanity}],需要理智[{_requiredSanity}]");
return nowSanity.Value >= _requiredSanity;
}

private void InitRequiredSanity()
Expand All @@ -80,8 +93,9 @@ private void SpecifiedTimes()
{
for (var currentTime = 1; currentTime <= RepeatTime; currentTime++)
{
Log.Info($"正在执行第{currentTime}次刷关");
Log.Info($"开始第{currentTime}次刷关");
RunOnce();
Log.Info($"关卡完成,目前已刷关{currentTime}次");
}
}

Expand All @@ -90,9 +104,10 @@ private void SpecTimesWithWait()
InitRequiredSanity();
for (var currentTime = 1; currentTime <= RepeatTime; currentTime++)
{
Log.Info($"正在执行第{currentTime}次刷关");
Log.Info($"开始第{currentTime}次刷关");
EnsureSanityEnough();
RunOnce();
Log.Info($"关卡完成,目前已刷关{currentTime}次");
}
}

Expand All @@ -103,8 +118,9 @@ private void UntilNoSanity()
while (true)
if (HaveEnoughSanity())
{
RunOnce();
currentTime++;
Log.Info($"开始第{currentTime}次刷关");
RunOnce();
Log.Info($"关卡完成,目前已刷关{currentTime}次");
}
else
Expand All @@ -128,8 +144,9 @@ private void WaitWhileNoSanity()
while (true)
if (HaveEnoughSanity())
{
RunOnce();
currentTime++;
Log.Info($"开始第{currentTime}次刷关");
RunOnce();
Log.Info($"关卡完成,目前已刷关{currentTime}次");
}
else
Expand Down
4 changes: 2 additions & 2 deletions Arknights Automation Library/ScreenArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace REVUnit.AutoArknights.Core
{
internal static class ScreenArea
{
public static Rect2f CurrentSanity = new Rect2f(0.875f, 0.023f, 0.11f, 0.065f);
public static Rect2f RequiredSanity = new Rect2f(0.9271f, 0.9426f, 0.0323f, 0.0296f);
public static Rect2f CurrentSanity = new Rect2f(0.872f, 0.021f, 0.125f, 0.07f);
public static Rect2f RequiredSanity = new Rect2f(0.92f, 0.9426f, 0.04f, 0.0296f);

public static Mat Apply(this Rect2f area, Mat super)
{
Expand Down
2 changes: 1 addition & 1 deletion Auto Arknights CLI/Auto Arknights CLI.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Adb": {
"Path": "adb/adb.exe",
"Remote": "127.0.0.1:21503"
"Remote": "127.0.0.1:7555"
},
"Log": {
"Level": "Info"
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@
*用于自动化明日方舟刷关的程序。*
*For non-CN server Arknights players:* now this program **only** works for CN server
## 运行
确保你已了解下面的“必须运行要求”和“如何使用”章节后由[此处](https://github.com/CCRcmcpe/Auto-Arknights/releases/latest)下载,运行`Auto Arknights CLI.exe`
### 必须运行要求
* 最新版的 `.NET 5.0 Preview`。([官方下载](https://dotnet.microsoft.com/download/dotnet-core/5.0))
* CPU支持`AVX2`指令集且支持`x64`架构。
* 系统为`Windows`,版本为7及以上,目标架构为`x64`

确保你的电脑满足运行要求后,[下载](https://github.com/CCRcmcpe/Auto-Arknights/releases/latest)并运行
* 系统为`Windows`,版本为7及以上,目标架构为`x64`
### 如何使用
0. (第一次运行)本程序需要连接目标设备的`ADB`,运行前编辑`Auto Arknights CLI.config.json`更改`ADB:Remote`至你想要的地址即可
0. (第一次运行)本程序需要连接目标设备的`ADB`。请编辑`Auto Arknights CLI.config.json`中的`ADB:Remote`至你想要的地址
各大模拟器的`ADB`地址不同,请自行搜索。此外,也可以连接开启了局域网调试的手机等设备。
1. 打开作战界面(带作战开始按钮的),并确保你勾选了代理作战。
2. 选择模式然后运行,各个模式的功能在下面有介绍。
## 功能
### 注意事项
1. **目前暂不支持剿灭作战!**
2. 如果刷关过程中博士等级升级了会卡住
2. 如果刷关过程中博士等级升级了会卡住
### 重复单关卡
功能|说明
-|-
Expand All @@ -31,3 +30,5 @@
2. 运行`build-winx64.ps1`,构建成果在`artifact/`
## 关于
开发者并没有很多经验,如果有问题欢迎提出`issue`
### 鸣谢
[Jetbrains](https://www.jetbrains.com/) 为本项目提供了免费的开源项目开发用许可证,这对本项目的开发有很大的帮助。

0 comments on commit 085dda8

Please sign in to comment.