Exemplo n.º 1
0
 def show_robot(self, robot):
     turtle.color("green")
     turtle.shape('turtle')
     turtle.setposition([robot.x + self.width / 2, robot.y + self.height / 2])
     turtle.setheading(robot.theta / pi * 180.0)
     turtle.stamp()
     turtle.update()
Exemplo n.º 2
0
    def show_particles(self, particles):
        self.update_cnt += 1
        if UPDATE_EVERY > 0 and self.update_cnt % UPDATE_EVERY != 1:
            return

        turtle.clearstamps()
        turtle.shape('tri')

        # Particle weights are shown using color variation
        show_color_weights = 1 #len(weights) == len(particles)
        draw_cnt = 0
        px = {}
        for i, p in enumerate(particles):
            draw_cnt += 1
            if DRAW_EVERY == 0 or draw_cnt % DRAW_EVERY == 1:
                # Keep track of which positions already have something
                # drawn to speed up display rendering
                scaled_x = int(p.x * self.one_px)
                scaled_y = int(p.y * self.one_px)
                scaled_xy = scaled_x * 10000 + scaled_y
                if not scaled_xy in px:
                    px[scaled_xy] = 1
                    turtle.setposition([p.x + self.width / 2, p.y + self.height / 2])
                    turtle.setheading(p.theta / pi * 180.0)
                    if(show_color_weights):
                        weight = p.w
                    else:
                        weight = 0.0
                    turtle.color(self.weight_to_color(weight))
                    turtle.stamp()
Exemplo n.º 3
0
 def show_robot(self, robot):
     turtle.color("green")
     turtle.shape('turtle')
     turtle.setposition(*robot.xy)
     turtle.setheading(robot.h)
     turtle.stamp()
     turtle.update()
Exemplo n.º 4
0
def printwin(turtle):
  turtle.stamp()
  turtle.hideturtle()
  turtle.penup()
  turtle.goto(0,0)
  turtle.color("green")
  turtle.write("You Win!",font=("Arial",30), align = "center")
Exemplo n.º 5
0
    def show_sharks(self, sharks):
        self.update_cnt += 1
        if UPDATE_EVERY > 0 and self.update_cnt % UPDATE_EVERY != 1:
            return

        turtle.clearstamps()
        draw_cnt = 0
        px = {}
        for shark in sharks:
            draw_cnt += 1
            shark_shape = 'classic' if shark.tracked else 'classic'
            if DRAW_EVERY == 0 or draw_cnt % DRAW_EVERY == 0:
                # Keep track of which positions already have something
                # drawn to speed up display rendering
                scaled_x = int(shark.x * self.one_px)
                scaled_y = int(shark.y * self.one_px)
                scaled_xy = scaled_x * 10000 + scaled_y
                turtle.color(shark.color)
                turtle.shape(shark_shape)
                turtle.resizemode("user")
                turtle.shapesize(1.5,1.5,1)
                if not scaled_xy in px:
                    px[scaled_xy] = 1
                    turtle.setposition(*shark.xy)
                    turtle.setheading(math.degrees(shark.h))
                    turtle.stamp()
Exemplo n.º 6
0
 def show_shark(self, shark):
     turtle.color(shark.color)
     turtle.shape('turtle')
     turtle.setposition(*shark.xy)
     turtle.setheading(math.degrees(shark.h))
     turtle.stamp()
     turtle.update()
Exemplo n.º 7
0
 def show_robot(self, robot):
     turtle.color("blue")
     turtle.shape('square')
     turtle.setposition(*robot.xy)
     turtle.setheading(math.degrees(robot.h))
     turtle.stamp()
     turtle.update()
Exemplo n.º 8
0
 def show_goal_posts(self, goal_posts):
     for p in goal_posts:
         turtle.color("#FFFF00")
         turtle.setposition(p[0], p[1])
         turtle.shape("circle")
         turtle.stamp()
         turtle.update()
