From 11ec9d5d14058cfac706da7c9de3e432894e718b Mon Sep 17 00:00:00 2001 From: ManDude <7569514+ManDude@users.noreply.github.com> Date: Thu, 29 Sep 2022 19:10:58 +0100 Subject: [PATCH] write a function that outputs a `dot` graph of the jak 2 tasks (#1932) --- goal_src/jak2/examples/debug-jak2.gc | 82 +++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/goal_src/jak2/examples/debug-jak2.gc b/goal_src/jak2/examples/debug-jak2.gc index 46481b56ba..1361979a98 100644 --- a/goal_src/jak2/examples/debug-jak2.gc +++ b/goal_src/jak2/examples/debug-jak2.gc @@ -244,4 +244,84 @@ ) ) proc) - ) \ No newline at end of file + ) + +(defun levelname->x11-color ((name symbol)) + (case name + (('city) "khaki") + (('fortress) "salmon") + (('stadium) "yellow") + (('palace) "hotpink") + (('castle) "gray") + (('ruins) "darkkhaki") + (('atoll) "gold") + (('sewer) "turquoise") + (('strip) "white") + (('mountain) "tan") + (('forest) "limegreen") + (('drill) "seagreen") + (('tomb) "chartreuse") + (('dig) "orange") + (('canyon) "#008B8B") + (('consite) "#90EE90") + (('under) "dodgerblue") + (('nest) "violet") + (('default) "white") + (('test) "purple") + (else "magenta") + ) + ) + +(defun print-task-node-tree-graphviz () + + (format #t "digraph G {~%") + (format #t " node [style=filled shape=ellipse]~%~%") + (let ((game-tasks (-> *game-info* play-list))) + (dotimes (t (-> game-tasks length)) + (let ((task (-> game-tasks t))) + (format #t " subgraph cluster_task_~D {~%" t) + (format #t " label = ~A;~%" (-> task name)) + (format #t " style = filled;~%") + (format #t " fontsize = \"25pt\";~%") + (cond + ((and (>= t (game-task fortress-escape)) + (<= t (game-task nest-boss)) + (!= t (game-task city-blue-gun-training)) + (!= t (game-task city-dark-gun-training))) + (format #t " fillcolor = lightgray;~%") + ) + ((and (>= t (game-task city-burning-bush-ring-1)) + (<= t (game-task stadium-burning-bush-race-class1-r))) + (format #t " fillcolor = pink;~%") + ) + (else + (format #t " fillcolor = lightyellow;~%") + ) + ) + (let ((game-nodes (-> *game-info* sub-task-list))) + (dotimes (i (-> game-nodes length)) + (let ((node (-> game-nodes i))) + (when (= t (-> node task)) + ;; iterate through parents + (dotimes (ii 4) + (when (!= (game-task-node none) (-> node parent-node ii)) + (format #t " ~A -> ~A;~%" (game-task-node->string (-> node parent-node ii)) (-> node name)) + ) + ) + (format #t " ~A [fillcolor=~A shape=~S];~%" (-> node name) (levelname->x11-color (-> node level)) + (cond + ((logtest? (-> node flags) (game-task-node-flag close-task)) + "oval") + (else + "box"))) + ) + ) + ) + (format #t " }~%") + ) + ) + ) + ) + (format #t "}~%") + 0) +