package biter; import java.util.HashMap; import java.util.ArrayList; import java.util.Iterator; import java.awt.geom.Point2D; /** * The decision making, action performing part * of the program. While running, first it looks for the ball. * Then it moves to the ball. It then looks for the goal, and * kicks the ball towards it. * * @author Paul A. Buhler * @version $Revision: 1.9 $, $Date: 2000/08/22 17:19:51 $ * * Copyright (C) 2000 Paul Buhler * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ public class Player extends PlayerFoundation { public Player( DatagramWrapper dgWrapper, GlobalMemory memory, ConfigurationData cfgData, Point2D.Double startLocation, int playerNumber ) { super(dgWrapper, memory, cfgData, startLocation, playerNumber); } /** * Provides access to the GlobalMemory as well * as performing necessary tasks for the player. These * tasks include using its visual information to * decide on and take the appropriate actions. * @param dynamicObjects a list containing visual data of the agent * @param hearInformation a list containing information from hear messages * @param staticObjects a map containing the location of the flags * @param self contains the necessary information on the player * @param lastMessage contains the current mode of play, decided by the referee * @param myData unused in this implementation */ public void act( ArrayList dynamicObjects, ArrayList hearInformation, HashMap staticObjects, SelfInfo self, RefereeMessage lastMessage, Object myData ) { //the general // idea is that the player finds the ball, goes to the ball, // and kicks the ball into the opposing team's goal. // PAB 5/3/2000 DynamicObjectInfo object = null; // find ball //Uses a regular expression Iterator iterator = dynamicObjects.iterator(); Iterator filteredIterator = new FilteredIterator( iterator, "[bB]all"); // there should be at most one ball object... thus no while loop. // PAB 4/10/2000 object = (BallInfo)filteredIterator.next(); if( object == null ) { // can't see the ball, turn to look for it turn( 60 ); } else { dribbleToPoint((Point2D.Double) staticObjects.get((self.getSide() == 'l') ? "goal r" : "goal l"), self, (BallInfo)object); } } }