Exemplo n.º 9
0
    def show_particles(self, particles):
        self.update_cnt += 1
        if UPDATE_EVERY > 0 and self.update_cnt % UPDATE_EVERY != 1:
            return

        # turtle.clearstamps()
        turtle.shape('tri')

        draw_cnt = 0
        px = {}
        for p in particles:
            draw_cnt += 1
            if DRAW_EVERY == 0 or draw_cnt % DRAW_EVERY == 1:
                # Keep track of which positions already have something
                # drawn to speed up display rendering
                scaled_x1 = int(p.x1 * self.one_px)
                scaled_y1 = int(p.y1 * self.one_px)
                scaled_xy1 = scaled_x1 * 10000 + scaled_y1
                if not scaled_xy1 in px:
                    px[scaled_xy1] = 1
                    turtle.setposition(*p.xy1)
                    turtle.setheading(math.degrees(p.h))
                    turtle.color("Red")
                    turtle.stamp()

                    turtle.setposition(*p.xy2)
                    turtle.setheading(math.degrees(p.h))
                    turtle.color("Blue")
                    turtle.stamp()
Exemplo n.º 10
0
    def show_particles(self, particles):
        turtle.shape('dot')

        for p in particles:
            turtle.setposition(*p.xy)
            turtle.setheading(p.h)
            turtle.color(self.weight_to_color(p.w))
            turtle.stamp()
Exemplo n.º 11
0
 def show_particles(self, particles):
     turtle.clearstamps()
     for p in particles:
         turtle.setposition(*p.xy)
         turtle.setheading(p.h)
         turtle.color(self.weight_to_color(p.w))
         turtle.stamp()
     turtle.update()
Exemplo n.º 12
0
 def show_mean(self, x, y, confident=False):
     if confident:
         turtle.color("#00AA00")
     else:
         turtle.color("#cccccc")
     turtle.setposition(x, y)
     turtle.shape("circle")
     turtle.stamp()
Exemplo n.º 13
0
def serpinski(length, depth):
    if depth > 1:
        t.dot()

    if depth == 0:
        t.stamp()
    else:
        serpinski_draw(length, depth)
        serpinski_draw(length, depth)
        serpinski_draw(length, depth)
Exemplo n.º 14
0
def draw_circle(x, y, r):
    turtle.penup()
    turtle.goto(x, y)
    turtle.pendown()
    turtle.stamp()
    turtle.penup()
    turtle.goto(x + r, y)
    turtle.setheading(90)
    turtle.pendown()
    turtle.circle(r)
    turtle.penup()
Exemplo n.º 15
0
def screenMC(x, y):
    global r, g, b
    turtle.penup()
    turtle.goto(x, y)
    tsize = random.randrange(1, 10)
    turtle.shapesize(tsize)
    r = random.random()
    g = random.random()
    b = random.random()
    turtle.color(r, g, b)
    turtle.stamp()
Exemplo n.º 16
0
def mlc(x, y):  ##함수 'mlc'를 정의한다.##
    global r, g, b  ##아래에서 기본r,g,b값을 지정하기위해 r,g,b를 전역변수로 선언한다.##
    size = random.randrange(1, 12)  ##거북이의 크기가 1에서 12까지 랜덤으로 변하게한다.##
    turtle.shapesize(size)  ####
    turtle.penup()  ##거북이 이동경로에 선이 생기지 않도록한다.##
    turtle.goto(x, y)  ##거북이가 마우스왼쪽클릭으로 지정한 곳으로 이동하게 한다##
    turtle.stamp()  ##그 위치에 거북이모양 도장을 찍는다##
    turtle.color((r, g, b))  ##거북이의 색을 랜덤으로 변하게 한다.##
    r = random.random()
    g = random.random()
    b = random.random()
Exemplo n.º 17
0
    def show_attraction_point(self, att):
        turtle.color('black')
        turtle.shape('circle')
        turtle.fillcolor("")
        turtle.resizemode("user")
        turtle.shapesize(1.5, 1.5, 1)

        turtle.setposition(att)
        turtle.setheading(0)
        turtle.stamp()
        turtle.update()
 def draw(self):
     turtle.setheading(90)
     if not self.burning:
         turtle.color("green")
     else:
         turtle.color("red")
     turtle.shape("circle")
     turtle.penup()
     turtle.goto(self.xpos, self.ypos)
     turtle.pendown()
     turtle.stamp()
Exemplo n.º 19
0
def turtlestamp(x, y):
    global r, g, b
    r = ra.random()  #색상 랜덤으로
    g = ra.random()
    b = ra.random()
    t.color(r, g, b)  #거북이 색상 변경
    t.shapesize(ra.randrange(1, 5))  #터틀사이즈 랜덤으로 변경
    t.penup()
    t.goto(x, y)
    t.lt(ra.randrange(360))  #거북이 각도를 왼쪽으로 얼만큼 바꿀 것인지
    t.stamp()  #거북이 좌표에 찍
