Exemplo n.º 1
0
 def colNumSub(self):
     for row in settings.points:
         del row[-1]
     for row in settings.weights:
         del row[-1]
     self.colNumLabel.setText("Col = " + str(len(settings.points[0])))
     main.draw()
Exemplo n.º 2
0
def test5(i):
    empty = mn.initializeTable(mn.atomsDisposition, mn.ourRobot,
                               mn.opponentFirstRobot, mn.opponentSecondRobot)
    mn.ourRobot.setX(0.5)
    mn.ourRobot.setY(1.75)
    mn.ourRobot.setDir(-2.357)
    mn.draw(mn.findPath(empty, mn.Atoms[i]), empty)
Exemplo n.º 3
0
def test12():
    table = mn.initializeTable(mn.atomsDisposition, mn.ourRobot,
                               mn.opponentFirstRobot, mn.opponentSecondRobot)
    response = "000000206000507005759"
    mn.updateTable(table, mn.ourRobot, mn.opponentFirstRobot,
                   mn.opponentSecondRobot, mn.atomsDisposition, response)
    mn.draw(np.array([]), table)
def amain():
    last_mod_time = main_frame_mod_time()
    args = main_frame.init()
    while True:
        args = main_frame.init()
        main.draw(*args)
        importlib.reload(main)
Exemplo n.º 5
0
def test9():
    table = mn.initializeTable(mn.atomsDisposition, mn.ourRobot,
                               mn.opponentFirstRobot, mn.opponentSecondRobot)
    element = mn.atom(1, 1.05 + mn.atomDiameter * 1.5, 1)
    for i in range(5):
        elementData = [element, i, i + 1, 0.03, 0.03]
        mn.updatePosition(elementData, mn.ourRobot, table)
        mn.draw(np.array([]), table)
Exemplo n.º 6
0
 def colNumAdd(self):
     for row in settings.points:
         point = row[-1]
         row.append([point[0], point[1] + 100, point[2]])
     for row in settings.weights:
         row.append(2)
     self.colNumLabel.setText("Col = " + str(len(settings.points[0])))
     main.draw()
Exemplo n.º 7
0
 def rowNumAdd(self):
     settings.points.append([])
     for point in settings.points[-2]:
         newPoint = [point[0] + 100, point[1], point[2]]
         settings.points[-1].append(newPoint)
     settings.weights.append([2 for i in range(len(settings.points[0]))])
     self.rowNumLabel.setText("Rows = " + str(len(settings.points)))
     main.draw()
def test_dynamic_mode():

    ob_list, path = main.init_obstacle_and_path(3)
    for ob in ob_list:
        main.draw(ob.vertices, True)
    size = Grid.size

    # grid = Grid(ob_list)
    # main.draw(list(grid.obstacle_grid),point_color='', basic_mul=size)

    robot = main.init_robot_pen(path[0], path[1])
    dynamic_windows_follow(ob_list, path, robot, draw_frequence=30)
    time.sleep(60)
Exemplo n.º 9
0
def image_outline(filename, quick="N", image_path="pictures/"):
    image = cv2.imread(image_path + filename, 0)
    edges = cv2.Canny(image, 200, 250)
    edges = cv2.bitwise_not(edges)
    cv2.imwrite(image_path + filename, edges)
    print("Image has been outlined")
    if quick != "Y":
        next_step = input("Next to drawing (Y/N): ")
        if next_step == "y":
            return main.draw(filename)
        else:
            return menu.menu()
    else:
        return main.draw(filename)
    return menu.menu()
Exemplo n.º 10
0
def dynamic_windows_follow(ob_list, path, robot, draw_frequence=1, max_pen_list=1):
    draw_time = draw_frequence
    pen_list = []
    while len(path) >= 2:
        head = robot.heading()
        index = int(((head+22.5) % 360)/45)
        direction = total_direct[index]
        path = final_main(ob_list, path, direction)
        draw_time += 1
        if draw_time >= draw_frequence:
            pen = main.draw(path, draw_circle=True, point_color='blue')
            pen_list.append(pen)
            if len(pen_list) > max_pen_list:
                first_pen = pen_list.pop(0)
                first_pen.clear()
            draw_time -= draw_frequence
        start_point = path.pop(0)
        target_point = path[0]
        rhead = robot.heading()
        phead = Point(target_point.x - start_point.x, target_point.y - start_point.y).get_angle_from_zero_zero()
        angle = main.get_turn_left_angle(phead, rhead)
        max_turn_angle = 10
        if abs(abs(angle)-360) % 360 > 3 and abs(angle) > 3:
            if abs(angle) > max_turn_angle:
                robot.left(max_turn_angle * angle / abs(angle))
            else:
                robot.left(angle)
        robot.forward(3)
        start_point = robot.pos()
        start_point = Point(start_point[0], start_point[1])
        if start_point.distance(target_point) < 10:
            path.pop(0)
        path.insert(0, Circle(start_point, 0))
    print 'end'
Exemplo n.º 11
0
 def test_missing_data(self):
     self.assertEqual(draw([1,'',2,'',4]), u'▂ ▄ █')
Exemplo n.º 12
0
 def test_some_negatives(self):
     self.assertEqual(draw([-1,2,-4,4]), u'▃▆▁█')
Exemplo n.º 13
0
 def updateV(self):
     for i in range(len(self.vKnotEditing)):
         lineEdit = self.vKnotEditing[i]
         settings.vKnots[i] = float(lineEdit.text())
     main.draw()
Exemplo n.º 14
0
 def vResValueChange(self):
     settings.vRes = self.vResSlider.value()
     self.vResLabel.setText("vRes = " + str(settings.vRes))
     main.draw()
Exemplo n.º 15
0
def HomeScreen(pygame, gameDisplay, Fonts, clock, MusicPaused):
    global AnimationStage, Count, Images
    import main
    run = True
    screen = "Main"
    height = 20
    width = 20
    Images = []
    Images = load_images("Images", 8, 8)
    MenuBoard = gen_Board([[0] * height for _ in range(width)], height, width)
    AnimationStage = {
        "Water": [1, 0.5],
        "FishingBoat": [1, 0.5],
        "Dam": [1, 0.5]
    }
    x = 0
    y = 0

    while run:
        gameDisplay.fill((0, 100, 255))

        Count = {
            "Water": 0,
            "FishingBoat": 0,
            "Dam": 0,
            "Forest Lv4": 0,
            "Quarry Lv4": 0,
            "Super Factory": 0
        }
        for j in range(height):
            for i in range(width):
                if MenuBoard[j][i] == "Water" or MenuBoard[j][
                        i] == "FishingBoat" or MenuBoard[j][i] == "Dam":
                    Count["Water"] += 1
                if MenuBoard[j][i] == "FishingBoat":
                    Count["FishingBoat"] += 1
                if MenuBoard[j][i] == "Dam":
                    Count["Dam"] += 1
                if MenuBoard[j][i] == "Forest Lv4":
                    Count["Forest Lv4"] += 1
                if MenuBoard[j][i] == "Quarry Lv4":
                    Count["Quarry Lv4"] += 1
                if MenuBoard[j][i] == "Super Factory":
                    Count["Super Factory"] += 1

        # Drawing all the tiles plus some extra to make it loop seemlessly
        for j in range(height):
            for i in range(width):
                main.draw(i * 80 + x, j * 80 + y, "Tile", MenuBoard[j][i], 8,
                          8, Images, AnimationStage, Count)
                main.draw(i * 80 + x + 1600, j * 80 + y, "Tile",
                          MenuBoard[j][i], 8, 8, Images, AnimationStage, Count)
                main.draw(i * 80 + x, j * 80 + y + 1600, "Tile",
                          MenuBoard[j][i], 8, 8, Images, AnimationStage, Count)
                main.draw(i * 80 + x + 1600, j * 80 + y + 1600, "Tile",
                          MenuBoard[j][i], 8, 8, Images, AnimationStage, Count)

        # Moving around tiles on screen by -x & -y
        x -= 2
        y -= 2

        if y < -1600:
            y = 0
            x = 0

        pos = pygame.mouse.get_pos()
        # Event checking mainly for clicking on the buttons
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
            if event.type == pygame.MOUSEBUTTONDOWN:
                if 400 <= pos[0] <= 600 and 600 <= pos[
                        1] <= 700 and screen == "Main":
                    main.game_loop(8, 8, 0, False)
                if 825 <= pos[0] <= 925 and 800 <= pos[
                        1] <= 900 and screen == "Main":
                    screen = "Options"
                if 625 <= pos[0] <= 925 and 500 <= pos[
                        1] <= 900 and screen == "Main":
                    screen = "New Game"
                if 775 <= pos[0] <= 975 and pos[1] >= 675 and pos[
                        1] <= 775 and screen == "Options":
                    screen = "Main"
                if 175 <= pos[0] <= 375 and 600 <= pos[
                        1] <= 700 and screen == "Main":
                    main.game_loop(8, 8, 0, True)
                # Give user option to mute the background music
                if pos[0] >= 200 and pos[0] <= 400 and pos[1] >= 50 and pos[
                        1] <= 150 and screen == "Options":
                    if MusicPaused == False:
                        MusicPaused = True
                        pygame.mixer.music.pause()
                    else:
                        MusicPaused = False
                        pygame.mixer.music.unpause()

        # Shows Main screen text and buttons
        if screen == "Main":
            text_surface, rect = Fonts[2].render("Grand Command",
                                                 (242, 43, 35))
            gameDisplay.blit(text_surface, (220, 50))
            # mouse hover & un-hover location
            if 600 <= pos[0] <= 830 and 620 <= pos[1] <= 840:
                # box location not-hover
                pygame.draw.rect(gameDisplay, (150, 0, 0),
                                 (580, 800, 200, 100), 0)
            else:
                # box location on-hover
                pygame.draw.rect(gameDisplay, (255, 0, 0),
                                 (580, 800, 200, 100), 0)

            text_surface, rect = Fonts[1].render("New Game", (0, 0, 0))
            gameDisplay.blit(text_surface, (600, 830))

            # mouse clickable to options -> menu for mute sound atm
            if 825 <= pos[0] <= 925 and 850 <= pos[1] <= 900:
                # box location not-hover
                pygame.draw.rect(gameDisplay, (150, 0, 0),
                                 (840, 800, 200, 100), 0)
            else:
                # box location on-hover
                pygame.draw.rect(gameDisplay, (255, 0, 0),
                                 (840, 800, 200, 100), 0)

            text_surface, rect = Fonts[1].render("Options", (0, 0, 0))
            gameDisplay.blit(text_surface, (880, 830))

            # Shows the options menu
        if screen == "Options":
            if pos[0] >= 775 and pos[0] <= 975 and pos[1] >= 675 and pos[
                    1] <= 775:
                pygame.draw.rect(gameDisplay, (150, 0, 0),
                                 (775, 675, 200, 100), 0)
            else:
                pygame.draw.rect(gameDisplay, (255, 0, 0),
                                 (775, 675, 200, 100), 0)

            text_surface, rect = Fonts[1].render("Back", (0, 0, 0))
            gameDisplay.blit(text_surface, (835, 705))

            if 200 <= pos[0] <= 400 and 50 <= pos[1] <= 150:
                pygame.draw.rect(gameDisplay, (150, 0, 0), (200, 50, 200, 100),
                                 0)
            else:
                pygame.draw.rect(gameDisplay, (255, 0, 0), (200, 50, 200, 100),
                                 0)

            if MusicPaused == False:
                text_surface, rect = Fonts[1].render("Mute Music", (0, 0, 0))
                gameDisplay.blit(text_surface, (210, 80))
            else:
                text_surface, rect = Fonts[0].render("Unmute Music", (0, 0, 0))
                gameDisplay.blit(text_surface, (210, 86))

        pygame.display.flip()
        clock.tick(120)
