示例#1
0
def make_decision(params):       
    x = int(params['x'][0])
    y = int(params['y'][0])
    figure_name = params['figure'][0]
    glass_str = params['glass'][0]    
    print "x:", x, " y:", y, "figure:", figure_name    

    figure = Figures[figure_name]
    glass = Glass(glass_str)

    glassWithFigure = glass.addFigure(figure, x, y)
    glassWithFigure.printGlass()    

    print "Current surface range:", glass.getSurfaceRange()   
    print "Current overal range:", glass.getGlassRange()   
    solution = glass.findSolution(figure, x, y)   
    print "Solution surface range:", solution[2].getSurfaceRange()
    print "Solution complete lines:", solution[2].getNumberOfCompleteLines()
    print "Solution number of holes:", solution[2].getNumberOfHoles()
    print "Solution max height:", solution[2].getMaxHeight()
    print "Solution overal range:", solution[2].getGlassRange()   
    
    figure.printFigure()    
    
    solutionPhrase = ("left=" + str(x - solution[0]) if (solution[0] <= x) else ("right=" + str(solution[0] - x)))
    solutionPhrase += ", rotate=" + str(solution[1])
    solutionPhrase += ", drop"    
    print "Solution phrase:", solutionPhrase     
    return solutionPhrase
示例#2
0
def make_decision(params):
    x = int(params['x'][0])
    y = int(params['y'][0])
    figure_name = params['figure'][0]
    glass_str = params['glass'][0]
    print "x:", x, " y:", y, "figure:", figure_name

    figure = Figures[figure_name]
    glass = Glass(glass_str)

    glassWithFigure = glass.addFigure(figure, x, y)
    glassWithFigure.printGlass()

    print "Current surface range:", glass.getSurfaceRange()
    print "Current overal range:", glass.getGlassRange()
    solution = glass.findSolution(figure, x, y)
    print "Solution surface range:", solution[2].getSurfaceRange()
    print "Solution complete lines:", solution[2].getNumberOfCompleteLines()
    print "Solution number of holes:", solution[2].getNumberOfHoles()
    print "Solution max height:", solution[2].getMaxHeight()
    print "Solution overal range:", solution[2].getGlassRange()

    figure.printFigure()

    solutionPhrase = ("left=" + str(x - solution[0]) if (solution[0] <= x) else
                      ("right=" + str(solution[0] - x)))
    solutionPhrase += ", rotate=" + str(solution[1])
    solutionPhrase += ", drop"
    print "Solution phrase:", solutionPhrase
    return solutionPhrase