Ejemplo n.º 1
0
def drawRadar(meta_a, meta_b, jnt_2, lnk_1, lnk_2, pos, pencol):
    board = turtle.Turtle()

    turtle.resetscreen()

    board.color(pencol)

    board.right(90) # draw base
    board.forward(20)

    if pos:
        board.left(meta_b)
        board.forward(lnk_1 * 150)

        board.right(180 - jnt_2)
        board.forward(lnk_2 * 150)

        board.left(90 - (180 - meta_a))
        board.forward(20)

    else:
        board.left((meta_a - 90))
        board.forward(lnk_1 * 150)

        board.right(180 - jnt_2)
        board.forward(lnk_2 * 150)

        board.left(meta_b)
        board.forward(20)
Ejemplo n.º 2
0
def resetScreen():
    global turtlesHard, turtlesSoft
    turtle.resetscreen()
    turtle.hideturtle()
    for t in turtlesHard + turtlesSoft:
        t.hideturtle()
    turtlesHard, turtlesSoft = [], []
 def affichage5(mot):
     turtle.resetscreen()
     turtle.speed("fastest")
     turtle.left(90)
     turtle.penup()
     turtle.goto(0,-300)
     turtle.pendown()
     turtle.tracer(0, 0)
     pos=[]
     for k in mot:
         if k=="F" or k=="M" or k=="N" or k=="O" or k=="P" or k=="Y" or k=="Z":
             t.forward(2)
         elif k=="-":
             t.rotate_Z(22.5)
         elif k=="+":
             t.rotate_Z(-22.5)
         elif k=="&":
             t.rotate_Y(22.5)
         elif k=="^":
             t.rotate_Y(-22.5)
         elif k=="/":
             t.rotate_Y(-22.5)
         elif k=="|":
             t.rotate_Z(180)
         elif k=="[":
             pos.append( (turtle.position(),turtle.heading()))
         elif k=="]":
             turtle.penup()
             x=pos.pop()
             turtle.goto(x[0])
             turtle.setheading(x[1])
             turtle.pendown()
     turtle.update()
Ejemplo n.º 4
0
def run_trials(environment_genome, robot_genome):
    fitness = 0
    environment = Environment(environment_genome)
    robot = Robot(robot_genome)
    robot.set_environment(environment)
    for _ in range(N_TRIALS):
        if simulation_state.ENABLE_DRAWING:
            turtle.resetscreen()
        environment.reset()
        robot.reset()

        for time in range(TRIAL_LENGTH):
            if simulation_state.ENABLE_DRAWING and time % 50 == 0:
                environment.draw()
                robot.draw()
                turtle.update()
            if robot.is_alive:
                robot.calculate_change()
                robot.update()
                fitness += (robot.food_battery +
                            robot.water_battery) / 2.0 / TRIAL_LENGTH
            environment.update()
            if not robot.is_alive:
                break
        if simulation_state.ENABLE_DRAWING:
            robot.clear()
            environment.clear()

    if simulation_state.ENABLE_DRAWING:
        turtle.resetscreen()
        robot.destroy()
        environment.destroy()

    return fitness / N_TRIALS
def newgame():

    #Clears the screen with everything on it.
    turtle.resetscreen()

    #Starts the game from the beginning.
    main()
Ejemplo n.º 6
0
    def games(hdgfxgh, jytcffcgfctg):
        turtle.resetscreen()
        turtle.clearscreen()
        wn.setup(width=600, height=600)
        wn.bgpic("chess1.gif")
        turtle.listen()
        turtle.onkey(clearhome, "e")
        wn.bgcolor("blue")
        home = turtle.Turtle()
        home.color("white")
        home.penup()
        home.left(90)
        home.forward(280)
        home.left(90)
        home.forward(137.5)
        home.write("Click me to go back", font=style1, align="center")
        turtle.listen()
        home.onclick(clearhome)

        sudoku_ = turtle.Turtle()
        sudoku_.color("white")
        sudoku_.penup()
        sudoku_.forward(150)
        sudoku_.left(90)
        sudoku_.forward(200)
        sudoku_.write("Click me to play Sudoku", font=style1, align="center")
        sudoku_.onclick(sudoku)

        tic = turtle.Turtle()
        tic.color("white")
        tic.penup()
        tic.left(180)
        tic.forward(150)
        tic.right(90)
        tic.forward(200)
        tic.write("Click me to play TTC", font=style1, align="center")
        tic.onclick(tictactoe)

        chess = turtle.Turtle()
        chess.color("white")
        chess.penup()
        chess.left(180)
        chess.forward(150)
        chess.left(90)
        chess.forward(200)
        chess.write("Click me to play Chess", font=style1, align="center")
        chess.forward(5)
        chess.left(180)
        chess.onclick(chess_)

        sl = turtle.Turtle()
        sl.color("white")
        sl.penup()
        sl.forward(150)
        sl.right(90)
        sl.forward(200)
        sl.left(180)
        sl.write("Click me to play SNL", font=style1, align="center")
        sl.onclick(sl_)