Exemplo n.º 20
0
def disp_num(k):
    global old_key
    t.shape(s7seg_base)
    t.stamp()
    if k != old_key:
        if k < 10:
            for i in range(7):
                if s7seg_num[k][i] == 1:
                    t.shape(s7seg_led[i])
                    t.stamp()
    old_key = k
Exemplo n.º 21
0
 def plot_position(self, x, y, theta):
     converted_angle = 180 - theta
     turtle.fillcolor('gray')
     turtle.setpos(x, y)
     # if self.step_count == self.steps_for_stamp:
     #     turtle.stamp()
     #     self.step_count = 0
     # else:
     #     self.step_count += 1
     turtle.stamp()
     turtle.setheading(converted_angle)
def manecilla():
    for i in range(12):
        turtle.penup()
        turtle.forward(65)
        turtle.pendown()
        turtle.forward(10)
        turtle.penup()
        turtle.forward(25)
        turtle.stamp()
        turtle.backward(100)
        turtle.left(360 / 12)
Exemplo n.º 23
0
 def deadeyes():
     t.register_shape('dead', ((-5, -5), (-0.01, 0), (-5, 5), (0, 0.01),
                               (5, 5), (0.01, 0), (5, -5), (0, -0.01)))
     t.penup()
     t.setpos((165, 255))
     t.dot(15, 'white')
     t.shape('dead')
     stamp1 = t.stamp()
     t.setpos((185, 255))
     t.dot(15, 'white')
     stamp2 = t.stamp()
Exemplo n.º 24
0
def start(x, y, linhas, colunas, tamanho):
    x_start = r.randrange(x, x + tamanho * colunas, tamanho)
    y_start = r.randrange(y - tamanho * linhas, y, tamanho)
    t.pu()
    t.goto(x_start, y_start)
    t.pd()
    t.shape('circle')
    t.shapesize(0.4)
    t.stamp()
    t.shape('classic')
    t.shapesize(1)
Exemplo n.º 25
0
def spider(legs, length):
    degree_ = 360 / legs
    n = 0
    while n<legs:
        turtle.seth(degree_)
        turtle.forward(length)
        turtle.stamp()
        turtle.backward(length)
        degree_ = degree_ + 360/legs
        print(degree_)
        n += 1
Exemplo n.º 26
0
def displayBanner(banner, position):
    """
    Show banner
    :param banner: banner
    :param position: location in list
    :return: None
    """
    the_turtle = turtle.getturtle()
    turtle.setposition(position[0], position[1])
    turtle.shape(banner)
    turtle.stamp()  # Show banner
Exemplo n.º 27
0
    def drawBoard(self):
        ##############################################
        turtle.shape('square')
        turtle.shapesize(SQUARE_SIZE * 3 / CURSOR_SIZE)
        turtle.color('black')
        turtle.stamp()
        turtle.hideturtle()
        ##############################################
        for j in range(3):
            for i in range(3):
                # CREATES SHAPE AND STORES IN PLACEHOLDER
                turtle.shape('square')
                box = turtle.shape('square')
                # CREATES SHAPE SIZE AND STORES IN PLACEHOLDER
                turtle.shapesize(SQUARE_SIZE / CURSOR_SIZE)
                boxsize = turtle.shapesize()
                # CREATES SHAPE COLOR
                turtle.color('white')
                turtle.penup()
                # CREATES SHAPE POS AND STORES IN PLACEHOLDER
                turtle.goto(i * (SQUARE_SIZE + 2) - (SQUARE_SIZE + 2),
                            j * (SQUARE_SIZE + 2) - (SQUARE_SIZE + 2))
                boxpos = turtle.pos()

                mypos = []

                pen.goto(boxpos[0] - 50, boxpos[1] + 50)
                ##############################################
                for line in range(0, 4):
                    pen.forward(SQUARE_SIZE)
                    pen.right(90)
                    mypos.append(pen.pos())
                turtle.showturtle()
                turtle.stamp()
                ##############################################
                a = mypos[0]
                b = mypos[1]
                c = mypos[2]
                d = mypos[3]
                self.board[j][i] = [a, b, c, d]
        ##############################################
        BOXES['BOX01'] = self.minmax(self.board[0][0])
        BOXES['BOX02'] = self.minmax(self.board[0][1])
        BOXES['BOX03'] = self.minmax(self.board[0][2])
        ##############################################
        BOXES['BOX11'] = self.minmax(self.board[1][0])
        BOXES['BOX12'] = self.minmax(self.board[1][1])
        BOXES['BOX13'] = self.minmax(self.board[1][2])
        ##############################################
        BOXES['BOX21'] = self.minmax(self.board[2][0])
        BOXES['BOX22'] = self.minmax(self.board[2][1])
        BOXES['BOX23'] = self.minmax(self.board[2][2])
        ##############################################
        turtle.onscreenclick(mouse)
