Temp commit of working state

This commit is contained in:
Jaculabilis 2024-04-02 08:30:18 -07:00 committed by Tim Van Baak
parent 158c952b6b
commit e580b91509
7 changed files with 156 additions and 34 deletions

27
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,27 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/MultiversalDiplomacy/bin/Debug/net6.0/MultiversalDiplomacy.dll",
"args": ["repl"],
"cwd": "${workspaceFolder}/MultiversalDiplomacy",
"console": "internalConsole",
"stopAtEntry": true
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
],
"logging": {
"engineLogging": true
}
}

41
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/MultiversalDiplomacy/MultiversalDiplomacy.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/MultiversalDiplomacy/MultiversalDiplomacy.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/MultiversalDiplomacy/MultiversalDiplomacy.csproj"
],
"problemMatcher": "$msCompile"
}
]
}

View File

@ -1,3 +1,5 @@
using System.Linq;
using MultiversalDiplomacy.Adjudicate.Decision;
using MultiversalDiplomacy.Adjudicate.Logging;
using MultiversalDiplomacy.Model;
@ -21,6 +23,31 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator
public List<Order> ParseOrderSets(World world, List<OrderSet> orderSets)
{
foreach (OrderSet orderSet in orderSets)
{
string[] lines = orderSet.Text.Split('\n');
string powerLine = lines[0];
// TODO verify
string powerName = powerLine.Substring("orders ".Length);
foreach (string line in lines.Skip(1))
{
// Individual order components do not have spaces in them
string[] tokens = line.Split(' ');
int i = 0;
// Check for a unit type
string[] unitTypes = new string[] { "a", "f"};
if (unitTypes.Contains(tokens[i].ToLowerInvariant()))
{
// yay
i++;
}
//
}
}
throw new NotImplementedException();
}

View File

@ -31,6 +31,7 @@ public class GameScriptHandler : IScriptHandler
case "?":
Console.WriteLine("commands:");
Console.WriteLine(" adjudicate: adjudicate the current orders");
Console.WriteLine(" assert: assert about the state of the game");
Console.WriteLine(" list: list things in a game category");
Console.WriteLine(" orders: submit order sets");
Console.WriteLine(" status: overview of the state of the game");
@ -40,6 +41,22 @@ public class GameScriptHandler : IScriptHandler
World = GameController.AdjudicateOrders(World);
break;
case "assert" when args.Length == 1:
Console.WriteLine("usage:");
Console.WriteLine(" assert timeline [timeline]@[turn]: timeline exists");
Console.WriteLine(" assert unit [unit spec]: unit exists");
break;
case "assert" when args[1] == "timeline":
// TODO: raise an error if the timeline doesn't exist
Console.WriteLine("WIP");
break;
case "assert" when args[1] == "unit":
// TODO: raise an error if the unit doesn't exist
Console.WriteLine("WIP");
break;
case "list" when args.Length == 1:
Console.WriteLine("usage:");
Console.WriteLine(" list ordersets: unadjudicated order sets");

View File

