Tank War Game is a two-player tactical game played on a grid-based map, where each player controls a tank with the objective of depleting the opponent's life points to zero. The game incorporates movement, shooting mechanics, and a shrinking map to intensify gameplay over time.
Grid Size: The game starts on a 20x20 grid, with coordinates ranging from (1,1) to (20,20).
Tank Placement:
Each player chooses starting coordinates within the grid boundaries.
Players also select initial facing directions for their tanks:
0: Up. (x, y) <- (x-1, y)
1: Right (x, y) <- (x, y+1)
2: Down (x, y) <- (x+1, y)
3: Left (x, y) <- (x, y-1)
Life Points: Tanks start with a default of 5 life points, but this can be adjusted at the game's start.
PvP (Player vs. Player): Both players control their tanks.
PvE (Player vs. Environment): One player controls their tank against an AI-controlled tank.
Demo: Two AI-controlled tanks battle for demonstration purposes.
Tournament: Designed for automated competitions between AI tanks.
Player Input:
Players input their actions simultaneously.
Action Execution:
Tanks perform their chosen actions (turning and moving).
Tank-Tank Collision Check:
The game checks if tanks occupy the same grid space and processes collisions accordingly.
Bullet Generation:
If it's a bullet-firing turn (every third turn), bullets are spawned.
Bullet Movement and Collision:
Bullets move in two steps, with collision checks after each step.
Bullets hitting tanks deduct 2 life points from the tank.
Boundary Check:
Tanks outside the boundary lose 1 life point.
Bullets outside the boundary are removed.
Game End Check:
The game checks if any tank's life points have reached zero.
Actions per Turn: Each turn, a player selects one action for their tank:
0 - Move Straight: The tank moves forward one grid space in its current direction.
1 - Turn Left + Move: The tank rotates 90 degrees counterclockwise and moves forward one grid space.
2 - Turn Right + Move: The tank rotates 90 degrees clockwise and moves forward one grid space.
Direction Representation:
Directions are integers from 0 to 3:
0: Up
1: Right
2: Down
3: Left
If a tank is at position (5,5) facing down (2):
Action 0: Moves to (6,5).
Action 1: Turns to right (1) and moves to (5,6).
Action 2: Turns to left (3) and moves to (5,4).
Collision Condition: Tanks can collide if they occupy the same grid space after movement. We don't consider crossing each other as collision.
Collision Outcome:
The damage to both players are equal to the minimal life points of the two players.
Frequency: Bullets are automatically fired every three turns, starting from the first turn.
Initial Position: Bullets spawn one grid space ahead of the tank, based on its current direction.
For example, if a tank is at (5,5) facing down (2), the bullet spawns at (6,5).
Direction and Movement:
Bullets inherit the tank's current direction upon firing.
Speed: Bullets move two grid spaces per turn, advancing in two steps during the bullet movement phase.
If a bullet lands on a tank's position, it reduces that tank's life by 2 points and the bullet is removed.
Before the bullet movement step, the game checks for collisions with tanks.
After each bullet movement step, the game checks for collisions with tanks.
Bullets do not interact with each other; there is no bullet-bullet collision logic in the game.
A bullet (5,5) fired from a tank at (4,5) facing down (2) moves to (6,5) and then to (7,5) in the same turn.
If an opposing tank is at (5-7,5), it gets hit during the second movement step, losing 2 life points.
The playable area starts from (1,1) to (20,20).
Getting out of the area from (1,1) to (20,20) will remove all life points.
The map shrinks inward every 4 turns, reducing the playable area by one grid space on all sides.
Example:
At turn 0-3: Boundaries are (1,1) to (20,20).
At turn 4-7: Boundaries are (2,2) to (19,19).
The map continues to shrink every 4 turns.
Tanks Out of Bounds:
If a tank is outside the current boundary, it loses 1 life point this turn.
Bullets Out of Bounds:
Bullets outside the playable area are removed from play.
Victory: A player wins if at a game end check, the opponent's tank life points drop to zero while they have at least one life point remaining.
Draw: If both tanks reach zero (or below) life points at a game end check, the game is a draw.