Ejemplo n.º 7
0
def square_spiral(first_side):
    """draw square spiral
    first_side = size of the first edge"""
    for i in range(20):
        for j in range(2):
            turtle.left(90)
            turtle.forward(first_side * i)
    turtle.resetscreen()
Ejemplo n.º 8
0
 def limpar(self):
     turtle.resetscreen()
     self.pen.color("Red")
     self.pen.pensize(1)
     self.pen.speed("fasted")
     turtle.bgcolor(self.colorbg)
     self.posx = 0
     self.posy = 0
Ejemplo n.º 9
0
 def clearhome(screen, you):
     #Telling turtle to clear the screen and reset the turtles back to their orginal postiton
     turtle.resetscreen()
     turtle.clearscreen()
     #Saying to turtle to make the background color to blue
     wn.bgcolor("blue")
     # calling the Funtction "main" to run again
     main()
Ejemplo n.º 10
0
def spiral_():
    """draw spiral
    side = first size of the edge"""
    a = 0
    while a < 2:
        a += 0.001
        turtle.forward(a)
        turtle.left(1)
    turtle.resetscreen()
Ejemplo n.º 11
0
    def drawSquare(self):
        print("I will draw a square.") 
        square = turtle.Turtle()
        
        for i in range(4):
            square.forward(self.side)
            square.right(90)

        turtle.resetscreen()
Ejemplo n.º 12
0
def rePlay(t):
    board = ["freespace", " ", " ", " ", " ", " ", " ", " ", " ", " "]
    for i in range(1, len(board)):
        if board[i] != " ":
            board[i] = " "

    turtle.resetscreen()
    draw_board(t)
    startGame(board, t)
Ejemplo n.º 13
0
def spiro(n, size):
    turtle.resetscreen()
    angle = 360 / n
    for i in range(n):
        for j in range(36):
            turtle.forward(size)
            turtle.right(10)

        turtle.right(angle)
Ejemplo n.º 14
0
def spider(length, number_of_legs):
    """draw spider
    side = first size of the edge"""
    for a in range(1, number_of_legs + 1):
        angle_ = 360 // number_of_legs
        turtle.forward(length)
        turtle.left(180)
        turtle.forward(length)
        turtle.left(180 + angle_)
    turtle.resetscreen()
Ejemplo n.º 15
0
def sixcolorspiral():
    turtle.resetscreen()
    turtle.bgcolor("black")
    sides = 6
    colors = ["red", "yellow", "blue", "orange", "green", "purple"]
    for x in range(360):
        t.pencolor(colors[x % sides])
        t.forward(x * 3 / sides + x)
        t.left(360 / sides + 1)
        t.width(x * sides / 200)
Ejemplo n.º 16
0
    def drawhexagon(self):
        print("I will draw a heaxagon.")

        hex = turtle.Turtle()

        for i in range(6):
            hex.forward(self.hside) 
            hex.left(60) 

        turtle.resetscreen()
Ejemplo n.º 17
0
def replay():  #Used for after the endgame
    con = turtle.textinput("Want to play more!",
                           "Would you like to continue? Y or N: ")
    if con == 'y' or con == 'Y' or len(
            con
    ) > 1:  #If you choose yes after game is over, it clears the screen, resets turtle object and reactivates hangman
        turtle.clearscreen()
        turtle.resetscreen()
        hangman()
    elif con == 'n' or con == '' or con == 'N':
        turtle.bye()  #Kills turtle window
