Labels

Monday, November 2, 2015

Art in New York City



Being from Seattle, I found myself delighted at the chance to poke fun at the art scene in New York.

I love Seattle, but why poke fun at Seattle artists with a comic when New York artists are practically cartoon characters already?

Thursday, August 20, 2015

Parentless Binary Search Tree

Binary search tree's are a helpful data structure in which nodes have two children and one parent. A nodes left child will be less then the parent, and a nodes right child will be more then the parent. In a BST where nodes have no parent pointer, every node is essentially its own tree. This means any method that you can call on a tree head, you can call on it's children, allowing for recursive solutions to most BST problems or methods.
Node insertion is easy, with or without a parent pointer.
...
  def insert(self, val):
      if val < self.val:
          if self.lchild is None:
              self.lchild = TreeNode(val)
          else:
              self.lchild.insert(val)
      if val > self.val:
          if self.rchild is None:
              self.rchild = TreeNode(val)
          else:
            self.rchild.insert(val)
Traversal is also easy.
...
  def depth_traversal(self, order="pre"):
      if order == "pre":
          yield self.val
      if self.lchild is not None:
          for v in self.lchild.depth_traversal(order=order):
              yield v
      if order == "in":
          yield self.val
      if self.rchild is not None:
          for v in self.rchild.depth_traversal(order=order):
              yield v
      if order == "post":
          yield self.val
These are simple, because you are recursing down the tree.
Tree balancing is much more complicated, because logically you need to start on the bottom of the tree, each node rotation needs to update what the parent is pointing to, and the pointer to the head node may no longer be the head node.
All of these problems can be worked around. If you return the pivot node at the end of a rotation, then you can call rotations from the parents pointer.
    def _rot_right(self):
        pivot = self.lchild
        self.lchild.rchild, self.lchild = self, self.lchild.rchild
        return pivot

    def _rot_left(self):
        pivot = self.rchild
        self.rchild.lchild, self.rchild = self, self.rchild.lchild
        return pivot

>>> node.lchild = node.lchild._rot_right()
Starting at the bottom of the tree can work in the same way as post oder traversal, where by recursing through the tree at the beginning of your function, and stepping through logic after assures that you will visit all the children of a node before you visit that node
...
  def rebalance(self, head):
    if self.lchild is not None:
        self.lchild.rebalance(head=head)
    if self.rchild is not None:
        self.rchild.rebalance(head=head)

    balance = self.balance()
    if balance > 1:
        lbalance = self.lchild.balance()
        if lbalance > 1:
            self.lchild = self.lchild._rot_right()
        elif lbalance < -1:
            self.lchild = self.lchild._rot_left()
    elif balance < -1:
        rbalance = self.rchild.balance()
        if rbalance > 1:
            self.rchild = self.rchild._rot_right()
        elif rbalance < -1:
            self.rchild = self.rchild._rot_left()
Rebalancing should return the new head node, so that pointers can be reassigned elsewhere.
...
  if head is self:
      if balance > 1:
          head = self._rot_right()
          head = head.rebalance(head)
          return head
      elif balance < -1:
          head = self._rot_left()
          head = head.rebalance(head)
          return head
    return self
And there you have it. A Binary Search Tree with no parent pointer.

Wednesday, May 14, 2014

Degenerate

This is the first comic I've ever drawn that ever hung in a gallery for any reason.
Go look at it, and at the off chance you're in New York City, go look at the original at Undercurrent Projects!

Tuesday, April 15, 2014

An Afternoon on Omegle.


My girlfriend and I had a lovely round of thought provoking discussion with strangers on the internet.
Read our dialouge under the break!

Tuesday, March 18, 2014

It's Nuzlocke season, apparently

I'm seeing a lot of other Nuzlocke updates on the site. I hope you aren't tired of reading them yet because I have another to add to the pile!

Last time I wrote about my Black Nuzlocke I had just started. I had Hamm the Tepig and Jasmine the Purrloin. Well, two gym badges later I am in Castelia City. I'm preparing to fight the bug gym leader there. On the way I lost Jasmine the Purrlion, RIP. She fought bravely against team Plasma but it just wasn't enough.
On the way to the second badge I caught Pecan, the Roggenrola. She and Hamm (now a Pignite) DESTROYED the normal gym with their fighting moves (Rock Smash and Arm Thrust, respectively.) On the way to kick some Team Plasma ass, I caught Biscuit the Cottonee! It's nice to have a grass guy on my team. I was starting to get worried about encountering a water Pokemon and having nothing to send out.

I'm in the Castelia City gym as I type this....I'm going to fight the gym leader real quick.
Brace yourself Burgh!

**Live blog**
Strong start with Hamm. I have four levels on his Whirlipede. I don't want to use physical moves and get poisoned so I'm stuck with Ember for now. Dead!
Uh oh, Dwebble next. Uh, I guess Hamm will stay out. I still have four levels on him.
Flame Charge, twice. Dead!
Leavanny next. Do I chance it and send out Roggenrola? She has sturdy, why not? Go Pecan!
Oh boy. Razor Leaf hits hard. Rock Blast almost kills Leavanny but I need to get Pecan out of there.
GO HAMM! Bastard used Hyper Potion. Leavanny is faster but Flame Charge is a one hit KO
AWH YEAH FUCK YOU BURGH!
**End Live Blog**

Here's my team as it stands after that gym battle:
Hamm (Pignite) Lv. 25
Pecan (Roggenrola) Lv. 22
Biscuit (Cottonee) Lv. 24

<3Billie

Thursday, March 13, 2014

Nuzlocke: Azalea Town and MFing Bugsy

Time for an update on my SoulSilver nuzlocke challenge! :)

So far things have gone all right, but there have been some really close calls. Togepi hatched, and that little shit knows EXTRASENSORY ALREADY. Fucking psychic-type move right out of the box. Er, egg. I guess Togepi never really leaves the egg. You get what I'm trying to say here.

I also managed to get through Union Cave (first Pokemon was a Zubat, said fuck that and killed it), which was good because I realized two things are on the other side of that cave... Slowpoke Cave and Azalea Town, which means another badge to earn and some more Team Rocket bitches. Oh, and an old guy who will make special pokeballs out of apricorns that I find. Which might prove useful later.

Saturday, March 8, 2014