Exemplo n.º 28
0
def spider(n):
    '''
        Нарисуйте паука с n лапами. Пример n = 12:
        '''
    turtle.shape('turtle')
    for i in range(n):
        turtle.forward(50)
        turtle.stamp()
        turtle.right(180)
        turtle.forward(50)
        turtle.right(180)
        turtle.right(360 / n)
Exemplo n.º 29
0
def draw_spider(n, paw_length):
    """ Данная функция рисует "паука"
        n - количество лап
        paw_length - длинна лапы        
    """
    turtle.shape('turtle')
    for i in range(n):
        turtle.forward(paw_length)
        turtle.stamp()
        turtle.right(180)
        turtle.forward(paw_length)
        turtle.right(180 - (360 /  n))
Exemplo n.º 30
0
def move():
    global x, y, Vsnake, t, cherry
    t = t + 1
    turtle.forward(Vsnake)
    turtle.stamp()

    if cherry > 0:
        cherry = cherry - 1
    else:
        turtle.clearstamps(1)

    turtle.ontimer(move, 100)
Exemplo n.º 31
0
    def show_particles(self, particles, show_frequency=10):

        turtle.shape('tri')

        for i, particle in enumerate(particles):
            if i % show_frequency == 0:
                turtle.setposition((particle.x, particle.y))
                turtle.setheading(90 - particle.heading)
                turtle.color(self.weight_to_color(particle.weight))
                turtle.stamp()

        turtle.update()
def DrawPileStorePosition(turtle, x,y,pile_color):
    coordinates = []

    for i in range(random.randrange(MIN_STONES,MAX_STONES+1)):
        turtle.color(pile_color)
        turtle.up()
        turtle.goto(x,y)
        turtle.stamp()
        coordinates = coordinates + [[x,y]]
        x = x + 100

    return coordinates
Exemplo n.º 33
0
def singlemove(col,row,color):
    '''put one move in graph'''
    turtle.hideturtle()
    turtle.penup()
    turtle.setworldcoordinates(-100,800,800,-100)
    turtle.shape("circle")
    turtle.shapesize(4)

    turtle.color(color)
    turtle.setpos(row*100,col*100)
    turtle.stamp()
    turtle.home()
Exemplo n.º 34
0
    def show_particles(self, particles, show_frequency = 10):
        turtle.shape('tri') # 前面定義過的箭頭圖形

		# show_frequency = 每10個才顯示一個(可調整)
        for i, particle in enumerate(particles):
            if i % show_frequency == 0:
                turtle.setposition((particle.x, particle.y))
                turtle.setheading(90 - particle.heading) # 將畫筆的方向設置為90 - particle.heading。
                turtle.color(self.weight_to_color(particle.weight)) # 根據particle weight來決定顏色 
                turtle.stamp() # 將烏龜形狀的副本標記在畫布上。
        
        turtle.update() # 更新畫布
Exemplo n.º 35
0
 def draw_vertex(self,  domain_name, domain ):
    if len(domain) == 1:
       shape_name = self.colors[ domain[0] ]
    else:
       shape_name = "uncolored"
    
    if shape_name != self.previous_color[domain_name]:
       self.previous_color[domain_name] = shape_name
       position = tuple(map(lambda x: x+0.4, self.positions[domain_name]))
       turtle.shape( shape_name )
       turtle.setposition( position )
       turtle.stamp()
Exemplo n.º 36
0
def screenLeftClick(x, y):

    global r, g, b
    tAngle = random.randrange(0, 360)
    turtle.left(tAngle)
    tSize = random.randrange(1, 10)
    turtle.shapesize(tSize)
    turtle.color((r, g, b))
    turtle.stamp()
    r = random.random()
    g = random.random()
    b = random.random()
