Sunday, September 26, 2010

Basic AI

This assignment I will present a simple A.I. Program for a game “Us vs It” - Tanks, Robot.  I will list the robots functions and then the program I created using it and the end result.

Robot functions:

  • Laser – shoots forward unless tracking a target using scan.  +1 damage to tank, -1 action point (ap).
  • Fist – Robot spins to damage all enemies within 1 square, +3 damage, -1 ap.
  • Move – move forward towards goal or towards enemy if tracked using scan. -1 ap
  • Scan – see if there are enemies within 2 squares, if so target (turn towards) the closest enemy.  If more than 1 target move towards target that gets robot closest to goal (in the event of equal distance, randomly choose 1) 0 ap used.  Once enemy is hit after scan, tracking resets.
  • Repair – +1 hp to robot, if under 8hit points (hp), -1 action point.
  • Shield – puts up barrier that blocks 1 damage during tanks round.  - 1 ap

Here is the program I put in place for the Robot.  The robot has 10 hp and 6 ap and 8 commands in the program.  The program runs until robot is out of action points, has crossed the goal line or is destroyed.

1. scan
2. move -1 ap
3. spin (possible – 1 ap)
4. scan
5. laser -1 ap
6. scan
7. move -1 ap
8. spin (possible -1 ap)
9. repair (possible -1 ap, possible +1 hp)
10. shield (possible -1 ap blocks 1 hp damage next round)

Playing using this, my robot was pretty tough.  I wanted to get it going towards the goal as fast a possible, so usually the first couple moves I went forward.

No comments:

Post a Comment