Exemplo n.º 16
0
 def test_all_positives(self):
     self.assertEqual(draw([1,2,3,4,5]), u'▂▄▅▇█')
Exemplo n.º 17
0
 def test_max_zero(self):
     self.assertEqual(draw([-34,-12,-3,0]), u'▁▆██')
Exemplo n.º 18
0
 def vKSub(self):
     settings.vK -= 1
     self.vKLabel.setText("vK = " + str(settings.vK))
     main.draw()
Exemplo n.º 19
0
import main
import turtle

#this tests the rewritten box function, it works
#main.box(50)

#this tests to see if the proper lists are stored in the 'load_art' function in main
listOne, listTwo = main.load_art('art/banana.txt')

print("List one is the colors: ")
colors = ""

for i in listOne:
    print(i)

print("List two is the pixel order: ")
for j in listTwo:
    print(j)
    
#this tests out the 'draw' function, works
main.draw(listOne, listTwo)

#this tests out the 'save_image' function
main.save_image()

#this tests out the 'triangle'
main.triangle(50, "#000000")

#this tests my circle function
main.circle(10, "#000000")
Exemplo n.º 20
0
 def vKAdd(self):
     settings.vK += 1
     self.vKLabel.setText("vK = " + str(settings.vK))
     main.draw()
Exemplo n.º 21
0
 def uKSub(self):
     settings.uK -= 1
     self.uKLabel.setText("uK = " + str(settings.uK))
     main.draw()
Exemplo n.º 22
0
 def uKAdd(self):
     settings.uK += 1
     self.uKLabel.setText("uK = " + str(settings.uK))
     main.draw()
Exemplo n.º 23
0
 def test_input_as_strings(self):
     self.assertEqual(draw(['1','2','3','4','5']), u'▂▄▅▇█')
Exemplo n.º 24
0
def test4():
    empty = mn.initializeTable(mn.atomsDisposition, mn.ourRobot,
                               mn.opponentFirstRobot, mn.opponentSecondRobot)
    mn.draw(np.array([]), empty)
Exemplo n.º 25
0
 def test_color_option(self):
     self.assertEqual(draw(['1','2','3','4'],color='cyan'), u'\x1b[36m▂▄▆█\x1b[0m')
Exemplo n.º 26
0
def test3(i):
    empty = np.zeros((3 * mn.ratio, 2 * mn.ratio))
    mn.addElement(mn.Atoms[i], empty)
    mn.deleteElement(mn.Atoms[i], empty)
    mn.draw(np.array([]), empty)
Exemplo n.º 27
0
 def test_no_data_supplied(self):
     self.assertEqual(draw([]),u'')
Exemplo n.º 28
0
 def cameraXValueChange(self):
     degree = 1 if self.previousX < self.cameraSliderX.value() else -1
     self.previousX = self.cameraSliderX.value()
     ASWindow.changeCameraAngle(degree, [1, 0, 0])
     main.draw()
Exemplo n.º 29
0
def menu(image_path="pictures/"):
    print("_____________________________")
    print("Please choose from below:")
    print("_____________________________")
    print("[1]: Quick Draw")
    print("[2]: New Drawing")
    print("[3]: New Search")
    print("[4]: Edit Image")
    print("[5]: Edit Image Outline")
    print("_____________________________")
    print("[6]: New Drawing Area")
    print("[7]: EXIT")
    print("_____________________________")
    chosen = input("Input: ")
    if chosen == "1":
        keywords = input("Please add keyword(s):\n")
        print("_____________________________")
        if find_file(keywords) is False:
            return main.new_search(keywords, quick="Y")
        else:
            return main.draw(find_file(keywords))
    elif chosen == "2":
        print("Please choose a file:")
        print("_____________________________")
        onlyfiles = [f for f in os.listdir(image_path) if isfile(join(image_path, f))]
        for image in onlyfiles:
            print("- " + image)
        print("_____________________________")
        filename = input("Input: ")
        if find_file(filename) is False:
            return print("The file doesn't exist")
        else:
            return main.draw(find_file(filename))
    elif chosen == "3":
        keywords = input("Please add keyword(s):")
        print("_____________________________")
        return main.new_search(keywords)
    elif chosen == "4":
        print("Please choose a file:")
        print("_____________________________")
        onlyfiles = [f for f in os.listdir(image_path + "downloaded/") if isfile(join(image_path + "downloaded/", f))]
        for image in onlyfiles:
            print("- " + image)
        print("_____________________________")
        filename = input("Input: ")
        if find_file(filename, image_path="pictures/downloaded/") is False:
            return print("The file doesn't exist")
        else:
            return file_edit.image_edit(find_file(filename, image_path="pictures/downloaded/"))
    elif chosen == "5":
        print("Please choose a file:")
        print("_____________________________")
        onlyfiles = [f for f in os.listdir(image_path) if isfile(join(image_path, f))]
        for image in onlyfiles:
            print("- " + image)
        print("_____________________________")
        onlyfiles = [f for f in os.listdir(image_path) if isfile(join(image_path, f))]
        for image in onlyfiles:
            print("- " + image)
        print("_____________________________")
        filename = input("Input: ")
        if find_file(filename) is False:
            return print("The file doesn't exist")
        else:
            return file_edit.image_outline(find_file(filename))
    elif chosen == "6":
        print("Please select a new drawing area by clicking on the")
        print("top left corner and on the right bottom corner of it")
        print("_____________________________")
        x1, y1 = on_move()
        print('X: ' + str(x1).rjust(4) + ' Y: ' + str(y1).rjust(4))
        x2, y2 = on_move()
        print('X2: ' + str(x2).rjust(4) + ' Y2: ' + str(y2).rjust(4))
        settings.base_pos1 = x1, y1
        settings.base_pos2 = x2, y2
        settings.full_size[0] = abs(settings.base_pos1[0]-settings.base_pos2[0])
        settings.full_size[1] = abs(settings.base_pos1[1]-settings.base_pos2[1])
        print("New drawing area selected")
        return menu()
    elif chosen == "7":
        sys.exit()
    else:
        return ()
Exemplo n.º 30
0
 def cameraYValueChange(self):
     degree = 1 if self.previousY < self.cameraSliderY.value() else -1
     self.previousY = self.cameraSliderY.value()
     ASWindow.changeCameraAngle(degree, [0, 1, 0])
     main.draw()
Exemplo n.º 31
0
 def rowNumSub(self):
     del settings.points[-1]
     self.rowNumLabel.setText("Rows = " + str(len(settings.points)))
     main.draw()
Exemplo n.º 32
0
 def resetView(self):
     ASWindow.refresh2d(settings.width, settings.height)
     main.draw()