diff --git a/TODO.txt b/TODO.txt index 14ab0ed..15f5369 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,14 +1,10 @@ BUGS ==== -* Fix "random" bug -* Pull fuzzie tree - Requests ======== -* Keep 12 hours of runs (720 runs) * Merge devdsp fixes (https://github.com/devdsp/tanks/commits/master) * Fix leaderboard * Read sensors from "sensors" and not "sensor[0-9]" diff --git a/ctanks.c b/ctanks.c index 7d7c7c5..76574d8 100644 --- a/ctanks.c +++ b/ctanks.c @@ -317,7 +317,7 @@ tanks_move_tank(struct tanks_game *game, to be a penalty for having the treads go in opposite directions. This probably plays hell with precisely-planned tanks, which I find very ha ha. */ - friction = .75 * (fabsf(tank->speed.current[0] - tank->speed.current[1]) / 200); + friction = TANK_FRICTION * (fabsf(tank->speed.current[0] - tank->speed.current[1]) / 200); v[0] = tank->speed.current[0] * (1 - friction) * (TANK_TOP_SPEED / 100.0); v[1] = tank->speed.current[1] * (1 - friction) * (TANK_TOP_SPEED / 100.0); diff --git a/ctanks.h b/ctanks.h index 4086176..57cb4e7 100644 --- a/ctanks.h +++ b/ctanks.h @@ -14,6 +14,7 @@ #define TANK_MAX_ACCEL 35 #define TANK_MAX_TURRET_ROT (TAU/8) #define TANK_TOP_SPEED 7 +#define TANK_FRICTION 0.75 /* (tank radius + tank radius)^2 */ #define TANK_COLLISION_ADJ2 \ diff --git a/run-tanks b/run-tanks index 3cabab8..062b38d 100755 --- a/run-tanks +++ b/run-tanks @@ -25,7 +25,7 @@ fn=$(printf "round-%04d.html" $next) rfn=results$$.txt # Clean up old games -ofn=$(printf "round-%04d.html" $(expr $next - 20)) +ofn=$(printf "round-%04d.html" $(expr $next - 720)) echo "Removing $ofn" rm -f $ofn @@ -64,8 +64,7 @@ cat <>$fn EOF -summary.awk $tanks > summary.html.$$ -mv summary.html.$$ summary.html +summary.awk $tanks > summary.html.$$ && mv summary.html.$$ summary.html echo "done." diff --git a/summary.awk b/summary.awk index bb16356..dbab44f 100755 --- a/summary.awk +++ b/summary.awk @@ -1,89 +1,89 @@ #! /usr/bin/awk -f function esc(s) { - gsub(/&/, "&", s); - gsub(//, ">", s); - return s; + gsub(/&/, "&", s); + gsub(//, ">", s); + return s; } BEGIN { - ngames = 20; + ngames = 20; - print ""; - print ""; - print " "; - print " Dirtbags Tanks"; - print " "; - print " "; - print " "; - print "

Dirtbags Tanks

"; + print ""; + print ""; + print " "; + print " Dirtbags Tanks"; + print " "; + print " "; + print " "; + print "

Dirtbags Tanks

"; - print "

New here? Read the introduction.

"; - print "

New round every minute.

"; - print "

Rankings

"; - print "

Over the last 20 games only.

"; - print "
    "; - for (i = 1; i < ARGC; i += 1) { - id = ARGV[i]; + print "

    New here? Read the introduction.

    "; + print "

    New round every minute.

    "; + print "

    Rankings

    "; + print "

    Over the last 20 games only.

    "; + print "
      "; + for (i = 1; i < ARGC; i += 1) { + id = ARGV[i]; - if (1 == getline < (id "/name")) { - names[id] = esc($0); - } else { - names[id] = "Unnamed"; - } + if (1 == getline < (id "/name")) { + names[id] = esc($0); + } else { + names[id] = "Unnamed"; + } - getline < (id "/color"); - if (/^#[0-9A-Fa-f]+$/) { - color[id] = $0; - } else { - color[id] = "#c0c0c0"; - } + getline < (id "/color"); + if (/^#[0-9A-Fa-f]+$/) { + color[id] = $0; + } else { + color[id] = "#c0c0c0"; + } - for (j = 0; 1 == getline < (id "/points"); j += 1) { - pts[id, j % ngames] = int($0); - } - total = 0; - for (j = 0; j < ngames; j += 1) { - total += pts[id, j]; - } - scores[total] = total; - points[id] = total; - } - while (1) { - # Find highest score - maxscore = -1; - for (p in scores) { - if (int(p) > maxscore) { - maxscore = int(p); - } - } - if (maxscore == -1) { - break; - } - delete scores[maxscore]; + for (j = 0; 1 == getline < (id "/points"); j += 1) { + pts[id, j % ngames] = int($0); + } + total = 0; + for (j = 0; j < ngames; j += 1) { + total += pts[id, j]; + } + scores[total] = total; + points[id] = total; + } + while (1) { + # Find highest score + maxscore = -1; + for (p in scores) { + if (int(p) > maxscore) { + maxscore = int(p); + } + } + if (maxscore == -1) { + break; + } + delete scores[maxscore]; - for (id in points) { - if (points[id] == maxscore) { - printf("
    1. # %s (%d points)
    2. \n", color[id], names[id], points[id]); - } - } - } - print "
    "; + for (id in points) { + if (points[id] == maxscore) { + printf("
  1. # %s (%d points)
  2. \n", color[id], names[id], points[id]); + } + } + } + print "
"; - print "

Rounds

"; - print " "; + print "

Rounds

"; + print " "; - while (getline < ENVIRON["NAV_HTML_INC"]) { - print; - } + while (getline < ENVIRON["NAV_HTML_INC"]) { + print; + } - print " "; - print ""; + print " "; + print ""; }