subject
Computers and Technology, 20.09.2020 14:01 bri9263

You can make improvements to your turtles_in_traffic program to make it more interesting. For example, you can vary the speed of the turtles and/or you can change what happens when they collide. You may choose to implement all of the improvements described in the next two steps or only some of them. Check with your teacher to see if any are required. Make faster and slower turtles: Make the turtles speed up as they move. If they get “too fast,” slow them down again. You can decide how quickly they speed up and when they need to slow down. If you speed up the turtles, they cover more ground faster. Change your code so they do not go off screen. Complete collision management: Change the shape and color when the turtles collide: Delete one of your shapes in your list and use it as the collision shape. Use a new color to indicate a collision. The color does not have to be from your list of colors; you can choose any color as a collision color. Try to recover from a collision. Make the turtles back up a bit and then continue on. You can still change the shape and color of collided turtles as an indicator that they crashed but also indicate they are able to recover. To recover from the collision, your code needs to remember and then restore the original shape and fill color of the turtle. When the turtles stop moving and your program ends, you should indicate that this is intentional and that something did not “break” in the program. Write another nested for loop to change all of the turtles to some color that indicates they are deactivated. # a118_turtles_in_traffic. py # Move turtles horizontally and vertically across screen. # Stopping turtles when they collide. import turtle as trtl trtl. setup(600,600) # create two empty lists of turtles, adding to them later horiz_turtles = [] vert_turtles = [] # use interesting shapes and colors turtle_shapes = ["arrow", "turtle", "circle", "square", "triangle", "classic"] horiz_colors = ["red", "blue", "green", "orange", "purple", "gold"] vert_colors = ["darkred", "darkblue", "lime", "salmon", "indigo", "brown"] tloc = -100 for s in turtle_shapes: ht = trtl. Turtle(shape=s) horiz_turtles. append(ht) ht. penup() new_color = horiz_colors. pop() ht. fillcolor(new_color) ht. goto(-200, tloc) ht. setheading(0) vt = trtl. Turtle(shape=s) vert_turtles. append(vt) vt. penup() new_color = vert_colors. pop() vt. fillcolor(new_color) vt. goto( -tloc, 200) vt. setheading(270) tloc += 50 # TODO: move turtles across and down screen, stopping for collisions """ steps = 0 while steps < 50: steps = steps + 1 """ wn = trtl. Screen() wn. mainloop() i need the code answer to this

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:30
Dave has to create animations for a game. which tool can dave use?
Answers: 3
question
Computers and Technology, 22.06.2019 16:50
Consider a slotted aloha system, where the time slot equals the fixed duration of each packet. assume that there are 4 stations a,b,c,d sharing the medium. (a) stations a,b,c,d receive one packet each from higher layers at times 1.3, 1.5, 2.6,5.7 respectively. show which transmissions take place when, according to the slottedaloha protocol; describe all transmissions until all four packets have been successful.when needed, each station has access to the following sequence of random number, provided by a random number generator and drawn uniformly between 0 and 1: (1) station a draws numbers: 0.31, 0.27, 0.78, 0.9, 0.9, 0.11, 0. (2) station b draws numbers: 0.45, 0.28, 0.11, 0.83, 0.37, 0.22, 0. (3)station c draws numbers: 0.1, 0.2, 0.3, 0.4, 0. (4) station d draws numbers: 0.36, 0.77, 0.9, 0.1, 0.1, 0.1, 0.1, 0. (b) in slotted aloha, a station transmits in each time slot with a given probability. what probabilities would you assign to each of the four stations so as to: (i) maximize the efficiency of the protocol? (ii) maximize fairness among the four stations? (c) will the efficiency increase or decrease if we modify slotted aloha as follows: (i) get rid of slots and allow stations to transmit immediately? (ii) implement carrier sensing? (iii) implement collision detection? (iv) implement collision avoidance?
Answers: 3
question
Computers and Technology, 23.06.2019 15:20
What does a bonus object do? a. subtracts lives b. keeps track of a player's health c. gives a player an advantage d. makes text appear
Answers: 1
question
Computers and Technology, 24.06.2019 07:00
Why would a business likely use a java applet - to back up their data files for the business - to create a program that a customer can launch in their web browser - to create music on a powerpoint presentation - to organize files on their company directory
Answers: 3
You know the right answer?
You can make improvements to your turtles_in_traffic program to make it more interesting. For exampl...
Questions
question
History, 23.06.2019 13:30
question
Mathematics, 23.06.2019 13:30
Questions on the website: 13722362