Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
263 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<AssemblyName>WagahighChoices.Ashe.Contract</AssemblyName> | ||
<RootNamespace>WagahighChoices.Ashe</RootNamespace> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="MagicOnion" Version="0.5.3" /> | ||
<PackageReference Include="MessagePackAnalyzer" Version="1.6.0" PrivateAssets="All" /> | ||
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace WagahighChoices.Ashe | ||
{ | ||
public enum ChoiceAction | ||
{ | ||
SelectUpper, | ||
SelectLower, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace WagahighChoices.Ashe | ||
{ | ||
public enum Heroine | ||
{ | ||
/// <summary>鹿苑寺かおるこ</summary> | ||
Kaoruko, | ||
/// <summary>桜木・R・アーシェ</summary> | ||
Ashe, | ||
/// <summary>鳴海兎亜</summary> | ||
Toa, | ||
/// <summary>宮瀬未尋</summary> | ||
Mihiro, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace WagahighChoices.Ashe | ||
{ | ||
public abstract class SearchDirector : IDisposable | ||
{ | ||
protected bool IsDisposed { get; private set; } | ||
|
||
protected virtual void Dispose(bool disposing) | ||
{ | ||
this.IsDisposed = true; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
this.Dispose(true); | ||
GC.SuppressFinalize(this); | ||
} | ||
|
||
/// <summary> | ||
/// 新しい指示をもらいます。 | ||
/// </summary> | ||
public abstract Task<SeekDirectionResult> SeekDirection(); | ||
|
||
/// <summary> | ||
/// 探索結果をレポートします。 | ||
/// </summary> | ||
/// <param name="jobId"><see cref="SeekDirectionResult.JobId"/></param> | ||
/// <param name="heroine">誰のルートに至ったか</param> | ||
/// <param name="selectionIds">通過した選択画面のリスト</param> | ||
public abstract Task ReportResult(Guid jobId, Heroine heroine, IReadOnlyList<int> selectionIds); | ||
|
||
/// <summary> | ||
/// ログを送信します。 | ||
/// </summary> | ||
public abstract Task Log(string message, DateTimeOffset timestamp); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using MessagePack; | ||
|
||
namespace WagahighChoices.Ashe | ||
{ | ||
[MessagePackObject] | ||
public class SeekDirectionResult | ||
{ | ||
[Key(0)] | ||
public SeekDirectionResultKind Kind { get; } | ||
|
||
[Key(1)] | ||
public Guid JobId { get; set; } | ||
|
||
[Key(2)] | ||
public ChoiceAction[] Actions { get; } | ||
|
||
[SerializationConstructor] | ||
public SeekDirectionResult(SeekDirectionResultKind kind, Guid jobId, ChoiceAction[] actions) | ||
{ | ||
this.Kind = kind; | ||
this.JobId = jobId; | ||
this.Actions = actions; | ||
} | ||
} | ||
|
||
public enum SeekDirectionResultKind | ||
{ | ||
/// <summary> | ||
/// 指示が <see cref="SeekDirectionResult.Actions"/> に代入されています。 | ||
/// </summary> | ||
Ok, | ||
/// <summary> | ||
/// すべてのジョブがワーカーに割り当てられているので、今は手を付けられる新しいジョブがありません。 | ||
/// </summary> | ||
NotAvailable, | ||
/// <summary> | ||
/// 探索は終了しました。 | ||
/// </summary> | ||
Finished, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using System.Collections.Immutable; | ||
|
||
namespace WagahighChoices.Ashe | ||
{ | ||
public class SelectionInfo | ||
{ | ||
public int Id { get; } | ||
public byte[] ScreenshotHash { get; } // ImmutableArray にしたい | ||
|
||
protected SelectionInfo(int id, string screenshotHash) | ||
{ | ||
this.Id = id; | ||
|
||
// Blockhash 256bit なので、 64 文字なはず | ||
if (screenshotHash?.Length != 64) throw new ArgumentException(); | ||
|
||
var hash = new byte[32]; | ||
for (var i = 0; i < hash.Length; i++) | ||
{ | ||
uint HexToUInt(char c) | ||
{ | ||
if (c >= '0' && c <= '9') return c - (uint)'0'; | ||
if (c >= 'a' && c <= 'f') return c - (uint)'a' + 10; | ||
if (c >= 'A' && c <= 'F') return c - (uint)'A' + 10; | ||
throw new FormatException(); | ||
} | ||
|
||
hash[i] = (byte)(HexToUInt(screenshotHash[i * 2]) << 4 | HexToUInt(screenshotHash[i * 2 + 1])); | ||
} | ||
|
||
this.ScreenshotHash = hash; | ||
} | ||
|
||
public override string ToString() => nameof(SelectionInfo) + " " + this.Id; | ||
|
||
// (ここに選択肢の文字列を入れてしまうと MIT License で配布するということに問題が発生してしまうので入れないぞ) | ||
public static ImmutableArray<SelectionInfo> Selections { get; } = ImmutableArray.Create( | ||
new SelectionInfo(1, "24f604760c3f6c3f2e7628162ef629b66dbf20097c478d4707c607c407c0cfff"), | ||
new SelectionInfo(2, "6b006a307f70ffb07fb06db06e706d207ff307e0872606e407600fe003c0ffff"), | ||
new SelectionInfo(3, "f01df81df80df00df21cf10cfffc0380319f119607b60fa70be00fe00fe3c7e6"), | ||
new SelectionInfo(4, "1e001000fb8fffbffc0ff81f7e3f00000fc703c783c7c3c683c0c1c0c3c0ffff"), | ||
new SelectionInfo(5, "fc01fc01fc07fc07fe77fc070ff50000fffc83f9b0039003f00390038e03ffff"), | ||
new SelectionInfo(6, "e780ff900fc12fc80ff80fd0bff88d00afc00fc0ff40ff406fc03d931ddb09d0"), | ||
new SelectionInfo(7, "e47ee07ee25c82c44fdcc1c88f70c7e0d7e157017701ff80ff80bea0fe22bc20"), | ||
new SelectionInfo(8, "81f81ff8bff221808fc2a020bef3a1f3f5b7f933f103c100718ce10f0100ffff"), | ||
new SelectionInfo(9, "43f009f08fe60bee0ff80ff00ff083f0e34ff7c107c106e100e302670057ffff"), | ||
new SelectionInfo(10, "001ff9ff031f03170ff709b30ff20256035f03d3b3d293ca580c400c7836ffff"), | ||
new SelectionInfo(11, "21ff00ff00ff08dc0afe017e2d3838afdbc9ece9e360f200f010c0dcc2ff44fe"), | ||
new SelectionInfo(12, "01fc1fea33f233c00ff281f03ff013f0b382ff90bfb2848208fc47400780ffff") | ||
); | ||
|
||
public static SelectionInfo GetSelectionById(int id) => Selections[id - 1]; // データ依存ハック | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
<AssemblyName>ashe</AssemblyName> | ||
<RootNamespace>WagahighChoices.Ashe</RootNamespace> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.2.5" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Ashe.Contract\Ashe.Contract.csproj" /> | ||
<ProjectReference Include="..\Toa.Core\Toa.Core.csproj" /> | ||
<ProjectReference Include="..\Toa.Grpc\Toa.Grpc.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using McMaster.Extensions.CommandLineUtils; | ||
using WagahighChoices.Toa.Grpc; | ||
|
||
namespace WagahighChoices.Ashe | ||
{ | ||
[Command(Name = "ashe", FullName = "Ashe", Description = "探索ワーカー")] | ||
public class Program | ||
{ | ||
public static int Main(string[] args) | ||
{ | ||
return CommandLineApplication.Execute<Program>(args); | ||
} | ||
|
||
[Option("--kaoruko-host <host>", Description = "接続する Kaoruko のホスト名。指定しない場合はコンソールから指示を受け付けます")] | ||
public string KaorukoHost { get; set; } | ||
|
||
[Option("--kaoruko-port <port>", Description = "接続する Kaoruko のポート番号(デフォルト: 50222)")] | ||
public int KaorukoPort { get; set; } | ||
|
||
[Option("--toa-host <host>", Description = "接続する Toa のホスト名。指定しない場合はワガママハイスペックを起動します")] | ||
public string ToaHost { get; set; } | ||
|
||
[Option("--toa-port <port>", Description = "接続する Toa のポート番号(デフォルト: 51203)")] | ||
public int ToaPort { get; set; } = GrpcToaServer.DefaultPort; | ||
|
||
[Option("-d|--directory <dir>", Description = "ワガママハイスペック.exe が存在するディレクトリ(Toa を使用しない場合)")] | ||
public string Directory { get; set; } | ||
|
||
private void OnExecute() | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters