Esempio n. 1
0
def ghost_walk(angle_to_face):
    ghost_flag = False
    for i in range(0, 10):
        ghost_pt_x = random.random() * 30 * random.choice([1, -1])
        ghost_pt_y = random.random() * 30 * random.choice([1, -1])
        target = me.currentPoint.x + ghost_pt_y, me.currentPoint.y + ghost_pt_y
        if target[0] > 0 and target[0] < PITCH_LENGTH and target[
                1] > 0 and target[1] < PITCH_WIDTH and not isEnemyBox(
                    Point(target[0], target[1])) and lineOfSight(
                        me.currentPoint, Point(target[0], target[1])):
            ghost_flag = True
            break
    if ghost_flag:
        angle_to_move = me.bearing(Point(target[0], target[1]))
        print "Ghost"
        controller.move(angle_to_face, angle_to_move, 60, None, None)
    else:
        print "None"
        controller.stop_robot()
Esempio n. 2
0
def collectBall():
    """Move towards then grab the ball"""
    me.goal=Goals.collectBall
    
    # if we've caught up to the ball, stop and grab
    if nearEnough(me.bearing(ball), me.currentRotation, near_enough_angle=30) and ball.distance(me)< BALL_OWNERSHIP_DISTANCE:
        controller.stop_robot()
        controller.grab(True)
    # otherwise, go to the ball
    else:
        me.goal = Goals.collectBall
        angle_to_face = me.bearing(ball)
        angle_to_move = angle_to_face
        distance_to_move = me.distance(ball)
        if lineOfSight(me.currentPoint,ball.currentPoint):
            print "Real"
            controller.move(angle_to_face,angle_to_move,distance_to_move,True)
        else:
            ghost_walk(angle_to_face)
Esempio n. 3
0
def collectBall():
    """Move towards then grab the ball"""
    me.goal = Goals.collectBall

    # if we've caught up to the ball, stop and grab
    if nearEnough(me.bearing(ball), me.currentRotation, near_enough_angle=30
                  ) and ball.distance(me) < BALL_OWNERSHIP_DISTANCE:
        controller.stop_robot()
        controller.grab(True)
    # otherwise, go to the ball
    else:
        me.goal = Goals.collectBall
        angle_to_face = me.bearing(ball)
        angle_to_move = angle_to_face
        distance_to_move = me.distance(ball)
        if lineOfSight(me.currentPoint, ball.currentPoint):
            print "Real"
            controller.move(angle_to_face, angle_to_move, distance_to_move,
                            True)
        else:
            ghost_walk(angle_to_face)
Esempio n. 4
0
def ghost_walk(angle_to_face):
    ghost_flag = False
    for i in range(0, 10):
        ghost_pt_x = random.random() * 30 * random.choice([1, -1])
        ghost_pt_y = random.random() * 30 * random.choice([1, -1])
        target = me.currentPoint.x + ghost_pt_y, me.currentPoint.y + ghost_pt_y
        if target[0] > 0 and target[0] < PITCH_LENGTH and target[1] > 0 and target[1] < PITCH_WIDTH and not isEnemyBox(Point(target[0],target[1])) and lineOfSight(me.currentPoint, Point(target[0],target[1])):
            ghost_flag = True
            break;
    if ghost_flag:
        angle_to_move = me.bearing(Point(target[0],target[1]))
        print "Ghost"
        controller.move(angle_to_face, angle_to_move, 60, None, None)
    else:
        print "None"
        controller.stop_robot()