This Week Cover as much Robocode strategy as we can Monday: Robocode

Slides:



Advertisements
Similar presentations
Robocode Some Methods and Ideas. Robot anatomy 101 Just like the real thing … it has a gun that rotates a radar on top that also rotates tank, gun and.
Advertisements

Robocode. What is Robocode? Robocode is an easy-to-use robotics battle simulator. You create a robot, put it onto a battlefield, and let it battle to.
Cutnell/Johnson Physics 7th edition
The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Lab 1.
Autonomy using Encoders Intro to Robotics. Goal Our new task is to navigate a labyrinth. But this time we will NOT use motor commands in conjunction with.
Artificial Intelligence in Game Design Introduction to Learning.
Graduate Capstone Project Breaking Walls: Developing a Successful Robot in Robocode Chris Velez Summer 2011 Advisor :Dr. Xiang.
EVENT DRIVEN SCRIPTING Andrew Williams. Robot Scripting Language  In the lab we looked at some very simple examples of Robot Scripting Language (RSL)
1 By: Christopher Burgess (CS) and Nathan Roy (IMGD) Advisor: Mark Claypool.
Design, Implementation, & Impact Jeffrey Santos Hofstra University May, 2010.
CSC Intro. to Computing Lecture 17: Even More Robotran!
Lecture 20 Simple linear regression (18.6, 18.9)
Astronomy 100 Tuesday, Thursday 2:30 - 3:45 pm Tom Burbine
Phys. 121: Tuesday, 21 Oct. Written HW 8: due by 2:00 pm.
Great teaching/ learning aid … OO Threading Packaging Inheritance Polymorphism Calling API code Event handling Inner classes Java docs How to duck… Consume.
Please open your laptops, log in to the MyMathLab course web site, and open Daily Quiz 18. You will have 10 minutes for today’s quiz. The second problem.
Programming – Touch Sensors Intro to Robotics. The Limit Switch When designing robotic arms there is always the chance the arm will move too far up or.
Algebra Problems… Solutions
CS Reinforcement Learning1 Reinforcement Learning Variation on Supervised Learning Exact target outputs are not given Some variation of reward is.
Next class session: Test 1 on all sections covered from Chapters 1 and 2 Remember: If you haven’t yet passed the Gateway Quiz, you need to review your.
SuperCorners. Problem The Corners sample robot has a simple strategy: first, move into a corner of the arena, and second sweep the gun back and forth.
Copyright © 2010 Pearson Education, Inc. Unit 3: Gathering Data Chapter 11 Understanding Randomness.
How does Robocode work? In short it is a framework
CPSC 171 Introduction to Computer Science 3 Levels of Understanding Algorithms More Algorithm Discovery and Design.
Raven Robin Burke GAM 376. Soccer standings Burke, 7 Ingebristen, 6 Buer, 6 Bukk, 6 Krishnaswamy, 4 Lobes, 3 Borys, 2 Rojas, 2 Bieneman, 2.
The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class 1.
Halliday/Resnick/Walker Fundamentals of Physics
CSE AI Game Programming. Installation 
Simple Soccer GAM 376 Robin Burke Fall 2006.
CSE AI Game Programming. Installation 
National 5 PHYSICAL EDUCATION Miss Robson
Assignments. AnatomyBot.java Create a robot that turns all of it parts independently (vehicle, gun, and radar). Turn the vehicle left 360 o Turn the gun.
Game Maker Terminology
Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.
Games Development Game Architecture: Entities CO2301 Games Development 1 Week 22.
University of Limerick1 Computer Applications CS 4815 Robocode.
Neural Network Implementation of Poker AI
Games Development 2 Entity Update & Rendering CO3301 Week 2, Part 1.
My Second Robot. Anatomy of a Robot A robot consists of 3 independently moving parts: Vehicle - determines the direction in which the robot will move.
Coaching Pack 9 – 11 Years. What Am I Coaching Today? What Might the Players Learn or Get Better at? TechnicalPsychological example PhysicalSocial example.
AP Physics Monday Standards: 2a1,2,3 add, subtract, and resolve displacement and velocity vectors Objective: SWBAT apply basic mathematical operations.
Tonight’s HW: Practice Presentations, Check website for War Game Rules and Quiz!
Game Programming Patterns Game Loop From the book by Robert Nystrom
Warlords Patrick Levoshko SE 558 – Multiplayer Game Design.
Seminar for Participants An Introduction on Robocode.
ORGANIZED BY THE CSS Virtual RoboCup A Brief Overview The Virtual RoboCup is a competition in which teams, of a maximum of 3 members, program a.
1 Printing in Python Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external files.
Finite State Machines (FSM) OR Finite State Automation (FSA) - are models of the behaviors of a system or a complex object, with a limited number of defined.
Artificial Intelligence in Game Design Lecture 8: Complex Steering Behaviors and Combining Behaviors.
Week 12 - Monday.  What did we talk about last time?  Defining classes  Class practice  Lab 11.
For Programming Challenge N. H. N. D. de Silva. Introduction General Game Architecture Server Architecture Joining the game Game initiation Moving and.
Searching CSE 103 Lecture 20 Wednesday, October 16, 2002 prepared by Doug Hogan.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
Robocode. Robocode: basics Coords. are (x,y), with bottom left as (0,0) Heading: degrees, straight up = 0, pos. clockwise (0
1 Chapter 4 Unordered List. 2 Learning Objectives ● Describe the properties of an unordered list. ● Study sequential search and analyze its worst- case.
Lecture 6: Basic Entities TEALS MINECRAFT PROJECT.
The Stingray Example Program CMT3311. Stingray - an example 2D game May be useful as a simple case study Most 2D games need to solve generic problems.
Biomechanics Linear motion This is motion in a straight line Definitions: Speed: distance moved in a given time Velocity: displacement in a given time.
Georgia Institute of Technology More on Creating Classes Barb Ericson Georgia Institute of Technology June 2006.
Winning Strategy in the Programming Game Robocode
Background Shapes & Collision Resolution (Top-down and Side-scrolling)
Winning Strategy in Programming Game Robocode
Introduction to Events
Autonomy using Encoders
CIS 488/588 Bruce R. Maxim UM-Dearborn
MTAT , 2CP Seminar Ilja Livenson
CIS 488/588 Bruce R. Maxim UM-Dearborn
Memory Hierarchy Memory: hierarchy of components of various speeds and capacities Hierarchy driven by cost and performance In early days Primary memory.
Robocode A robot is made up of 3 things:
Presentation transcript:

This Week Cover as much Robocode strategy as we can Monday: Robocode NN Homework Review Hand in Picbreeder hw if you haven’t Grades: Can’t give you an A if you haven’t at least turned in the assignments Email me if you’d like to double check my records against yours (which assignments you turned in and how many points you received for each)

This Week Continued Tuesday: Quiz Wednesday: Robocode Explain how a neural network can represent a solution to a particular problem. Explain how you would input data and interpret the output. Wednesday: Robocode Thursday: Competition and prizes – My last day (no late robots) Friday: AI Jeopardy with Dan DeBlasio

Robocode Homework http://www.cs.ucf.edu/~ahoover/bhcsi2010/

Robocode and Robocode Strategies (taken from citations at the end)

Excellent Sources of Information My First Robot http://testwiki.roborumble.org/w/index.php?title=Robocode/My_First_Robot FAQs http://testwiki.roborumble.org/w/index.php?title=Robocode/FAQ

From Last Time Robocode tanks are java programs We saw this when we added a line of code, compiled, and ran the code Robocode tanks are event driven There is a main loop The main loop can be interrupted by handling different events

From Last Time The tank default behavior is in a loop defined in run() Different events interrupt this loop execution

Example public class MyRobot extends Robot { public void run() { while(true) { ahead(100); turnGunRight(360); back(100); } This is an example main loop. This robot doesn’t have any event handlers so it executes these exact actions until it either wins (very unlikely) or dies (very likely).

Example public class MyRobot extends Robot { public void run() { while(true) { ahead(100); turnGunRight(360); back(100); } public void onHitByBullet(HitByBulletEvent e) { turnLeft(90 - e.getBearing()); This example has an event handler. It will continue executing this loop until we get hit by a bullet. When we get hit, we turn toward the enemy.

Inheritance in Java Ideas: Inhertiance common components are inherited, rather than duplicated allows similar though distinct objects to exhibit their common capabilities without requiring the code to be in two places

Inheritance in Java Class GoldenRetriever extends Dog GoldenRetriever has any properties that Dog has: Canis lupus familiaris Four legs GoldenRetriever has extra properties not common to all dogs Gold hair Playful demeanor Tall

Inheritance in Java Class Dog extends Mammal Mammals have: Dogs have: Hair Legs Lungs Dogs have: Canis lupus familiaris Four legs

Inheritance in Java To give our robots all of the methods defined in the robot API, we have been extending the Robot class. This is so we don’t have to define all the methods that are already defined for us. We could also extend the AdvancedRobot class Note: Beginners I don’t expect you to fully implement this concept I do expect you to understand what happens when we extend a class (inherit from a class)

Robocode Basics Tank properties Game play Energy Time Fire Radar How to determine a winner (not necessarily last tank standing) How the Robocode engine updates

Tank Basics: Energy Tanks start with a certain amount of health (energy) 100 Tanks lose health by: getting shot bumping into things (the walls, other robots) shooting bullets fighting for too long (Note: tanks that hit each other lose equal amounts of health) Tanks gain health by shooting other tanks Tanks that run out of health by shooting too much are disabled (If the tanks bullet hits a target it can gain energy back)

Game Play (point distribution) Robots on the field when another robot dies – 50 points Last robot alive given extra points – 10 points per dead robot Every point of fire damage inflicted on target robot – 1 point Every opponent ram – 2 points per damage inflicted by ramming Killing a target robot by firing at it– 20% of total damage inflicted Death by ramming – 30% of total damage inflicted

Tank Basics: Time Rotating the gun, radar, and vehicle takes time Vehicle takes the longest amount of time Radar takes the least amount of time Bullets take time to hit things (need to shoot where you expect the target to be when the bullet should arrive) Gun has a short cooldown period in between shots Radar must be pointed at a target to see it Detects velocity, bearing, heading, and energy remaining.

Tank Basics: Fire 3 levels of firing fire(1) – costs the least health, does the least damage fire(2) -costs intermediate health, does intermediate damage fire(3) – costs the most health, does the most damage

Tank Basics: Radar Infinite range One degree scan width Returns enemy position, orientation, bearing, gun angle, and energy. Tank knows its own position, oreintation, bearing, gun angle, and energy

Game Play (how Robocode updates) All robots execute their code until taking action Time is updated All bullets move and check for collisions All robots move (heading, acceleration, velocity, distance, in that order) All robots perform scans (and collect team messages) The battlefield draws http://www.dinbedstemedarbejder.dk/Dat3.pdf

Robocode Strategies Seeing other robots – how the robot controls its radar Choosing an enemy Moving – where the robot should go Targeting and Shooting - when, how powerful and in which direction to shoot. http://www.dinbedstemedarbejder.dk/Dat3.pdf

Radar Strategies – Seeing other robots Remember that scanning takes time Simple – scan 360 degrees (while alive), looking for target robots, remember where these robots are Problem: Robots aren’t typically evenly distributed

Example: Scan 360 public class MyFirstRobot extends Robot { public void run() { while (true) { ahead(100); turnGunRight(360); } }   public void onScannedRobot(ScannedRobotEvent e) { fire(1); } }

Radar Strategies – Seeing other robots Locked scanning strategy – radar finds a target and sticks with it Implemented by moving the radar back and forth a little to keep track of the robot, it could scan the direction based on the target robot’s heading Problem: Not good for bigger battles since you could pass by easier to kill robots Radar can be used to guess when an opponent’s bullet has fired Any ideas on how we could do this? Look at what we can gather from the radar API

Example: Target Lock //Follows the robot around the battlefield. public void run() { // ... turnRadarRightRadians(Double.POSITIVE_INFINITY); do { scan(); } while (true); } public void onScannedRobot(ScannedRobotEvent e) { double absoluteBearing = getHeadingRadians() + e.getBearingRadians(); double radarTurn = absoluteBearing - getRadarHeadingRadians(); setTurnRadarRightRadians(Utils.normalRelativeAngle(radarTurn)); // ... }

Radar Strategy – Methods (AdvancedRobots) scan() - Scans the arena using the radar at its current setting. Robocode calls this for each robot at each turn. setTurnRadarLeft and turnRadarLeft. setTurnRadarRight and turnRadarRight setAdjustRadarForRobotTurn - Enables or disables the radar locking to the vehicle setAdjustRadarForGunTurn - Enables or disables the radar locking to the gun

Choosing an Enemy Weakest Enemy – Pick the guy with the lowest health Problem: This target could be far away. Another robot could dip below target robot’s health in the mean time! Closest Enemy – Pick the guy closest to you Problem: He could be the winner. Dying earlier means you receive less points overall

Choosing an Enemy No explicit methods provided by Robocode Neural Network Targeting Today if we have time

Movement Strategies (MS) None – easy to hit Straight line Problem: Easy for enemies to predict Curve Problem: Also easy for enemies to predict Oscillating Random Problem: Run a larger chance of hitting walls

Movement Strategies (MS) Anti-gravity – keeps the robot from dangerous areas and attracts it toward advantageous areas Many different implementations These and more discussed here – http://www.dinbedstemedarbejder.dk/Dat3.pdf

Shooting Strategies Stationary Linear Circular Oscillatory Movement pattern matching

Shooting Strategies Stationary – Assume the robot is not going to move and fire directly at the target robot’s current location Problem: If the target moves, we miss Target Robot Our Robot

Example: Stationary Shooting onScanRobot() { fire(1); } //This method just fires where we saw the robot without taking into account where it may be going

Shooting Strategies Linear – Assume that the robot is moving in a straight line, fire at where the robot should be in the time it takes to fire (Assumes constant velocity) All robot motion can be approximated for a short period of time this way Problem: Not effective over longer periods of time Target Robot Our Robot X

Shooting Strategies Circular- Assumes the target moves at a constant velocity and angular velocity (slightly better than linear targeting) Problem: Can be avoided by stopping/starting quickly or changing directions sporadically Target Robot Our Robot X

Shooting Strategies Circular change in x = cos(initialheading) * radius - cos(initialheading + changeinheading) * radius change in y = sin(initialheading + changeinheading) * radius - sin(initialheading) * radius

Shooting Strategies Oscillatory – Assumes that the target robot is moving back and forth (not many robots do this) Target Robot Our Robot X

Shooting Strategies Movement pattern matching – Predicts target robots position based on past moves Problems: Time expensive Target Robot Our Robot X

Recall how inheritance works common components are inherited, rather than duplicated allows similar though distinct objects to exhibit their common capabilities without requiring the code to be in two places

Creating Your Own Event Note: We’ve been extending the Robot class If we extend the AdvancedRobot class, we can create our own events

Creating Your Own Event Events happen when a certain condition is met E.g. onScanRobot() – checks to see if another robot is found, returns true if a robot is found, event fires Event needs to check for some kind of “behavior,” call this a condition Your robots onCustomEvent(CustomEvent e) method is called when the test condition is true

Creating Your Own Event addCustomEvent(Condition condition) Registers a custom event to be called when a condition is met. Condition() Creates a new, unnamed Condition with the default priority. Condition(String name) Creates a new Condition with the specified name, and default priority. Condition(String name, int priority) Creates a new Condition with the specified name and priority.

Example: Our own event public class MyEvent extends AdvancedRobot { ... public void run() { //the condition is given a name “canFire” addCustomEvent(new Condition(“canFire") public boolean test() // When the gun has cooled off, test returns true return (getGunHeat() == 0); }; } );

Example: Handling our event public void onMyEvent(CustomEvent ev) { fire(3); }

Citations… http://people.csail.mit.edu/jacobe/papers/robocode.pdf http://www.ibm.com/developerworks/java/library/j-tipstrats.html http://sclab.yonsei.ac.kr/~hjinh/PAPER/IC2004-1.pdf http://www.dinbedstemedarbejder.dk/Dat3.pdf