Skip to main content

Daniel, Week 6

Pittsburgh is a beautiful city, at least the part I'm living in. The streets of my neighborhood, lined with stores, a mix of antique restaurants and contemporary fashion salons, feel so fresh, clean, and perhaps even a little romantic at dusk.

That's what I felt about my project when I finally created a working animation of my grid, minus the romantic part. I took Mr. Corica's suggestion on repeatedly drawing the graph during the algorithm's execution to simulate live animation. New versions of the graph would draw over previous versions so quickly that to the human eye, it would seem as if every iteration of my code's draw function only adds newer elements to the graph. To make this happen would, of course, also require a wait function that runs in between iterations, as otherwise only the final state of the graph would be observable. Javascript is a single-threaded language, so it doesn't offer a built-in sleep function that pauses the code without killing the entire browser. My first solution attempt was a sort-of self-loop, a loop that calls itself with a working timer in between iterations. However, the loop had to be hardcoded and I couldn't find a way to break out of it once A*'s termination requirement was met (either having reached the end state or having filled the entire graph without finding an end state). Luckily, my second solution worked. I used an asynchronous function, denoted by the keyword "async", to run the main function of my code. This allowed for a simple custom-made sleep function to work, called upon in the async function and preceded by the keyword "await". Once the timer problem was solved, I had a graph that could display any square dimension (limited only by runtime efficiency, 100 x 100 blocks gets a little slow), have any start and end blocks, a changeable weight to scale A*'s efficiency, and animated blocks of different colors flow through the graph to visualize the algorithm's execution.

The last thing needed was to actually chart the shortest path produced by the algorithm. My version of the algorithm does not actually keep track of the shortest path during its execution. Rather, it looks for the most optimal way to reach the end block in a non-linear fashion, meaning the algorithm might explore multiple different blocks across the graph at the same time. Since I did record all the blocks that the algorithm at one point deemed the lowest minimum value (closest to the end) in a boolean array, generating the shortest path simply required backtracking from the end block to the start block by repetitively finding the next adjacent block with a true value in the boolean array that is closest, of the previous block's neighbors, to the start.

After producing what is, in my opinion, a good looking animated graph with cool colors, I met with Dr. Likhachev again. For my remaining time at the lab, I will be working on creating the same animation feature for ARA*, an improved and more efficient version that Dr. Likhachev himself wrote years back.

Comments

  1. Sounds like you are making a breakthrough with your work! Will be interesting to see your results in the fall.

    ReplyDelete

Post a Comment

Popular posts from this blog

Amy, Week 4

At the beginning of the fourth week, I started working on my third project with Charlotte, a PhD student at the Tomasello Lab. For the first part of the study, the child watched a pre-recorded Skype video in which three different adult experimenters name three toys (a dog, a book, and a dump truck) in their own ways. The first two people name them “a fish”, “a spoon”, and “a shoe” respectively, which is obviously wrong. Then when the third person came and was about to name the toys, there was a buzzing sound in the video and the experimenter would ask what the child participants expected the third person to say. After the children answered, the experimenter would take out three toys with different shapes and colors and l et the child play with them for a while. After that, the child would watch another pre-recorded Skype video in which the first person in the previous video assigned three names to the three toys respectively. As she left, a new person who did not appear in th...

Sarah Park, Week 1

I happened to start on a Tuesday, so, on Monday, I was left on my own to travel around Philadelphia.  I was incredibly lucky and thankful because I have a friend in the area who did not have school and drove me around to her favorite touristy spots in the city.  First, my friend Sofia took me to Reading Terminal in order for us to have lunch because she told me I would be missing out if I spent 8 weeks in Philadelphia without visiting Reading Terminal at least once.  After, she took me to the Magic Gardens, which originally was a vacant lot, but is now an extremely large mosaic by Isaiah Zagar who is still constantly working on the museum and gallery.  Sofia, who had been to the Magic Gardens many times before, and I were thrilled to see mosaics not only in the museum, but also in the street. Last, but not least, we drove to Harbor Park in order to enjoy ice cream and swing in a hammock before she dropped me off at my apartment. I was incredibly nervous walking...

Kyle Sikkema - Getting The Lay of The Land

**Warning - This is way too long of a blog post, but it’s good, so viewer discretion is advised?** I was never one to deal with homesickness well or cope with a sizeable distance separating me from my family. Before this week, the furthest I had been away from home was at a summer camp in Pennsylvania, a few summers ago, for two weeks. Now, I’m more than 600 miles removed from the comforts of home, for three times as long. But this time, things are different. Through the chaotic weekend of moving into my apartment and the first few days at the lab, I’ve found the town of Ann Arbor to be quite pleasant. The streets are flooded with people around the clock, and the city still feels very much alive, considering the majority of the student body has left for summer. My homesickness has subsided quicker than expected, and I have grown more familiar with the area from my numerous adventures around town. Simply put, I love it here. My first day in the lab went much better than I an...