From 8c2e679bee586b63aa8e647cdd9aff4bd06b8065 Mon Sep 17 00:00:00 2001 From: jadedctrl Date: Mon, 27 Mar 2017 07:04:52 -0500 Subject: [PATCH] Optimized rendering (43 seconds to 20) --- README.md | 8 ++++++++ lib | 2 +- render.sh | 27 +++++++++++++++++++++++---- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9c131a4..06def9f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,10 @@ # unixchesscollection UCC - A POSIX chess game that adheres to the Unix philosophy +Don't expect much just yet. +Roadmap (in order): +* JSON interpreter read support +* Rendering chess game JSON files +* Move validation +* JSON interpreter write support +* Move writing +* Wrapper script diff --git a/lib b/lib index c347eb5..e68ded3 160000 --- a/lib +++ b/lib @@ -1 +1 @@ -Subproject commit c347eb502beb52b63868f36051c0aa913f59a715 +Subproject commit e68ded350c8dc035b3be24a7eb5688393b3b02d2 diff --git a/render.sh b/render.sh index 7df8925..ef7749f 100644 --- a/render.sh +++ b/render.sh @@ -13,11 +13,30 @@ do while [ $widthi -ne $width ] do widthi=$((widthi+1)) - piece=$(lib/json.sh -s ${widthi},${heighti}/piece $file) - team=$(lib/json.sh -s ${widthi},${heighti}/team $file) - text=$(lib/json.sh -s ${team}/pieces/${piece}/text $file) - if [ -z $text ] + if grep "${widthi},${heighti}" $file > /dev/null then + point_data=$(sh lib/json.sh $file | grep board/pieces/${widthi},${heighti}/ | grep =) + point_data=$(echo $point_data | sed 's/ = /=/g' | sed 's/ /^/g') + echo $point_data + string_one=$(echo $point_data | sed 's/.*^//') + echo $string_one + string_two=$(echo $point_data | sed 's/^.*//') + echo $string_two + if echo $string_one | grep team= + then + team=$string_one + piece=$string_two + elif echo $string_one | grep piece= + then + piece=$string_one + team=$string_two + fi + echo $string_one + echo $string_two + echo $piece + echo $team + text=$(sh lib/json.sh -s ${team}/pieces/${piece}/text $file) + else text=" " fi if [ $(echo "$heighti % 2" | bc) -eq 1 ]