Exemplo n.º 37
0
def moe_6_spaider(count=None, angel=30):
    if count:
        angel = 360 // count
    i = 0
    while i < 360:
        turtle.right(angel)
        turtle.forward(100)
        turtle.stamp()
        turtle.right(180)
        turtle.forward(100)
        turtle.left(180)
        i += angel
Exemplo n.º 38
0
def binToTurtle(binary, num):
    curX = swidth / 2  # 거북이 초기 위치를 윈도창 오른쪽 끝으로 설정
    for i in range(len(binary) - 2):  # 5를 입력시 0b101이므로 앞 0b를 제외한 101 글자 수에 해당하는 3번을 반족
        turtle.goto(curX, curY)  # 거북이랑 계산된 좌표로 이동
        if num & 1:  # 2진수로 변환했을 때 맨 하위 비트가 1인지 체크
            turtle.color('red')
            turtle.turtlesize(2)
        else:
            turtle.color('blue')
            turtle.turtlesize(1)
        turtle.stamp()  # 위에서 설정된 크기와 색상으로 거북이 도장을 현재 위치에 찍는다.
        curX -= 50  # X좌표를 왼쪽으로 50만큼 이동시킨다.
        num >>= 1  # 숫자를 오른쪽을 1 시프트시킨다. 오른쪽 비트는 이미 앞에서 표현했으므로 제거
Exemplo n.º 39
0
def star(size):
    if size <= 10:
        return
    else:

        for i in range(5):
            turtle.begin_fill()
            turtle.fd(size)
            star(size / 3)
            turtle.left(216)
            turtle.end_fill()
            turtle.stamp()
            turtle.ht()
Exemplo n.º 40
0
def turtle_spider(N, coefficient = False):
    """where N is number of spider's paws"""
    if coefficient == False:
        coefficient = 360/N
    if N == 0:
        return
    turtle_spider(N-1, coefficient)

    turtle.shape("turtle")
    turtle.right(coefficient)
    turtle.forward(90)
    turtle.stamp()
    turtle.goto(0,0)
Exemplo n.º 41
0
def circularSpiral(turtle, center, heading, color):
    #draws a circular spiral with a stamped symbol at its center
    turtle.penup()
    turtle.goto(center)
    turtle.pendown()
    turtle.setheading(heading)
    turtle.color(color)
    for k in range(8):
        #draws the stamped symbol by stamping the turtle in 8 different rotated positions
        turtle.stamp()
        turtle.right(45)
    for k in range(130):
        turtle.circle(k, 10 * 3.14)
Exemplo n.º 42
0
def orbit(turtle, x, y, z, t, d):
    if z == 0:
        turtle.stamp()
    else:
        if t == 0:
            turtle.up()
            turtle.goto(x * math.cos(math.radians(1 / z)) + d,
                        y * math.sin(math.radians(1 / z)))
            turtle.down()
            turtle.showturtle()
        else:
            turtle.goto(x * math.cos(math.radians(t / z)) + d,
                        y * math.sin(math.radians(t / z)))
Exemplo n.º 43
0
def binary_draw(num, curX, curY):
    binary = bin(num)
    for i in range(len(binary) - 2):
        turtle.goto(curX, curY)
        if num & 1:
            turtle.color('red')
            turtle.turtlesize(2)
        else:
            turtle.color('blue')
            turtle.turtlesize(1)
        curX -= 50
        num >>= 1
        turtle.stamp()
Exemplo n.º 44
0
def display_number(turtle, number):
    for digit in str(number):
        bits = DIGITS[digit]

        for bit in range(7):
            if 2**bit & bits:
                position = turtle.position()
                segments[bit](turtle)
                turtle.stamp()
                turtle.setheading(0)
                turtle.setposition(position)

        turtle.forward(SPACING)
Exemplo n.º 45
0
def oct_draw(num, curX, curY):
    '''
    8진수를 size에 따라 거북이 그리기
    '''
    octnum = oct(num)
    for j in range(len(octnum) - 1, 1, -1):
        print(j)
        turtle.goto(curX, curY)
        turtle.color('red')
        turtle.turtlesize(int(octnum[j]))
        curX -= 100
        turtle.stamp()
    turtle.done()
