More fixes

This commit is contained in:
Neale Pickett 2014-07-28 20:32:24 +00:00
parent 962e08bd50
commit dfacb42dee
5 changed files with 76 additions and 80 deletions

View File

@ -1,14 +1,10 @@
BUGS BUGS
==== ====
* Fix "random" bug
* Pull fuzzie tree
Requests Requests
======== ========
* Keep 12 hours of runs (720 runs)
* Merge devdsp fixes (https://github.com/devdsp/tanks/commits/master) * Merge devdsp fixes (https://github.com/devdsp/tanks/commits/master)
* Fix leaderboard * Fix leaderboard
* Read sensors from "sensors" and not "sensor[0-9]" * Read sensors from "sensors" and not "sensor[0-9]"

View File

@ -317,7 +317,7 @@ tanks_move_tank(struct tanks_game *game,
to be a penalty for having the treads go in opposite directions. to be a penalty for having the treads go in opposite directions.
This probably plays hell with precisely-planned tanks, which I This probably plays hell with precisely-planned tanks, which I
find very ha ha. */ 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[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); v[1] = tank->speed.current[1] * (1 - friction) * (TANK_TOP_SPEED / 100.0);

View File

@ -14,6 +14,7 @@
#define TANK_MAX_ACCEL 35 #define TANK_MAX_ACCEL 35
#define TANK_MAX_TURRET_ROT (TAU/8) #define TANK_MAX_TURRET_ROT (TAU/8)
#define TANK_TOP_SPEED 7 #define TANK_TOP_SPEED 7
#define TANK_FRICTION 0.75
/* (tank radius + tank radius)^2 */ /* (tank radius + tank radius)^2 */
#define TANK_COLLISION_ADJ2 \ #define TANK_COLLISION_ADJ2 \

View File

@ -25,7 +25,7 @@ fn=$(printf "round-%04d.html" $next)
rfn=results$$.txt rfn=results$$.txt
# Clean up old games # Clean up old games
ofn=$(printf "round-%04d.html" $(expr $next - 20)) ofn=$(printf "round-%04d.html" $(expr $next - 720))
echo "Removing $ofn" echo "Removing $ofn"
rm -f $ofn rm -f $ofn
@ -64,8 +64,7 @@ cat <<EOF >>$fn
</html> </html>
EOF EOF
summary.awk $tanks > summary.html.$$ summary.awk $tanks > summary.html.$$ && mv summary.html.$$ summary.html
mv summary.html.$$ summary.html
echo "done." echo "done."

View File

@ -1,89 +1,89 @@
#! /usr/bin/awk -f #! /usr/bin/awk -f
function esc(s) { function esc(s) {
gsub(/&/, "&amp;", s); gsub(/&/, "&amp;", s);
gsub(/</, "&lt;", s); gsub(/</, "&lt;", s);
gsub(/>/, "&gt;", s); gsub(/>/, "&gt;", s);
return s; return s;
} }
BEGIN { BEGIN {
ngames = 20; ngames = 20;
print "<!DOCTYPE html>"; print "<!DOCTYPE html>";
print "<html>"; print "<html>";
print " <head>"; print " <head>";
print " <title>Dirtbags Tanks</title>"; print " <title>Dirtbags Tanks</title>";
print " <link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">"; print " <link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">";
print " </head>"; print " </head>";
print " <body>"; print " <body>";
print " <h1>Dirtbags Tanks</h1>"; print " <h1>Dirtbags Tanks</h1>";
print " <p>New here? Read the <a href=\"intro.html\">introduction</a>.</p>"; print " <p>New here? Read the <a href=\"intro.html\">introduction</a>.</p>";
print " <p>New round every minute.</p>"; print " <p>New round every minute.</p>";
print " <h2>Rankings</h2>"; print " <h2>Rankings</h2>";
print " <p>Over the last 20 games only.</p>"; print " <p>Over the last 20 games only.</p>";
print " <ol>"; print " <ol>";
for (i = 1; i < ARGC; i += 1) { for (i = 1; i < ARGC; i += 1) {
id = ARGV[i]; id = ARGV[i];
if (1 == getline < (id "/name")) { if (1 == getline < (id "/name")) {
names[id] = esc($0); names[id] = esc($0);
} else { } else {
names[id] = "<i>Unnamed</i>"; names[id] = "<i>Unnamed</i>";
} }
getline < (id "/color"); getline < (id "/color");
if (/^#[0-9A-Fa-f]+$/) { if (/^#[0-9A-Fa-f]+$/) {
color[id] = $0; color[id] = $0;
} else { } else {
color[id] = "#c0c0c0"; color[id] = "#c0c0c0";
} }
for (j = 0; 1 == getline < (id "/points"); j += 1) { for (j = 0; 1 == getline < (id "/points"); j += 1) {
pts[id, j % ngames] = int($0); pts[id, j % ngames] = int($0);
} }
total = 0; total = 0;
for (j = 0; j < ngames; j += 1) { for (j = 0; j < ngames; j += 1) {
total += pts[id, j]; total += pts[id, j];
} }
scores[total] = total; scores[total] = total;
points[id] = total; points[id] = total;
} }
while (1) { while (1) {
# Find highest score # Find highest score
maxscore = -1; maxscore = -1;
for (p in scores) { for (p in scores) {
if (int(p) > maxscore) { if (int(p) > maxscore) {
maxscore = int(p); maxscore = int(p);
} }
} }
if (maxscore == -1) { if (maxscore == -1) {
break; break;
} }
delete scores[maxscore]; delete scores[maxscore];
for (id in points) { for (id in points) {
if (points[id] == maxscore) { if (points[id] == maxscore) {
printf("<li><span class=\"swatch\" style=\"background-color: %s;\">#</span> %s (%d points)</li>\n", color[id], names[id], points[id]); printf("<li><span class=\"swatch\" style=\"background-color: %s;\">#</span> %s (%d points)</li>\n", color[id], names[id], points[id]);
} }
} }
} }
print " </ol>"; print " </ol>";
print " <h2>Rounds</h2>"; print " <h2>Rounds</h2>";
print " <ul>"; print " <ul>";
getline rounds < "next-round"; getline rounds < "next-round";
for (i = rounds - 1; i >= rounds - 21; i -= 1) { for (i = rounds - 1; (i >= rounds - 720) && (i > 0); i -= 1) {
printf("<li><a href=\"round-%04d.html\">%04d</a></li>\n", i, i); printf("<li><a href=\"round-%04d.html\">%04d</a></li>\n", i, i);
} }
print " </ul>"; print " </ul>";
while (getline < ENVIRON["NAV_HTML_INC"]) { while (getline < ENVIRON["NAV_HTML_INC"]) {
print; print;
} }
print " </body>"; print " </body>";
print "</html>"; print "</html>";
} }