@ -30,52 +30,52 @@ The Great Powers of Europe can only wage multiversal wars because they are lead
### Unit designations
In _Diplomacy_, orders refer to provinces by name or abbreviation, such as an order given to "Army Munich" or a build order for "London". In _5D Diplomacy with Multiversal Time Travel_, this is insufficient to unambiguously identify a province, since the province exists in multiple timelines across multiple turns. The convention for identifying a multiversal location is `timeline:province:turn`, where `timeline` is the timeline's identifier and `turn` is the turn's identifier. Thus, an army in Munich in timeline "bravo" in Spring 1902 might be referenced as "Army bravo:Munich:Spring 1902" or "A b:Mun:S02" for short.
In _Diplomacy_, orders refer to provinces, such as "A Mun-Tyr". In _5D Diplomacy with Multiversal Time Travel_, this is insufficient to unambiguously identify a province, since the province exists in multiple timelines across multiple turns. The convention for identifying a multiversal location is `timeline:province:turn`, where `timeline` is the timeline's identifier and `turn` is the turn's identifier. Thus, an army in Munich in timeline "bravo" in Spring 1902 is referenced as "A b:Mun:S02".
(Why this order? If timeline and turn identifiers were next to each other, it could be difficult to immediately see which one is the timeline and which one is the turn if both are in a short representation, especially for timelines designated `foxtrot` or `sierra` compared to turns designated as being Fall or Spring. _5D Diplomacy with Multiversal Time Travel_ is already complicated enough, so the timeline and turn are put on either side of the province.)
(Why this order? Short representations for timelines and turns can be confused for each other, especially for timelines designated with `foxtrot` or `sierra` and turns in Fall or Spring. _5D Diplomacy with Multiversal Time Travel_ is already complicated enough, so the timeline and turn are put on either side of the province.)
WIP: parsing of turn designations has not been implemented yet
### Open convoys
The standard _Diplomacy_ rules require that a convoy order include the convoyed unit's origin and destination. This is hard to coordinate once there are multiple turns and timelines involved. _5D Diplomacy with Multiversal Time Travel_ thus introduces the concept of an _open convoy_, a nonspecific convoy order that can become part of a convoy later.
WIP: open convoys have not been implemented yet
## DATC compliance
WIP
## 5dp script
Order notation is case-insensitive.
### Order element grammar
Where a unit type is expected, either the full unit type name or a single letter is valid.
A unit type is specified with a single letter.
```
<unit-spec> = <unit-long> / <unit-short>
<unit-long> = "Army" / "Fleet"
<unit-short> = "A" / "F"
<unit-spec> = "A" / "F"
```
Where a timeline is expected, either the full timeline designation or an initial is valid. An omitted secondary designation is equivalent to a secondary designation of 0.
A timeline is specified with a primary designation initial, plus a secondary designation if there are enough timelines.
```
<timeline-spec> = <tl-long> / <tl-short>
<tl-long> = <tl-long-primary> <tl-long-secondary>
<tl-long-primary> = "alfa" / "bravo" / ...
<tl-long-secondary> = "" / "prime" / "second" / ...
<tl-short> = <tl-short-primary> <tl-short-secondary>
<tl-short-primary> = "a" / "b" / ...
<tl-short-secondary> = "" / "1" / "2" / ...
<timeline-spec> = <tl-primary> <tl-secondary>
<tl-primary> = "a" / "b" / ...
<tl-secondary> = "" / "1" / "2" / ...
```
Where a province is expected, either the province's full name or a known abbreviation is valid. A named location in a province may optionally be specified with either its full name or a known abbreviation. A named location is not necessary for the _form_ of a province to be valid, though an order may be invalid if the omission creates an ambiguity.
A province is specified with a known three-letter abbreviation. A named location in a province may optionally be specfied with its abbreviation. A named location is not necessary for the _form_ of a province to be valid, though an order may be invalid if the omission creates an ambiguity.
```
<province-spec> = (<province-long> / <province-short>) ["/" (<location-long> / <location-short>)]
<province-long> = "Munich" / "Tyrolia" / ...
<province-short> = "MUN" / "TYR" / ...
<location-long> = "north coast" / "south coast" / ...
<location-short> = "nc" / "sc" / ...
<province-spec> = <province> ["/" <location>]
<province> = "MUN" / "TYR" / ...
<location> = "nc" / "sc" / ...
```
Where a turn is expected, either the full seasonal designation or an abbreviated form is valid.
A turn is specified with the season's initial and the short form of the year. Winter is numbered in the year of the previous Fall.
```
<turn-spec> = (<season-long> / <season-short>) [" "] (<year-long> / <year-short>)
<season-long> = "Spring" / "Fall" / "Winter"
<season-short> = "S" / "F" / "W"
<year-long> = "1901" / "1902" / ...
<year-short> = "01" / "02" / ...
<turn-spec> = <season> <year>
<season> = "S" / "F" / "W"
<year> = "01" / "02" / ...
```
A multiversal location is a timeline, a province, and a turn separated by a colon.
@ -83,10 +83,7 @@ A multiversal location is a timeline, a province, and a turn separated by a colo
<multiverse-spec> = <timeline-spec> ":" <province-spec> ":" <turn-spec>
```
Thus, the following multiversal locations are equivalent:
* `bravoprime:Irish Sea:Fall 1902`
* `b1:IRI:F02`
* `bravoprime:IRS:Fall02`
Thus, `b1:IRI:F02` represents the Irish Sea, in Fall 1902, in timeline bravo-prime.
### Order formats
@ -94,25 +91,25 @@ Note that DATC 4.C makes unit designations superfluous outside some build order
Hold orders require the unit and an indication of a hold order.
```
<hold-order> = [<unit-spec>] <multiverse-spec> <hold-token>
<hold-order> = [<unit-spec> " "] <multiverse-spec> " " <hold-token>
<hold-token> = "hold" / "holds"
```
Move orders require the unit, target, and an indication of movement instead of support.
```
<move-order> = [<unit-spec>] <multiverse-spec> <move-token> <multiverse-spec>
<move-order> = [<unit-spec> " "] <multiverse-spec> <move-token> <multiverse-spec>
<move-token> = "-" / " to "
```
Support-hold orders require the unit, target, and an indication of support instead of movement.
```
<support-hold-order> = [<unit-spec>] <multiverse-spec> <support-token> <multiverse-spec>
<support-hold-order> = [<unit-spec> " "] <multiverse-spec> <support-token> <multiverse-spec>
<support-token> = " S " / " support " / " supports "
```
Support-move orders require the unit, target, and the support and move indicators.
```
<support-move-order> = [<unit-spec>] <multiverse-spec> <support-token> <move-order>
<support-move-order> = [<unit-spec> " "] <multiverse-spec> <support-token> <move-order>
```
Convoy orders WIP.

12
script.txt Normal file
View File

@ -0,0 +1,12 @@
new custom
unit Germany Army Berlin
unit Austria Army Tyrolia
orders Germany
BER - TYR
orders Austria
TYR hold
list ordersets
adjudicate

1
test.sh Normal file
View File

@ -0,0 +1 @@
dotnet test -l "console;verbosity=normal" MultiversalDiplomacyTests/ $@