Ejemplo n.º 18
0
    def draw(self):
        print("I will draw a rectangle.")
        rect = turtle.Turtle()

        for i in range(2):
            rect.forward(self.lengthh)
            rect.right(90)  # Rotate clockwise by 90 degrees
            rect.forward(self.breadth)
            rect.right(90)

        turtle.resetscreen()
Ejemplo n.º 19
0
def draw_scene(shape_list, t):
    insertion_sort(shape_list)
    if enable_turtle:
        turtle.resetscreen()
        turtle.hideturtle()
        t.speed(0)
        s = turtle.getscreen()
        s.tracer(1, draw_delay)
        for shape in shape_list:
            shape.draw(t)
        t.hideturtle()
Ejemplo n.º 20
0
 def uusmäng():
     print("Sinu vigade arv on", x)
     vastus=input("Kas te soovite uuesti mängida? (vasta jah või ei) "  )
     if vastus == "jah":
         turtle.resetscreen()
         poomismäng()
     if vastus == "ei":
         print("Väga kahju on näha teid minemas. Aitäh meiega mängimast. ")
         exit()
     else:
         print("Kahjuks ei mõista me teie vastust. Olge kindel, et kirjutate väikeste tähtedega ja tühikuteta. Vastake kas jah või ei")
         uusmäng()
Ejemplo n.º 21
0
def draw(pallet, pixels):
    turtle.resetscreen()
    global boxSize
    turtle.tracer(30)
    for row in range(len(pixels)):
        myPen.goto(0, boxSize * (-1) * row)
        for column in pixels[row]:
            column = int(column)
            use_color = pallet[column]
            myPen.color(use_color, use_color)
            box(boxSize)
            myPen.forward(boxSize)
Ejemplo n.º 22
0
        def h(sghius, fvh):
            def bmi_(dfjhbs, hiy):
                h = float(input('Enter your height (in m): '))
                w = float(input('Enter your weight (in kg): '))

                BMI = round(w / (h**2))
                print('You have a BMI of: {0} and you are '.format(BMI),
                      end='')

                if BMI < 18.5:
                    print('underweighted')
                elif BMI >= 18.5 and BMI < 25:
                    print('ideal')
                elif BMI >= 25 and BMI < 30:
                    print('overweighted')
                elif BMI >= 30:
                    print('obese')

            def heart_(check, heartrate):
                webbrowser.open('https://onlineheartrate.com/')

            turtle.resetscreen()
            turtle.clearscreen()
            wn.setup(width=600, height=600)
            wn.bgpic("_health_.gif")
            home = turtle.Turtle()
            home.color("black")
            home.penup()
            home.left(90)
            home.forward(280)
            home.left(90)
            home.forward(137.5)
            home.write("Click me to go back", font=style1, align="center")
            turtle.listen()
            home.onclick(clearhome)
            bmi = turtle.Turtle()
            bmi.penup()
            bmi.color("black")
            bmi.left(90)
            bmi.forward(250)
            bmi.write("BMI Calculator", font=style1, align="center")
            turtle.listen()
            bmi.onclick(bmi_)
            heart = turtle.Turtle()
            heart.penup()
            heart.right(90)
            heart.forward(275)
            heart.left(180)
            heart.write("Click to view heart rate",
                        font=style1,
                        align="center")
            turtle.listen()
            heart.onclick(heart_)
Ejemplo n.º 23
0
def ClearScreen():
    turtle.resetscreen()
    # Deletes all drawings and backgrounds, resets turtles to initial state.
    tank.hideturtle()
    for invader in invaders:
        invader.hideturtle()
    window.bgpic("")
    menu_pen.hideturtle()
    game_pen.hideturtle()
    norm_btn.hideturtle()
    hard_btn.hideturtle()
    score_pen.hideturtle()
