Posts

Showing posts from October, 2018

Guessing Game – v1.0

Image
This assignment was pretty exciting for me. We were asked to create a 20 Questions-like game, where the program could guess what object you were thinking of, using a binary tree . Binary Trees My teacher introduced me to a new concept called a binary tree. A binary tree consists of nodes, and each node contains a left and right child. For example, to the right, node A has node B as its left child and node C as its right child. This data structure is infinitely expandable and can hold a wide variety of data types. Saving & Reading Data This was definitely the toughest part of the project - saving the data in a plain text file. Using recursion, I was able to output the binary nodes relatively easily, using Preorder. This means that the nodes are printed out in this order: parent, left, right. For example, if you had "A" as the parent node, and  "B" and "C" as its left and right nodes respectively, the output would be ABC. I used this method t

VacuumWorld – v1.0

Image
VacuumWorld was a pretty simple project that combined two ideas that we have been learning about: Agents and States. Borrowing from the Braitenberg project, the Vacuum agent in this game would look for dirt ("sense"), decide to vacuum or move ("decide"), and then do so ("act"). With the dirt and vacuum, there were a total of eight possible states: During my  decide method, the Vacuum agent senses where dirt exists within the VacuumWorld (the two squares). Then, if there is dirt, it will suck it up (bonus: audio!). If not it will move to the other square and sense again. Finally, when all dirt is gone, it will end the "game".  Improvements can obviously be added to my game. One major improvement I would make is to allow the user to decide the beginning state of the world; i.e. which cells have dirt, and where the vacuum is. Moreover, I would like to expand the 'world' to allow for better algorithms in the future.