Exemplo n.º 46
0
def move():
    global x, y, Vsnake, t, cherry
    t = t + 1
    turtle.forward(Vsnake)
    turtle.stamp();

    if cherry > 0:
        cherry = cherry - 1
    else:
        turtle.clearstamps(1)


    turtle.ontimer(move, 100)
Exemplo n.º 47
0
def circularSpiral(turtle, center, heading, color):
    #draws a circular spiral with a stamped symbol at its center
    turtle.penup()
    turtle.goto(center)
    turtle.pendown()
    turtle.setheading(heading)
    turtle.color(color)
    for k in range(8):
        #draws the stamped symbol by stamping the turtle in 8 different rotated positions
        turtle.stamp()
        turtle.right(45)
    for k in range(130):
        turtle.circle(k, 10 * 3.14)
Exemplo n.º 48
0
def disp(A, cellsize = 1 / 10.5):
    turtle.clear()
    turtle.shape("square")
    turtle.penup()
    turtle.speed(0)
    turtle.shapesize(0.5, 0.5, 1)
    turtle.ht()
    top = len(A) / cellsize
    left = -len(A[0]) / cellsize
    for r in range(len(A)):
        for c in range(len(A[r])):
            if A[r][c]: 
                turtle.goto(c * 10.5 + left, top - r * 10.5)
                turtle.stamp()
Exemplo n.º 49
0
 def show_mean(self, mean):
     # TODO: Delete below assumption about confident
     confident = True
     m1, m2 = mean
     x = 0
     y = 0
     if confident:
         turtle.color("#00AA00")
         turtle.fillcolor("")
     else:
         turtle.color("#cccccc")
         turtle.fillcolor("")
     turtle.setposition(x, y)
     turtle.shape("circle")
     turtle.stamp()
Exemplo n.º 50
0
    def show_particles(self, particles):
        self.update_cnt += 1
        if UPDATE_EVERY > 0 and self.update_cnt % UPDATE_EVERY != 1:
            return

        turtle.clearstamps()
        turtle.shape('tri')

        draw_cnt = 0
        for p in particles:
            draw_cnt += 1
            if DRAW_EVERY == 0 or draw_cnt % DRAW_EVERY == 1:
                turtle.setposition(*p.xy)
                turtle.setheading(p.h)
                turtle.color(self.weight_to_color(p.w))
                turtle.stamp()
Exemplo n.º 51
0
def langton_move(turtle, pos, maps, step):
    if pos not in maps or maps[pos] == "white":
        turtle.fillcolor("black")
        turtle.stamp()
        update_maps(maps, turtle, "black")
        turtle.right(90)
        turtle.forward(step)
        pos = turtle_pos(turtle)
    elif maps[pos] == "black":
        turtle.fillcolor("white")
        update_maps(maps, turtle, "white")
        turtle.stamp()
        turtle.left(90)
        turtle.forward(step)
        pos = turtle_pos(turtle)
    return pos
Exemplo n.º 52
0
def stamp_block():
    """
    Places a block in the center of the canvas.
    """
    ## HINT
    global STAMP_ID
    STAMP_ID = t.stamp()
Exemplo n.º 53
0
def main():
    # turtle.forward(120)
    distance = 60
    step = 60
    amount = 4
    turtle.up()
    turtle.backward(200)
    turtle.down()
    turtle.pensize(2)
    turtle.color('blue')
    turtle.stamp()
    for j in range(amount):
        for i in range(5):
            turtle.forward(distance)
            turtle.right(144)
        distance += step
    turtle.exitonclick()
Exemplo n.º 54
0
def sierpinski(length,depth):
    if depth>1:turtle.dot()
    if depth==0:
        turtle.stamp()
    else:
        turtle.forward(length)
        sierpinski(length/2,depth-1)
        turtle.backward(length)
        turtle.left(120)
        turtle.forward(length)
        sierpinski(length/2,depth-1)
        turtle.backward(length)
        turtle.left(120)
        turtle.forward(length)
        sierpinski(length/2,depth-1)
        turtle.backward(length)
        turtle.left(120)
