From e580b915094cfde1be884ca9cebb7cb2d0a2a7df Mon Sep 17 00:00:00 2001 From: Jaculabilis Date: Tue, 2 Apr 2024 08:30:18 -0700 Subject: [PATCH] Temp commit of working state --- .vscode/launch.json | 27 ++++++++ .vscode/tasks.json | 41 ++++++++++++ .../Adjudicate/MovementPhaseAdjudicator.cs | 27 ++++++++ .../Script/GameScriptHandler.cs | 17 +++++ README.md | 65 +++++++++---------- script.txt | 12 ++++ test.sh | 1 + 7 files changed, 156 insertions(+), 34 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 script.txt create mode 100644 test.sh diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..9a75f60 --- /dev/null +++ b/.vscode/launch.json @@ -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 + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..2ed287c --- /dev/null +++ b/.vscode/tasks.json @@ -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" + } + ] +} \ No newline at end of file diff --git a/MultiversalDiplomacy/Adjudicate/MovementPhaseAdjudicator.cs b/MultiversalDiplomacy/Adjudicate/MovementPhaseAdjudicator.cs index 34bec81..63dbd9f 100644 --- a/MultiversalDiplomacy/Adjudicate/MovementPhaseAdjudicator.cs +++ b/MultiversalDiplomacy/Adjudicate/MovementPhaseAdjudicator.cs @@ -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 ParseOrderSets(World world, List 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(); } diff --git a/MultiversalDiplomacy/Script/GameScriptHandler.cs b/MultiversalDiplomacy/Script/GameScriptHandler.cs index 01a2b8a..5f89904 100644 --- a/MultiversalDiplomacy/Script/GameScriptHandler.cs +++ b/MultiversalDiplomacy/Script/GameScriptHandler.cs @@ -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"); diff --git a/README.md b/README.md index 601bbf0..8a34b1c 100644 --- a/README.md +++ b/README.md @@ -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. ``` - = / - = "Army" / "Fleet" - = "A" / "F" + = "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. ``` - = / - = - = "alfa" / "bravo" / ... - = "" / "prime" / "second" / ... - = - = "a" / "b" / ... - = "" / "1" / "2" / ... + = + = "a" / "b" / ... + = "" / "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. ``` - = ( / ) ["/" ( / )] - = "Munich" / "Tyrolia" / ... - = "MUN" / "TYR" / ... - = "north coast" / "south coast" / ... - = "nc" / "sc" / ... + = ["/" ] + = "MUN" / "TYR" / ... + = "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. ``` - = ( / ) [" "] ( / ) - = "Spring" / "Fall" / "Winter" - = "S" / "F" / "W" - = "1901" / "1902" / ... - = "01" / "02" / ... + = + = "S" / "F" / "W" + = "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 = ":" ":" ``` -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" / "holds" ``` Move orders require the unit, target, and an indication of movement instead of support. ``` - = [] + = [ " "] = "-" / " to " ``` Support-hold orders require the unit, target, and an indication of support instead of movement. ``` - = [] + = [ " "] = " S " / " support " / " supports " ``` Support-move orders require the unit, target, and the support and move indicators. ``` - = [] + = [ " "] ``` Convoy orders WIP. diff --git a/script.txt b/script.txt new file mode 100644 index 0000000..b26b86e --- /dev/null +++ b/script.txt @@ -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 \ No newline at end of file diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..97c9752 --- /dev/null +++ b/test.sh @@ -0,0 +1 @@ +dotnet test -l "console;verbosity=normal" MultiversalDiplomacyTests/ $@