From 318fd72e5806b663fd7fa7a83acb9b7e409500f0 Mon Sep 17 00:00:00 2001 From: dsc Date: Mon, 22 Nov 2010 11:24:11 -0800 Subject: [PATCH] Adds docs, custom AI panel. --- .gitignore | 1 + ai-challenge.md | 27 ----------------- ai.md | 31 ------------------- bin/deploy.sh | 4 ++ css/lttl.css | 8 ++++- doc/ai-challenge.md | 27 +++++++++++++++++ doc/ai.md | 32 ++++++++++++++++++++ doc/gameplay.md | 63 ++++++++++++++++++++++++++++++++++++++++ doc/notes.md | 25 ++++++++++++++++ index.php | 10 ++++++- notes.md | 25 ---------------- src/tanks/main.js | 20 +++++++++++- src/tanks/thing/custom-tank.js | 8 +++++ src/tanks/thing/player.js | 19 +++++++----- tanks.php | 1 + 15 files changed, 206 insertions(+), 95 deletions(-) create mode 100644 .gitignore delete mode 100644 ai-challenge.md delete mode 100644 ai.md create mode 100644 doc/ai-challenge.md create mode 100644 doc/ai.md create mode 100644 doc/gameplay.md create mode 100644 doc/notes.md delete mode 100644 notes.md create mode 100644 src/tanks/thing/custom-tank.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c5083f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.md.html diff --git a/ai-challenge.md b/ai-challenge.md deleted file mode 100644 index 3aa28d7..0000000 --- a/ai-challenge.md +++ /dev/null @@ -1,27 +0,0 @@ -# The Tank AI Challenge - -Your goal is to design an AI tank which does its best to: 1) stay alive; 2) kill all enemy tanks. - -Rules: -- All tanks have 1hp. -- Tanks shoot bullets. Bullets explode on contact with tanks and other bullets, and bounce once on contact with a wall. -- Each tank can have up to 5 bullets in the air at a time. - -Each tick, you get a bunch of inputs: -- A pathmap of the level (which you can ask whether an area is passable) -- A list of friendly and enemy units (including bullets), each with its attributes (trajectory, position, hp, speed, power, shots, etc) -- Your attributes (position, hp, speed, power, etc) - -Ticks occur 30 times per second. When called, you'll return one action, which can be: -- Move toward (x,y) -- Fire a projectile toward (x,y) -- Do nothing -That is all. - -An AI script looks like a list of ordered (test, action) pairs. The game will consider each test in turn, and the first matching will be the action taken. Here's an example: - -- If there is a bullet that will collide with me in less than 15 ticks, shoot a bullet at its location. -- If there is a bullet that will collide with me in less than 30 ticks, move perpendicular to its trajectory. -- If there is an enemy within 100 pixels, shoot a bullet at it. -- Finally, move toward the closest enemy tank. - diff --git a/ai.md b/ai.md deleted file mode 100644 index 0dab8e6..0000000 --- a/ai.md +++ /dev/null @@ -1,31 +0,0 @@ -# Tank AI Language - -## Types - -- `Loc`: Object with properties `x` and `y`, representing a position on the map. -- `Rect`: Object with properties `x1`, `y1`, `x2`, `y2`, representing the top-left and bottom-right locations of a region on the map. -- `Agent`: An object that reprensents both your tank and all agents discovered with various lookup methods. See below for properties. - -## Agent Properties - -- `stats`: Agent's stats. - - `hp`: Agent's health. - - `move`: Agent's move speed in squares/sec. - - `speed`: Agent's attack cooldown wait-time in sec. - - `shots`: Maximum projectiles the agent can have in the air at once. -- `loc`: Loc of the top-left point of the agent on the map. -- `boundingBox`: Rect of the agent's absolute map position. -- `midpoint`: Loc of the agent's midpoint position on the map. -- `nShots`: Number of shots the agent currently has in the air. - -## Functions - -- `shoot(x,y)`: Fires a shot at (x,y) if possible. -- `move(x,y)`: Moves directly toward (x,y) if possible. -- `ableToShoot()` -> `Boolean`: Whether your tank is able to fire at the moment. -- `find(x1,y1,x2,y2)` -> `Agent[]` -- `findNearLike(ticks, filter)` -> `Agent[]`: Returns a list of agents within `ticks` movement distance away that match the filter. -- `findClosest(agents)` -> `Agent`: Returns the closest agent to this tank in the supplied list, or null if none are supplied. -- `calculatePath(point)` -- `calculatePath(x,y)`: Calculates a path from your current location to (x,y), taking into account walls, and then queues it for future moves. - diff --git a/bin/deploy.sh b/bin/deploy.sh index 5251783..7f627eb 100755 --- a/bin/deploy.sh +++ b/bin/deploy.sh @@ -16,6 +16,10 @@ for opt in $*; do echo $opt | egrep -xq -e '--?h(e(lp?)?)?' && { halp; exit 0; } done +for md in doc/*.md; do + markdown $md -f $md.html +done + EXCLUDE="--exclude=$(join ' --exclude=' 'tmp' $*)" echo "rsync -Cavz --delete $EXCLUDE ./* less.ly:lessly/hacking/tanks/" rsync -Cavz --delete $EXCLUDE ./* less.ly:lessly/hacking/tanks/ diff --git a/css/lttl.css b/css/lttl.css index b293744..051d12c 100644 --- a/css/lttl.css +++ b/css/lttl.css @@ -36,11 +36,17 @@ table.grid td { /* outline:1px solid rgba(255,255,255,0.1); */ .countdown { position:fixed; overflow:hidden; z-index:1000; text-align:center; border:10px solid #fff; color:#fff; } +#ai { position:absolute; z-index:1002; width:80%; left:10%; } + #ai h2 { font-size:1.3em; } + #ai .box { width:100%; } + #ai .ready { width:5%; float:left; margin-right:1em; } + #ai textarea { width:90%; height:100px; } + #viewport { position:relative; width:500px; height:500px; margin:1em auto; cursor:crosshair; } #overlay { position:fixed; top:0; left:0; width:100%; height:100%; background-color:#000; opacity:0.5; z-index:100; } -#welcome { cursor:pointer; } +#welcome .box { cursor:pointer; } #notes { /* position:fixed; top:4em; right:1em; color:#BFBFBF;*/ } #notes ul, #notes ol, #notes li { list-style:circle ! important; } #notes li { margin-left:1em; } diff --git a/doc/ai-challenge.md b/doc/ai-challenge.md new file mode 100644 index 0000000..3aa28d7 --- /dev/null +++ b/doc/ai-challenge.md @@ -0,0 +1,27 @@ +# The Tank AI Challenge + +Your goal is to design an AI tank which does its best to: 1) stay alive; 2) kill all enemy tanks. + +Rules: +- All tanks have 1hp. +- Tanks shoot bullets. Bullets explode on contact with tanks and other bullets, and bounce once on contact with a wall. +- Each tank can have up to 5 bullets in the air at a time. + +Each tick, you get a bunch of inputs: +- A pathmap of the level (which you can ask whether an area is passable) +- A list of friendly and enemy units (including bullets), each with its attributes (trajectory, position, hp, speed, power, shots, etc) +- Your attributes (position, hp, speed, power, etc) + +Ticks occur 30 times per second. When called, you'll return one action, which can be: +- Move toward (x,y) +- Fire a projectile toward (x,y) +- Do nothing +That is all. + +An AI script looks like a list of ordered (test, action) pairs. The game will consider each test in turn, and the first matching will be the action taken. Here's an example: + +- If there is a bullet that will collide with me in less than 15 ticks, shoot a bullet at its location. +- If there is a bullet that will collide with me in less than 30 ticks, move perpendicular to its trajectory. +- If there is an enemy within 100 pixels, shoot a bullet at it. +- Finally, move toward the closest enemy tank. + diff --git a/doc/ai.md b/doc/ai.md new file mode 100644 index 0000000..5f4d6fb --- /dev/null +++ b/doc/ai.md @@ -0,0 +1,32 @@ +# Tank AI Language + +## Types + +- `Loc`: Object with properties `x` and `y`, representing a position on the map. +- `Rect`: Object with properties `x1`, `y1`, `x2`, `y2`, representing the top-left and bottom-right locations of a region on the map. +- `Agent`: An object that reprensents both your tank and all agents discovered with various lookup methods. See below for properties. + +## Agent Properties + +- `stats`: Agent's stats. + - `hp`: Agent's health. + - `move`: Agent's move speed in squares/sec. + - `speed`: Agent's attack cooldown wait-time in sec. + - `shots`: Maximum projectiles the agent can have in the air at once. +- `loc`: Loc of the top-left point of the agent on the map. +- `boundingBox`: Rect of the agent's absolute map position. +- `midpoint`: Loc of the agent's midpoint position on the map. +- `nShots`: Number of shots the agent currently has in the air. + +## Functions + +- `shoot(x,y)`: Fires a shot at (x,y) if possible. +- `move(x,y)`: Moves directly toward (x,y) if possible. +- `ableToShoot()` -> `Boolean`: Whether your tank is able to fire at the moment. +- `find(x1,y1,x2,y2)` -> `Agent[]`: Returns a list of all agents within the map bounds specified. +- `findNearLike(ticks, filter)` -> `Agent[]`: Returns a list of agents within `ticks` movement distance away that match the filter. +- `findClosest(agents)` -> `Agent`: Returns the closest agent to this tank in the supplied list, or null if none are supplied. +- `willCollide(agents, wiggle)` -> `Agent[]`: Returns the list of agents which will collide with this agent (within `wiggle` width/height pixels). +- `calculatePath(point)` +- `calculatePath(x,y)`: Calculates a path from your current location to (x,y), taking into account walls, and then queues it for future moves. + diff --git a/doc/gameplay.md b/doc/gameplay.md new file mode 100644 index 0000000..02a1ac4 --- /dev/null +++ b/doc/gameplay.md @@ -0,0 +1,63 @@ +# The Littlest Battletank + +Inspired by Tanks minigame off Wii Play. + +## The Basics +- Your tank has 1hp. +- Your basic cannon shoots bullets. A bullet lives for one bounce or until it kills something. You can have up to 5 bullets at a time in the air. +- When you die, you respawn after a few seconds. (In single player, it restarts the level.) + +## Controls +- wasd, arrows: move your tank. +- mouse: aim your reticule. +- click, space, enter: fire a shot. +- 0-9: use items. +- All controls can be configured. + +## Ideas +- Simplicity is king. +- Only bosses have more than 1hp +- Always on one screen +- No stats: all items are qualitative +- AI makes commentary on situations. "That was close. Sucker." "loool, you always die here." +- Use TruRank-style player rating system, but the point of multiplayer will not be the ladder +- Optional registration (Flash cookie every user) +- Badges, awards, stats +- Virtual currency from various in-game activities + +## Power-Ups +- Missiles (fast, no bounce) +- Refractor Rounds (slow, infi bounces) +- Flamethrower (Cone AOE) +- Shrapnel Rounds (splits once on impact) +- Mortar Rounds (Projectile AOE) +- Mines (Stationary Prox AOE) +- Heatseekers (Projectile Prox) +- Nukes (Absurd AOE which often kills you) +- Portal Cannon (Exchanges your position with your cursor) +- K-Boss Shield (Absorbs 1 damage) +- Gin & Tonic / iPhone 3G / Hannah Montana Lamp (Extra Life) +- Deuschund Trebuchet (Parabolic Arc lulz) +- Light Cannon (Faster Move, -1 Shots in Air) +- EMP Device (aka, the "Stunna") (Freezes everyone in place. Including you.) + +## Mechanics +- AOE +- Shot Travel Speed +- Shot Bounces +- Shot Cooldown +- Shots in Air +- Move Speed +- HP (Bosses only) +- Allies -- companion AI tanks which play for your side, but they can still damage you +- Can use Items +- AI type, quality +- Mutable Environment? + + + + + + + + diff --git a/doc/notes.md b/doc/notes.md new file mode 100644 index 0000000..3285ae5 --- /dev/null +++ b/doc/notes.md @@ -0,0 +1,25 @@ +# Bugs +- Tanks seem to get stuck on some corners + +# TODOs +- How-to overlay +- Restart level button +- AI: Line-of-sight for dodging, firing +- AI: Don't shoot if it'll kill you or your friends +- AI: Lead shots on moving targets +- Config-driven unit-types (name, stats, properties; pointers to behavior scripts, assets) +- DSL for AI scripts +- Countdown to start +- User system (so I know whose scripts are whose) +- Game scoring +- Move game objects into namespace `tanks` +- Move portal into namespace (ideas: `portal`, canvas tools... `easel`, or `ezl`) +- Support touch events (for iPad?) +- Migrate A* code into PathMap + + +# Notes +- Replace *2 and /2 with shifts at compile-time +- Clipping will suck (masking is easy -- overflow:hidden) +- Classes should have generalize()-ed version of instance methods on them. + diff --git a/index.php b/index.php index 0f8add7..7376a28 100644 --- a/index.php +++ b/index.php @@ -7,8 +7,17 @@ +
+ +

The Littlest Battletank

@@ -26,7 +35,6 @@
-