Exemplo n.º 55
0
	 def showParticles(self, _loc):
		 turtle.tracer(50000, delay=0)
		 turtle.register_shape("dot", ((-3, -3), (-3, 3), (3, 3), (3, -3)))
		 turtle.register_shape("tri", ((-3, -2), (0, 3), (3, -2), (0, 0)))
		 turtle.speed(0)
		 turtle.setworldcoordinates(0,(self.maze.resolution+1)*3,(self.maze.resolution+1)*3,0)
		 turtle.up()
		 turtle.clearstamps()
		 lines = turtle.Turtle()
		 lines.color("black")
		 lines.pensize(5)
		 for i in range(len(self.maze.layout)):
			 for j in range(len(self.maze.layout[0])):
				 if self.maze.layout[i][j][2]=='X':
					 lines.penup()
					 lines.goto(j*(self.maze.resolution)-1,(i+1)*self.maze.resolution-1)
					 lines.pendown()
					 lines.forward(self.maze.resolution)
					 lines.penup()
				 if self.maze.layout[i][j][1] == 'X':
					 lines.penup()
					 lines.goto(j * (self.maze.resolution) - 1, i * self.maze.resolution)
					 lines.pendown()
					 lines.forward(self.maze.resolution)
					 lines.penup()
		 turtle.shape('tri')
		 for p in self.particles:
			 #print(p.x, p.y)
			 turtle.setposition(p.x,p.y)
			 heading = ((p.orientation +math.pi/2) / (2 * math.pi)) * 360
			 turtle.setheading(heading)
			 turtle.color("red")
			 turtle.stamp()
			 #turtle.update()
		 turtle.shape('dot')
		 turtle.color("blue")
		 turtle.setposition(self.bestParticle.x, self.bestParticle.y)
		 turtle.stamp()
		 turtle.shape('turtle')
		 turtle.color("green")
		 turtle.setposition(_loc[0], _loc[1])
		 headingr = ((_loc[2] +math.pi/2) / (2 * math.pi)) * 360
		 turtle.setheading(headingr)
		 #heading = (self.particles[self.prWithHeighestW].orientation / (2 * math.pi)) * 360
		 #turtle.setheading(heading)
		 turtle.update()
Exemplo n.º 56
0
def move():
    turtle.pensize(1)
    turtle.color("black")
    turtle.pu()
    turtle.speed(3)
    turtle.setheading(h[0])
    turtle.shape("square")
    turtle.stamp()
    turtle.fd(20)
    x = turtle.xcor()
    y = turtle.ycor()
    if b[0] > a[0]:     
        turtle.clearstamps(1)
        pos.insert(0,[round(x),round(y)])
        pos.pop(-1)
    else:
        pos.insert(0,[round(x),round(y)])       
        b[0] += 1    
Exemplo n.º 57
0
	def draw(self):
		'''
		Draws the object at its current (x, y) coordinates.
		'''
		turtle.goto(self.x, self.y)
		turtle.seth(self.heading())
		turtle.shape(self.shape)
		turtle.color(self.color)
		return turtle.stamp()
Exemplo n.º 58
0
def big_rectangle(x, y):
    """
    Creates an x by y rectangle of stamps.
    """
    global STAMP_IDs
    for i in range(x):
        for j in range(y):
            t.setpos(i * 20, j * 20)
            STAMP_IDs.append(t.stamp())
Exemplo n.º 59
0
def flashing_block():
    global STAMP_ID
    global BLOCK_POS
    
    t.clearstamp(STAMP_ID)
    nx,ny = BLOCK_POS
    t.setpos(nx,ny)
    STAMP_ID = t.stamp()
    
    t.ontimer(flashing_block,100)
Exemplo n.º 60
0
def moveTurtle(turtle, direction):
        turtle.stamp()

        if turtle.heading() != direction:
                turtle.setheading(direction)


        global remainingY
        global remainingX
        global forwardX
        global backwardX
        
        if direction == NORTH:
                newY = remainingY - 1
                remainingY = newY
        elif direction == EAST:
                newX = remainingX - 1
                remainingX = newX
                newForX = forwardX + 1
                forwardX = newForX

                if backwardX > 0:
                        newBackX = backwardX - 1
                        backwardX = newBackX
                        
                
        elif direction == WEST:
                newX = remainingX + 1
                remainingX = newX
                
                newBackX = backwardX + 1
                backwardX = newBackX
                newForX = forwardX - 1
                forwardX = newForX
                
        else:
                newY = remainingY + 1
                remainingY = newY

        turtle.forward(MOVING_DISTANCE)