Ejemplo n.º 24
0
    def draw(self):
        print("I will draw an ellipse.")
        for i in range(361):
            t = i * (self.pi / 180)
            x = (self.a) * math.sin(t)
            y = (self.b) * math.cos(t) - self.b
            #turtle.goto(x,y)
            tilt = 25 * (math.pi / 180)
            x1 = x * math.cos(tilt) + y * math.sin(tilt)
            y1 = x * math.sin(tilt) - y * math.cos(tilt)
            turtle.goto(x1, y1)

        turtle.resetscreen()
Ejemplo n.º 25
0
    def drawtriangle(self):
        print("I will draw an equilateral triangle.")
        board = turtle.Turtle()
 
        board.forward(self.sidee) # draw base
         
        board.left(120)
        board.forward(self.sidee)
         
        board.left(120)
        board.forward(self.sidee)

        turtle.resetscreen()
Ejemplo n.º 26
0
 def again():
     again = input(
         "Would you like to draw something else?\nYes) - 1\nNo) - 2\n")
     try:
         again == int(again)
     except ValueError:
         exit(1)
     if int(again) == 1:
         turtle.resetscreen()
         do_it()
     elif int(again) == 2:
         exit(1)
         turtle.done()
Ejemplo n.º 27
0
def pixelart():
    boxsize = 10
    choice = input(
        "Which pixel art would you like to see? To quit enter :q.\n{1} Bannana\n{2} Mario\n{3} Pacman Ghost\n{4} Space Invader\n{5} Smiley Face\n{6} Mushroom\n{7} Panda\n{8} Aladdin Genie\nChoice: "
    )
    if (choice == ':q'):
        exit(1)
    else:
        while (choice != ':q'):
            try:
                goto_origin(myPen)
                choice = int(choice)
                if (choice == 1):
                    file = 'art/banana.txt'
                elif (choice == 2):
                    file = 'art/mario.txt'
                elif (choice == 3):
                    file = 'art/pacman.txt'
                elif (choice == 4):
                    file = 'art/alien.txt'
                    print(file)
                elif (choice == 5):
                    file = 'art/smileyface.txt'
                elif (choice == 6):
                    file = 'art/mushroom.txt'
                elif (choice == 7):
                    file = 'art/panda.txt'
                elif (choice == 8):
                    file = 'art/genie.txt'
                    boxsize = 5
                else:
                    print(
                        "Please make sure you are entering a number amongst the choices and just a number."
                    )
                    pixelart()
                pallet_1, pixels_1 = load_art(file)
                turtle.resetscreen()  #clears previous picture off the window
                turtle.tracer(300, 0)
                draw(pallet_1, pixels_1, boxsize)
                turtle.update()
                boxsize = 10
                choice = input(
                    "Which pixel art would you like to see next? To quit enter :q.\n{1} Bannana\n{2} Mario\n{3} Pacman Ghost\n{4} Space Invader\n{5} Smiley Face\n{6} Mushroom\n{7} Panda\n{8} Aladdin Genie\nChoice: "
                )
            except ValueError:
                print(
                    "Please make sure you are entering a number amongst the choices and just a number."
                )
                pixelart()
        if (choice == ':q'):
            exit(1)
Ejemplo n.º 28
0
def runString(instring, actions):
    turtle.resetscreen()
    turtle.clearscreen()
    turtle.color(rand_color())
    turtle.speed(100)
    turtle.left(90)
    turtle.penup()
    turtle.back(400)
    turtle.pendown()
    states = []
    for l in instring:
        if l in actions:
            a = actions[l]
            states = a(states)
Ejemplo n.º 29
0
def loop():
    try:
        c = int(input('Would you like to continue?\n1. yes\n2. no'))
        if c == 1:
            turtle.resetscreen()
            main()
        elif c == 2:
            exit
        else:
            print('enter a valid input please')
            loop()
    except ValueError:
        print('Please enter number only')
        loop()
Ejemplo n.º 30
0
def square_in_square(side, number_of_squares):
    """draw square
    side = first size of the edge"""
    for a in range(1, number_of_squares + 1):
        for i in range(4):
            turtle.left(90)
            turtle.forward(side * a)
        turtle.penup()
        turtle.forward(side * 0.5)
        turtle.right(90)
        turtle.forward(side * 0.5)
        turtle.left(90)
        turtle.pendown()
    turtle.resetscreen()