コード例 #1
0
from binary_heap import BHeap
if __name__ == "__main__":
    a = [None] * 1
    a.append([90, 'watermelon'])
    a.append([80, 'pear'])
    a.append([70, 'melon'])
    a.append([50, 'lime'])
    a.append([60, 'mango'])
    a.append([20, 'cherry'])
    a.append([30, 'grape'])
    a.append([35, 'orange'])
    a.append([10, 'apricot'])
    a.append([15, 'banana'])
    a.append([45, 'lemon'])
    a.append([40, 'kiwi'])
    b = BHeap(a)

    print('Before heap construction :')
    b.print_heap()
    b.create_heap()

    print('Minimum Heap : ')
    b.print_heap()

    print('After deleting minimum value ')
    print(b.delete_min())
    b.print_heap()
    b.insert([5, 'apple'])
    print('Inserting 5')
    b.print_heap()
コード例 #2
0
from binary_heap import BHeap
import math
import pprint
pp = pprint.PrettyPrinter()

from agent import Agent
from cell import Cell

infinity = 1000000

fringe = BHeap()
costs = {}


def print_grid(grid, agent, goal):
    '''
	Use the function to print the world state to the terminal.
	agent is your Agent, goal is the goal Cell.
	'''
    matrix = [['x' for i in range(len(grid[0]))] for j in range(len(grid[1]))]
    for i in range(10):
        for j in range(10):
            if i == agent.x and j == agent.y:
                matrix[i][j] = 'A'
            elif i == goal.x and j == goal.y:
                matrix[i][j] = 'G'
            elif grid[i][j].status == 'u':
                matrix[i][j] = ' '
            else:
                matrix[i][j] = 'X'