mirror of https://github.com/dirtbags/tanks.git
More fixes
This commit is contained in:
parent
962e08bd50
commit
dfacb42dee
4
TODO.txt
4
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]"
|
||||
|
|
2
ctanks.c
2
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);
|
||||
|
||||
|
|
1
ctanks.h
1
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 \
|
||||
|
|
|
@ -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 <<EOF >>$fn
|
|||
</html>
|
||||
EOF
|
||||
|
||||
summary.awk $tanks > summary.html.$$
|
||||
mv summary.html.$$ summary.html
|
||||
summary.awk $tanks > summary.html.$$ && mv summary.html.$$ summary.html
|
||||
|
||||
echo "done."
|
||||
|
||||
|
|
144
summary.awk
144
summary.awk
|
@ -1,89 +1,89 @@
|
|||
#! /usr/bin/awk -f
|
||||
|
||||
function esc(s) {
|
||||
gsub(/&/, "&", s);
|
||||
gsub(/</, "<", s);
|
||||
gsub(/>/, ">", s);
|
||||
return s;
|
||||
gsub(/&/, "&", s);
|
||||
gsub(/</, "<", s);
|
||||
gsub(/>/, ">", s);
|
||||
return s;
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
ngames = 20;
|
||||
ngames = 20;
|
||||
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html>";
|
||||
print " <head>";
|
||||
print " <title>Dirtbags Tanks</title>";
|
||||
print " <link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">";
|
||||
print " </head>";
|
||||
print " <body>";
|
||||
print " <h1>Dirtbags Tanks</h1>";
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html>";
|
||||
print " <head>";
|
||||
print " <title>Dirtbags Tanks</title>";
|
||||
print " <link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">";
|
||||
print " </head>";
|
||||
print " <body>";
|
||||
print " <h1>Dirtbags Tanks</h1>";
|
||||
|
||||
print " <p>New here? Read the <a href=\"intro.html\">introduction</a>.</p>";
|
||||
print " <p>New round every minute.</p>";
|
||||
print " <h2>Rankings</h2>";
|
||||
print " <p>Over the last 20 games only.</p>";
|
||||
print " <ol>";
|
||||
for (i = 1; i < ARGC; i += 1) {
|
||||
id = ARGV[i];
|
||||
print " <p>New here? Read the <a href=\"intro.html\">introduction</a>.</p>";
|
||||
print " <p>New round every minute.</p>";
|
||||
print " <h2>Rankings</h2>";
|
||||
print " <p>Over the last 20 games only.</p>";
|
||||
print " <ol>";
|
||||
for (i = 1; i < ARGC; i += 1) {
|
||||
id = ARGV[i];
|
||||
|
||||
if (1 == getline < (id "/name")) {
|
||||
names[id] = esc($0);
|
||||
} else {
|
||||
names[id] = "<i>Unnamed</i>";
|
||||
}
|
||||
if (1 == getline < (id "/name")) {
|
||||
names[id] = esc($0);
|
||||
} else {
|
||||
names[id] = "<i>Unnamed</i>";
|
||||
}
|
||||
|
||||
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("<li><span class=\"swatch\" style=\"background-color: %s;\">#</span> %s (%d points)</li>\n", color[id], names[id], points[id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
print " </ol>";
|
||||
for (id in points) {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
print " </ol>";
|
||||
|
||||
print " <h2>Rounds</h2>";
|
||||
print " <ul>";
|
||||
getline rounds < "next-round";
|
||||
for (i = rounds - 1; i >= rounds - 21; i -= 1) {
|
||||
printf("<li><a href=\"round-%04d.html\">%04d</a></li>\n", i, i);
|
||||
}
|
||||
print " </ul>";
|
||||
print " <h2>Rounds</h2>";
|
||||
print " <ul>";
|
||||
getline rounds < "next-round";
|
||||
for (i = rounds - 1; (i >= rounds - 720) && (i > 0); i -= 1) {
|
||||
printf("<li><a href=\"round-%04d.html\">%04d</a></li>\n", i, i);
|
||||
}
|
||||
print " </ul>";
|
||||
|
||||
while (getline < ENVIRON["NAV_HTML_INC"]) {
|
||||
print;
|
||||
}
|
||||
while (getline < ENVIRON["NAV_HTML_INC"]) {
|
||||
print;
|
||||
}
|
||||
|
||||
print " </body>";
|
||||
print "</html>";
|
||||
print " </body>";
|
||||
print "</html>";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue