diff --git a/Makefile b/Makefile index ba00e2d..07c6f88 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CFLAGS = -Wall all: html run-tanks designer.cgi -html: forf.html +html: forf.html procs.html intro.html run-tanks: run-tanks.o ctanks.o forf.o run-tanks: LDFLAGS = -lm @@ -10,8 +10,10 @@ run-tanks.o: forf.h ctanks.h forf.o: forf.c forf.h ctanks.o: ctanks.h -forf.html: forf.html.sh forf/forf.txt - ./forf.html.sh > $@ +%.html: %.html.m4 + m4 $< > $@ + +forf.html: forf/forf.txt forf.%: forf/forf.% cp forf/$@ $@ diff --git a/ctanks.h b/ctanks.h index da42fe7..e540d2d 100644 --- a/ctanks.h +++ b/ctanks.h @@ -1,10 +1,11 @@ #ifndef __CTANKS_H__ #define __CTANKS_H__ -/* Some useful constants */ +/* τ = 2π */ #define TAU 6.28318530717958647692 #define PI 3.14159265358979323846 +/* Some in-game constants */ #define TANK_MAX_SENSORS 10 #define TANK_RADIUS 7.5 #define TANK_SENSOR_RANGE 100 diff --git a/dirtbags.css b/dirtbags.css index 8c71432..97ea65b 100644 --- a/dirtbags.css +++ b/dirtbags.css @@ -30,7 +30,7 @@ h1:first-child:before { /*** left side bar ***/ -#navigation { +nav { position: absolute; background: #222; opacity: 0.9; @@ -39,18 +39,18 @@ h1:first-child:before { padding: 0; } -#navigation h3 { +nav h2 { font-size: 100%; border-bottom: 2px solid #444; } -#navigation ul { +nav ul { list-style: none; padding: 0; margin: 0; } -#navigation li a { +nav li a { display: block; height: 25px; width: 90px; @@ -63,13 +63,13 @@ h1:first-child:before { font-size: 0.9em; } -#navigation li a:hover { +nav li a:hover { color: #f4f4f4; background: #333; border-right: 4px solid #2a2; } -#navigation li .active { +nav li .active { color: #999; background: #333; border-right: 4px solid #444; diff --git a/dump.h b/dump.h index 514f676..4553643 100644 --- a/dump.h +++ b/dump.h @@ -2,6 +2,10 @@ #include +#ifndef TAU +#define TAU 6.28318530717958647692 +#endif + /* Debugging */ #define DUMPf(fmt, args...) fprintf(stderr, "%s:%s:%d " fmt "\n", __FILE__, __FUNCTION__, __LINE__, ##args) #define DUMP() DUMPf("") @@ -12,6 +16,7 @@ #define DUMP_f(v) DUMPf("%s = %f", #v, v) #define DUMP_p(v) DUMPf("%s = %p", #v, v) #define DUMP_xy(v) DUMPf("%s = (%f, %f)", #v, v[0], v[1]); +#define DUMP_angle(v) DUMPf("%s = %.3fτ", #v, (v/TAU)); /* Tektronix 4014 drawing */ #define TEK_ENABLE "\033[?38h" diff --git a/forf.html.sh b/forf.html.m4 old mode 100755 new mode 100644 similarity index 71% rename from forf.html.sh rename to forf.html.m4 index 3aeceaa..e8e45eb --- a/forf.html.sh +++ b/forf.html.m4 @@ -1,6 +1,4 @@ -#! /bin/sh - -cat < Forf Manual @@ -8,9 +6,8 @@ cat < -EOF -markdown forf/forf.txt -cat < -EOF + diff --git a/intro.html b/intro.html.m4 similarity index 99% rename from intro.html rename to intro.html.m4 index c59f48c..1784b92 100644 --- a/intro.html +++ b/intro.html.m4 @@ -143,4 +143,5 @@ get-turret 12 + set-turret! ( Rotate turret ) Good luck blowing everybody up! +include(nav.html.inc) diff --git a/nav.html.inc b/nav.html.inc new file mode 100644 index 0000000..3c8470a --- /dev/null +++ b/nav.html.inc @@ -0,0 +1,10 @@ + diff --git a/procs.html b/procs.html.m4 similarity index 98% rename from procs.html rename to procs.html.m4 index c902b18..f6ead12 100644 --- a/procs.html +++ b/procs.html.m4 @@ -66,6 +66,8 @@
Returns a random number in the range [0, n). That is, between 0 and n-1, inclusive.
+ +include(nav.html.inc) diff --git a/rank.awk b/rank.awk index 9cd482b..45acf41 100755 --- a/rank.awk +++ b/rank.awk @@ -65,10 +65,10 @@ END { if (killer[id]) { reason[id] = reason[id] " (" name[killer[id]] ")"; } + print score[id] >> (path[id] "/points"); } - # Give the winner a point - print "1" >> (path[winner] "/points"); + # Dole out points # Output the table print ""; diff --git a/round.sh b/round.sh index de60ce0..0d8734e 100755 --- a/round.sh +++ b/round.sh @@ -41,11 +41,13 @@ window.onload = go; +

Tanks Round $next

0 fps

EOF ./rank.awk $rfn >>$fn rm -f $rfn +cat nav.html.inc >>$fn cat <>$fn diff --git a/summary.awk b/summary.awk index bc802c2..d3267ef 100755 --- a/summary.awk +++ b/summary.awk @@ -8,6 +8,8 @@ function esc(s) { } BEGIN { + ngames = 20; + print ""; print ""; print " "; @@ -17,15 +19,9 @@ BEGIN { print " "; print "

Dirtbags Tanks

"; - print "

Resources

"; - print " "; - + print "

New here? Read the introduction.

"; print "

Rankings

"; + print "

Over the last 20 games only.

"; print "
    "; for (i = 1; i < ARGC; i += 1) { id = ARGV[i]; @@ -43,13 +39,16 @@ BEGIN { color[id] = "#c0c0c0"; } - p = 0; - while (1 == getline < (id "/points")) { - p += $0; + + for (j = 0; 1 == getline < (id "/points"); j += 1) { + pts[id, j % ngames] = int($0); } - scores[p] = p; - points[id] = p; - nscores + total = 0; + for (j = 0; j < ngames; j += 1) { + total += pts[id, j]; + } + scores[total] = total; + points[id] = total; } while (1) { # Find highest score @@ -66,7 +65,7 @@ BEGIN { for (id in points) { if (points[id] == maxscore) { - printf("
  1. # %s (%d wins)
  2. \n", color[id], names[id], points[id]); + printf("
  3. # %s (%d points)
  4. \n", color[id], names[id], points[id]); } } } @@ -79,6 +78,11 @@ BEGIN { printf("
  5. %04d
  6. \n", i, i); } print " "; + + while (getline < "nav.html.inc") { + print; + } + print " "; print ""; }