Did I find the right examples for you? yes no

All Samples(7)  |  Call(4)  |  Derive(0)  |  Import(3)
Returns the Manhattan distance between points xy1 and xy2

        def manhattanDistance(xy1, xy2):
    "Returns the Manhattan distance between points xy1 and xy2"
    return abs(xy1[0] - xy2[0]) + abs(xy1[1] - xy2[1])
        


src/r/l/rlpy-HEAD/rlpy/Domains/PacmanPackage/ghostAgents.py   rlpy(Download)
from game import Directions
import random
from util import manhattanDistance
import util
 
 
        # Select best actions given the state
        distancesToPacman = [manhattanDistance(pos, pacmanPosition)
                             for pos in newPositions]
        if isScared:

src/r/l/rlpy-HEAD/rlpy/Domains/PacmanPackage/pacman.py   rlpy(Download)
from game import Actions
from util import nearestPoint
from util import manhattanDistance
import util
import layout
        next = pacmanState.configuration.getPosition()
        nearest = nearestPoint(next)
        if manhattanDistance(nearest, next) <= 0.5:
            # Remove food
            PacmanRules.consume(nearest, state)
    def canKill(pacmanPosition, ghostPosition):
        return (
            manhattanDistance(
                ghostPosition,
                pacmanPosition) <= COLLISION_TOLERANCE

src/r/l/rlpy-HEAD/rlpy/Domains/PacmanPackage/layout.py   rlpy(Download)
# For more info, see http://inst.eecs.berkeley.edu/~cs188/pacman/pacman.html
 
from util import manhattanDistance
from game import Grid
import os
    def getFurthestCorner(self, pacPos):
        poses = [(1, 1), (1, self.height - 2), (self.width - 2, 1),
                 (self.width - 2, self.height - 2)]
        dist, pos = max([(manhattanDistance(p, pacPos), p) for p in poses])
        return pos