protected void closestTargets(Game game, boolean randomTarget)
    {
        targets.clear();
        double bestDist = Double.MAX_VALUE;

        int targetSpriteId = -1;
        int numChasing = game.getNumSprites(itype1);
        int numFleeing = game.getNumSprites(itype2);

        if(numChasing > numFleeing)
        {
            targetSpriteId = itype1;
            fleeing = false;
        }else if(numFleeing > numChasing)
        {
            targetSpriteId = itype2;
            fleeing = true;
        }

        if(targetSpriteId != -1)
        {
            Iterator<VGDLSprite> spriteIt = game.getSpriteGroup(targetSpriteId);
            if(spriteIt != null) while(spriteIt.hasNext())
            {
                VGDLSprite s = spriteIt.next();

                if(randomTarget)
                {
                    targets.add(s);
                }else{
                    double distance = this.physics.distance(rect, s.rect);
                    if(distance < bestDist)
                    {
                        bestDist = distance;
                        targets.clear();
                        targets.add(s);
                    }else if(distance == bestDist){
                        targets.add(s);
                    }
                }
            }
        }

        if(randomTarget)
        {
            VGDLSprite sel = targets.get(game.getRandomGenerator().nextInt(targets.size()));
            targets.clear();
            targets.add(sel);
        }
    }