Skip to content

Commit

Permalink
Merge branch 'dev' into patch
Browse files Browse the repository at this point in the history
  • Loading branch information
asdawej authored May 11, 2024
2 parents 1790ba9 + 765bb84 commit 961f0d6
Show file tree
Hide file tree
Showing 16 changed files with 510 additions and 70 deletions.
21 changes: 4 additions & 17 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
name: deploy
on:
push:
branches: [dev, main, master]
pull_request:
branches: [dev, main, master]
branches: [main, master]

env:
version: 1.1.0.0

jobs:
deploy-to-tencent-cos:
Expand All @@ -29,8 +25,6 @@ jobs:
mkdir D:\a\publish
- name: Copy THUAI7
run: Copy-Item -recurse D:\a\THUAI7\THUAI7\ D:\a\mirror\
- name: Test
run: tree D:\a\mirror
- name: Remove directories not needed
run: |
Remove-Item -recurse -force D:\a\mirror\.git
Expand All @@ -45,15 +39,8 @@ jobs:
- name: Build Client
run: dotnet publish "./logic/Client/Client.csproj" -o "D:\a\mirror\logic\Client" -f net8.0-windows10.0.19041.0 -c Release -p:RuntimeIdentifierOverride=win10-x64 -p:WindowsPackageType=None -p:WindowsAppSDKSelfContained=true
- name: Deploy to bucket
run: dotnet run --project "./dependency/deploy/deploy.csproj" ${{ secrets.INSTALLER_COS_SECRET_ID }} ${{ secrets.INSTALLER_COS_SECRET_KEY }}
run: dotnet run --project "./dependency/deploy/deploy.csproj" ${{ secrets.INSTALLER_COS_SECRET_ID }} ${{ secrets.INSTALLER_COS_SECRET_KEY }} "check"
- name: Get installer package(No Key contained for safety)
run: |
$version=Get-ChildItem -Path D:\a\publish | ForEach-Object { $_.name }
[Environment]::SetEnvironmentVariable("version", $version, "Machine")
dotnet publish "./installer/installer.csproj" -o "D:\a\installer" -f net8.0-windows10.0.19041.0 -c Release -p:RuntimeIdentifierOverride=win10-x64 -p:WindowsPackageType=None -p:WindowsAppSDKSelfContained=true
./dependency/7z/7za.exe a -r D:\a\publish\Installer_v${version}.zip D:\a\installer\*
- name: Upload installer package
uses: actions/upload-artifact@v4
with:
name: Installer_v${{ env.version }}.zip
path: D:\a\publish\Installer_v${{ env.version }}.zip
dotnet publish "./installer/installer.csproj" -o "D:\a\publish" -f net8.0-windows10.0.19041.0 -c Release -p:RuntimeIdentifierOverride=win10-x64 -p:WindowsPackageType=None -p:WindowsAppSDKSelfContained=true
dotnet run --project "./dependency/deploy/deploy.csproj" ${{ secrets.INSTALLER_COS_SECRET_ID }} ${{ secrets.INSTALLER_COS_SECRET_KEY }} "upload"
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ GitLink 镜像地址:[THUAI7: GitLink Mirror](https://www.gitlink.org.cn/EESAS

## 赛题背景

待定
![thuai7](resource/THUAI7.png)

在不久的未来,随着 AI 技术的飞速发展,人类探索太空的步伐也大大加快。太空安全对于国家安全的重要性与日俱增,因此,太空建设也成为了各国的重要任务。在这个全新的赛场上,由 AI 控制的高度自动化的太空舰船成为了竞技的主力。它们可以在太空中自由穿梭,执行各种任务,如资源采集、建筑建造、太空战斗等。 新领域的探索总是伴随着风险,太空中的舰船也不例外。在太空中,舰船之间的距离遥远,通讯延迟巨大,因此,舰船之间的冲突往往是在瞬息之间决定胜负。在这个竞技场上,AI 的控制能力、决策速度、战术策略等都将成为决定胜负的关键。

在远离地球的太空中,为了建立起牢固的防线,保卫美好的家园,一场激烈的战斗即将打响。你将扮演舰队指挥官,带领你的舰队在太空中展开一场激烈的战斗,为了最终的胜利,你需要制定合理的战术策略,部署舰船,利用资源,应对敌人的进攻,最终摧毁敌人的基地,夺取最终的胜利。

## 比赛规则

待定
https://docs.eesast.com/docs/contests/THUAI7/

## 软件架构

Expand Down
105 changes: 62 additions & 43 deletions dependency/deploy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using installer.Services;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.IO.Compression;

Logger Log = LoggerProvider.FromConsole();

Expand All @@ -17,56 +18,74 @@
d.Log.Partner.Add(Log);
// 每次更新需要更新默认值
d.CurrentVersion = new TVersion();
File.Create(Path.Combine("D:\\a\\publish", d.CurrentVersion.InstallerVersion.ToString()));

if (d.CheckUpdate())
switch (args[2])
{
foreach (var r in d.Data.MD5Update)
{
Log.LogInfo($"{r.state}, {r.name}");
}
case "check":

d.Data.SaveMD5Data();
List<Task> l = new List<Task>();
foreach (var r in d.Data.MD5Update)
{
var n = r.name.Replace('\\', '/');
n = n.TrimStart('.').TrimStart('/');
if (r.state == System.Data.DataRowState.Added || r.state == System.Data.DataRowState.Modified)
if (d.CheckUpdate())
{
l.Add(Cloud.UploadFileAsync(Path.Combine(d.Data.Config.InstallPath, r.name), n));
foreach (var r in d.Data.MD5Update)
{
Log.LogInfo($"{r.state}, {r.name}");
}

d.Data.SaveMD5Data();
List<Task> l = new List<Task>();
foreach (var r in d.Data.MD5Update)
{
var n = r.name.Replace('\\', '/');
n = n.TrimStart('.').TrimStart('/');
if (r.state == System.Data.DataRowState.Added || r.state == System.Data.DataRowState.Modified)
{
l.Add(Cloud.UploadFileAsync(Path.Combine(d.Data.Config.InstallPath, r.name), n));
}
else if (r.state == System.Data.DataRowState.Deleted)
{
l.Add(Cloud.DeleteFileAsync(n));
}
}
Task.WaitAll(l.ToArray());
}
else if (r.state == System.Data.DataRowState.Deleted)
else
{
l.Add(Cloud.DeleteFileAsync(n));
Log.LogInfo("Nothing to update");
}
}
Task.WaitAll(l.ToArray());
}
else
{
Log.LogInfo("Nothing to update");
}

d.Data.SaveMD5Data();
Cloud.UploadFile(d.Data.MD5DataPath, "hash.json");
d.Data.SaveMD5Data();
Cloud.UploadFile(d.Data.MD5DataPath, "hash.json");

Cloud.UploadFile(Path.Combine(d.Data.Config.InstallPath, "CAPI", "cpp", "API", "src", "AI.cpp"),
$"Templates/t.{d.CurrentVersion.TemplateVersion}.cpp");
Cloud.UploadFile(Path.Combine(d.Data.Config.InstallPath, "CAPI", "python", "PyAPI", "AI.py"),
$"Templates/t.{d.CurrentVersion.TemplateVersion}.py");
Log.LogInfo("User code uploaded.");
Cloud.UploadFile(Path.Combine(d.Data.Config.InstallPath, "CAPI", "cpp", "API", "src", "AI.cpp"),
$"Templates/t.{d.CurrentVersion.TemplateVersion}.cpp");
Cloud.UploadFile(Path.Combine(d.Data.Config.InstallPath, "CAPI", "python", "PyAPI", "AI.py"),
$"Templates/t.{d.CurrentVersion.TemplateVersion}.py");
Log.LogInfo("User code uploaded.");

var list = (from i in d.Data.MD5Data
select i.Key.Replace(Path.DirectorySeparatorChar, '/').TrimStart('.').TrimStart('/')).ToArray();
Log.LogInfo(list[0]);
using (FileStream s = new FileStream(Path.Combine(d.Data.Config.InstallPath, "compress.csv"), FileMode.Create, FileAccess.Write))
using (StreamWriter w = new StreamWriter(s))
{
foreach (var item in list)
{
w.WriteLine("https://thuai7-1319625962.cos.ap-beijing.myqcloud.com/" + item);
}
}
Cloud.UploadFile(Path.Combine(d.Data.Config.InstallPath, "compress.csv"), "compress.csv");
Log.LogInfo("Compress csv generated.");
var list = (from i in d.Data.MD5Data
select i.Key.Replace(Path.DirectorySeparatorChar, '/').TrimStart('.').TrimStart('/')).ToArray();
Log.LogInfo(list[0]);
using (FileStream s = new FileStream(Path.Combine(d.Data.Config.InstallPath, "compress.csv"), FileMode.Create, FileAccess.Write))
using (StreamWriter w = new StreamWriter(s))
{
foreach (var item in list)
{
w.WriteLine("https://thuai7-1319625962.cos.ap-beijing.myqcloud.com/" + item);
}
}
Cloud.UploadFile(Path.Combine(d.Data.Config.InstallPath, "compress.csv"), "compress.csv");
Log.LogInfo("Compress csv generated.");
break;
case "upload":
d.UpdateMD5();
if (d.Data.FileHashData.TVersion.InstallerVersion < d.CurrentVersion.InstallerVersion)
{
Cloud.DownloadFile(@"D:\a\publish\Secret.csv", "Secret.csv");
ZipFile.CreateFromDirectory(@"D:\a\publish", @$"D:\a\Installer_v{d.CurrentVersion.InstallerVersion}.zip", CompressionLevel.SmallestSize, false);
Cloud.UploadFile(@$"D:\a\Installer_v{d.CurrentVersion.InstallerVersion}.zip", $"Setup/Installer_v{d.CurrentVersion.InstallerVersion}.zip");
}
else
{
Log.LogInfo("No installer version update found.");
}
break;
}
2 changes: 1 addition & 1 deletion installer/Data/MD5FileData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class TVersion
public Version TemplateVersion = new Version(1, 0, 0, 3);
// 本体版本
[JsonInclude]
public Version InstallerVersion = new Version(1, 1, 0, 0);
public Version InstallerVersion = new Version(1, 1, 0, 2);
public static bool operator <(TVersion l, TVersion r)
{
return l.LibVersion < r.LibVersion || l.TemplateVersion < r.TemplateVersion || l.InstallerVersion < r.InstallerVersion;
Expand Down
10 changes: 7 additions & 3 deletions installer/ViewModel/DebugViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,14 @@ private void ServerExited(object? sender, EventArgs e)
protected Process? server;
public event EventHandler? OnServerLaunched;
public event EventHandler? OnServerExited;

public bool LaunchServer()
{
server = Process.Start(new ProcessStartInfo()
{
FileName = Downloader.Data.Config.DevServerPath ?? Path.Combine(Downloader.Data.Config.InstallPath, "logic", "Server", "Server.exe"),
Arguments = $"--ip 0.0.0.0 --port {Port} --teamCount {TeamCount} --shipNum {ShipCount}",
WorkingDirectory = Downloader.Data.Config.InstallPath
});
if (server is null)
{
Expand All @@ -296,7 +298,6 @@ public bool LaunchServer()
return true;
}


public bool LaunchClient(int team, int player, int ship)
{
Downloader.Data.Config.Commands.TeamID = team;
Expand All @@ -313,6 +314,7 @@ public bool LaunchClient(int team, int player, int ship)
var client = Process.Start(new ProcessStartInfo()
{
FileName = Downloader.Data.Config.DevClientPath ?? Path.Combine(Downloader.Data.Config.InstallPath, "logic", "Client", "Client.exe"),
WorkingDirectory = Downloader.Data.Config.InstallPath
});
if (client is null)
{
Expand Down Expand Up @@ -341,7 +343,8 @@ public bool LaunchCppAPI(int team, int player)
var cpp = Process.Start(new ProcessStartInfo()
{
FileName = Downloader.Data.Config.DevCppPath ?? exe,
Arguments = $"-I {IP} -P {Port} -t {team} -p {player} -o"
Arguments = $"-I {IP} -P {Port} -t {team} -p {player} -o -d",
WorkingDirectory = Downloader.Data.Config.InstallPath
});
if (cpp is null)
{
Expand Down Expand Up @@ -379,7 +382,8 @@ public bool LaunchPyAPI(int team, int player)
FileName = "cmd.exe",
Arguments = "/c python "
+ (Downloader.Data.Config.DevPyPath ?? Path.Combine(Downloader.Data.Config.InstallPath, "CAPI", "python", "PyAPI", "main.py"))
+ $" -I {IP} -P {Port} -t {team} -p {player} -o"
+ $" -I {IP} -P {Port} -t {team} -p {player} -o -d",
WorkingDirectory = Downloader.Data.Config.InstallPath
});
if (py is null)
{
Expand Down
8 changes: 8 additions & 0 deletions interface/interface_playback/Assets/Plugins.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions interface/interface_playback/Assets/Scripts/Playback.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 961f0d6

Please sign in to comment.