Skip to content

Commit

Permalink
Draw dot
Browse files Browse the repository at this point in the history
  • Loading branch information
gsvgit committed Dec 22, 2023
1 parent 5e7da8a commit 640369c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions VSharp.ML.GameServer.Runner/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,35 @@ let ws checkActualCoverage outputDirectory (webSocket : WebSocket) (context: Htt
| Choice2Of2 error -> failwithf $"Error: %A{error}"

let predict =
let mutable cnt = 0u
fun (gameState:GameState) ->
let toDot () =
let file = System.IO.Path.Join ("dot",$"{cnt}.dot")
let vertices = ResizeArray<_>()
let edges = ResizeArray<_>()
for v in gameState.GraphVertices do
vertices.Add($"{v.Id} [label={v.Id}, shape=box]")
for s in v.States do
edges.Add($"99{s}00 -> {v.Id} [label=L]")
for s in gameState.States do
vertices.Add($"99{s.Id}00 [label={s.Id}, shape=circle]")
for v in s.Children do
edges.Add($"99{s.Id}00 -> 99{v}00 [label=ch]")
for v in s.History do
edges.Add($"99{s.Id}00 -> {v.GraphVertexId} [label={v.NumOfVisits}]")
for e in gameState.Map do
edges.Add($"{e.VertexFrom}->{e.VertexTo}[label={e.Label.Token}]")
let dot =
seq
{
"digraph g{"
yield! vertices
yield! edges
"}"
}
System.IO.File.WriteAllLines(file,dot)
cnt <- cnt + 1u
toDot()
let res =
socket {
do! sendResponse (ReadyForNextStep gameState)
Expand Down

0 comments on commit 640369c

Please sign in to comment.