From 54b8a7b46eae030ca63c591bd4e9256cdda22fb4 Mon Sep 17 00:00:00 2001
From: Manuel Bucher <manuel.bucher@hu-berlin.de>
Date: Sun, 24 Jun 2018 13:05:37 +0200
Subject: [PATCH] added debug programs

---
 Makefile           |  4 ++--
 check              |  2 ++
 loesung.c          |  3 +--
 visulize.py        | 21 +++++++++++++++++++++
 visulize_result.py | 24 ++++++++++++++++++++++++
 5 files changed, 50 insertions(+), 4 deletions(-)
 create mode 100755 check
 create mode 100755 visulize.py
 create mode 100755 visulize_result.py

diff --git a/Makefile b/Makefile
index 742516b..34b60e8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,9 @@
 all: loesung
 
-WARNINGS = -Wall #-Werror
+WARNINGS = -Wall -Werror
 OPTIONAL = -Wextra -Wpedantic -Wshadow
 DEBUG = -g -ggdb -fno-omit-frame-pointer
-OPTIMIZE = -Og -std=c11
+OPTIMIZE = -std=c11
 
 loesung: Makefile loesung.c
 	$(CC) -o $@ $(WARNINGS) $(OPTIONAL) $(DEBUG) $(OPTIMIZE) loesung.c
diff --git a/check b/check
new file mode 100755
index 0000000..2a419bf
--- /dev/null
+++ b/check
@@ -0,0 +1,2 @@
+#!/bin/bash
+./loesung <$1 | ./check_result $1
diff --git a/loesung.c b/loesung.c
index c319c2a..1d9d06b 100755
--- a/loesung.c
+++ b/loesung.c
@@ -303,8 +303,7 @@ bool hk_dfs(Field *this, uint32_t e) {
 void hk_print(Field *this) {
     Tile *t = this->tiles;
     for (uint32_t i = 1; i < this->num_tiles; i++) {
-        uint32_t p = t[i].pair;
-        if (this->tiles[i].pair == 0) {
+        if (t[i].pair == 0) {
             printf("None\n");
             return;
         }
diff --git a/visulize.py b/visulize.py
new file mode 100755
index 0000000..1a4093e
--- /dev/null
+++ b/visulize.py
@@ -0,0 +1,21 @@
+#!/usr/bin/python3
+import sys
+import matplotlib.pyplot as plt
+import numpy as np
+inp = sys.argv[1]
+
+def load():
+    f = open(inp)
+    xs = []
+    ys = []
+    for line in f:
+        point = [int(i) for i in line.split()]
+        xs.append(point[0])
+        ys.append(point[1])
+
+    plt.scatter(xs, ys, marker="s")
+    plt.show()
+
+while True:
+    load()
+
diff --git a/visulize_result.py b/visulize_result.py
new file mode 100755
index 0000000..b4000aa
--- /dev/null
+++ b/visulize_result.py
@@ -0,0 +1,24 @@
+#!/usr/bin/python3
+import sys
+import matplotlib.pyplot as plt
+import numpy as np
+inp = sys.argv[1]
+
+def load():
+    f = open(inp)
+    xs = []
+    ys = []
+    for line in f:
+        for p in line.split(";"):
+            point = [int(i) for i in p.split()]
+            xs.append(point[0])
+            ys.append(point[1])
+        xs.append(None)
+        ys.append(None)
+
+    plt.plot(xs, ys, marker="s")
+    plt.show()
+
+while True:
+    load()
+
-- 
GitLab