[Pogamut-list] Bot Radius Detection

dirkmalta pogamut-forum at diana.ms.mff.cuni.cz
Mon Dec 6 16:17:17 CET 2010


Re: Bot Radius Detection

Author: dirkmalta

Hi all. Here is a code sample I created thanks to the assistance provided by Michal. It allows Bots to have different radius sizes which detects surroundings.

Very simple but can be efficient:

TurnTo t = new TurnTo();
        Map map = players.getPlayers();
        for (Player p : map.values())
        {
            //System.out.println(p.getName() + " - " + p.getLocation());
            if (p.getLocation() != null) {
                if ((info.getLocation() != null) && (info.getLocation().getDistance(p.getLocation()) < MAX_DISTANCE)) {
                    body.getCommunication().sendGlobalTextMessage("VERY CLOSE!!!!");
                    p.
                    getAct().act(new TurnTo().setTarget(p.getId()));
                    getAct().act(new Shoot().setTarget(p.getId()));
                } else if ( (info.getLocation() != null) &&
                            (info.getLocation().getDistance(p.getLocation()) > MAX_DISTANCE) &&
                            (info.getLocation().getDistance(p.getLocation()) < MAX_DISTANCE_OUT)) {
                    body.getCommunication().sendGlobalTextMessage("Close");
                    //pathExecutor.followPath(pathPlanner.computePath(bot, p));
                } else {
                    body.getCommunication().sendGlobalTextMessage("I sense someone....");
                }
            }else {
                body.getCommunication().sendGlobalTextMessage("peace all around");
            }
        }

-- 
Reply Link: <http://diana.ms.mff.cuni.cz/main/tiki-view_forum_thread.php?forumId=4&comments_reply_threadId=4&comments_parentId=435&post_reply=1#form>





More information about the Pogamut-list mailing list