import os
import re
import shutil

class Item:

    def __init__(self, path, index, no_name):
        self.path = path
        self.index = index
        self.no_name = no_name
        self.next = None

    def __str__(self):
        return str(self.index) + "\t" + self.path

    def __len__(self):
        ii = 0
        current = self
        while current != None:
            ii += 1
            current = current.next
        return ii

    def insert(self, path, index=None):
        head = self
        previous = head.advance_to_index_predecessor(index)
        if index == None:
            index = previous.index + 1
        item = Item(path, index, self.no_name)
        if previous != None:
            item.next = previous.next
            previous.next = item
        else:
            item.next = head
            head = item
        item.increase_indices()
        return head

    def advance_to_index_predecessor(self, index=None):
        previous = None
        current = self
        while current != None:
            if index != None and current.index >= index:
                break
            previous = current
            current = current.next
        return previous

    def increase_indices(self):
        current = self.next
        previous_index = self.index
        while current != None and current.index == previous_index:
            current.index += 1
            previous_index += 1
            current = current.next

    def remove_path(self, path):
        head = self
        current = head
        previous = None
        while current != None:
            if os.path.samefile(path, current.path):
                if previous != None:
                    previous.next = current.next
                else:
                    head = current.next
                break
            previous = current
            current = current.next
        return head

    def bunch(self):
        index = 1
        current = self
        while current != None:
            current.index = index
            index += 1
            current = current.next

    def erase_index(self):
        self.index = None

    def save(self, directory_path, prefix_length, delimiter, copy, simulate,
             verbosity):
        name = self.extract_name()
        name = name.lstrip(delimiter)
        prefix = self.build_prefix(prefix_length)
        if self.no_name:
            file_name = prefix + self.extract_extension(name)
        else:
            file_name = prefix + delimiter + name
        path = os.path.join(directory_path, file_name)
        self.write_path(path, copy, simulate, verbosity)

    def build_prefix(self, prefix_length):
        prefix = ""
        if self.index != None:
            prefix = str(self.index).zfill(prefix_length)
        return prefix

    def extract_extension(self, name):
        return "." + name.split(".")[-1]

    def write_path(self, path, copy, simulate, verbosity):
        if not os.path.isfile(path) or not os.path.samefile(self.path, path):
            if not simulate:
                if copy:
                    shutil.copy(self.path, path)
                else:
                    shutil.move(self.path, path)
            if verbosity > 0:
                print "Wrote:", self.path, "=>", path

    def get_largest_index(self):
        current = self
        while current.next:
            current = current.next
        return current.index

    def extract_name(self):
        file_name = os.path.basename(self.path)
        match = re.match("^[0-9]*(.*)", file_name)
        return match.group(1)
<?php

define("STYLE_SHEET", "style.css");
define(
   "PAGE_TITLE",
   "Elemental Parents &#187; Lightweight Hierarchical Database");

display_page();
function display_page() { echo build_page(); }

function build_page()
{
   $markup = "<html>\n\n";
   $markup .= build_head();
   $markup .= build_body();
   $markup .= "</html>";
   return $markup;
}

function build_body()
{
   $markup = file_get_contents("elmp.html") . "\n";
   return $markup;
}

function build_head()
{
   $markup = "<head>\n";
   $markup .= "<title>" . PAGE_TITLE . "</title>\n";
   $markup .= build_style_sheet_tag();
   $markup .= "</head>\n\n";
   return $markup;
}

function build_style_sheet_tag()
{
   $markup = "<link href=\"";
   $markup .= STYLE_SHEET;
   $markup .= "\" rel=\"stylesheet\" type=\"text/css\"/>\n";
   return $markup;
}
<?php

define("OPEN_ELEMENT_CHAR", "(");
define("CLOSE_ELEMENT_CHAR", ")");

define("NAME_COMPONENT", 0);
define("ID_COMPONENT", 1);
define("DATA_COMPONENT", 2);
define("COMPONENT_COUNT", 3);

define("ELMP_VERBOSE", True);
<?php

// The refrigerator picked up a mix of transmissions from Andromeda, one of
// them was a loop, "Attention All Humans..."

class Element
{
   public function __construct($id=NULL, $name=NULL, $content=NULL)
   {
      $this->id = $id;
      $this->name = $name;
      $this->content = $content;
   }

   public function __toString()
   {
      return "Element $this->id -- $this->name\n";
   }

   public function count()
   {
      return ((is_object($this->content)) ? $this->content->count() : 0) +
         (($this->next) ? $this->next->count() : 0) + 1;
   }

   public function measure_depth()
   {
      $current = $this;
      while ($current)
      {
         if (is_object($current->content))
         {
            $nodes[] = 1 + $current->content->measure_depth();
         }
         $current = $current->next;
      }
      return ($nodes) ? max($nodes) : 1;
   }

   // Run a user supplied function on every member of the tree.  Return the
   // concatenation of the values given by each recursive call.
   public function format($editor, $indent=False, $level=0)
   {
      $markup = call_user_func($editor, $this, $indent, $level);
      if (is_object($this->content))
      {
         $markup .= $this->content->format($editor, True, $level+1);
      }
      if ($this->next)
      {
         $markup .= $this->next->format($editor, False, $level);
      }
      else
      {
         $markup .= call_user_func($editor, $this->next, $indent, $level);
      }
      return $markup;
   }

   public function convert_to_raw_string()
   {
      $message = "($this->name $this->id";
      $message .= ($this->content || $this->next) ? " " : "";
      $message .= (is_object($this->content)) ?
         $this->content->convert_to_raw_string() : "";
      $message .= (!is_object($this->content)) ? "$this->content)" : ")";
      $message .= ($this->next) ? $this->next->convert_to_raw_string() : "";

      return $message;
   }

   public function convert_to_tabbed_string($level=0)
   {
      $string = str_repeat("   ", $level);
      $string .= "$this->id $this->name";
      $string .= (is_object($this->content)) ? " »\n" : ": $this->content\n";

      $string .= (is_object($this->content)) ?
         $this->content->convert_to_tabbed_string($level+1) : "";
      $string .= ($this->next) ?
         $this->next->convert_to_tabbed_string($level) : "";

      return $string;
   }
}
3.143.111.52
3.143.111.52
3.143.111.52
 
August 12, 2013

I've been researching tartan/plaid recently for decoration in my updated version of Ball & Cup, now called Send. I want to create the atmosphere of a sports event, so I plan on drawing tartan patterns at the vertical edges of the screen as backgrounds for areas where spectator ants generate based on player performance. I figured I would make my own patterns, but after browsing tartans available in the official register, I decided to use existing ones instead.

I made a list of the tartans that had what I thought were interesting titles and chose 30 to base the game's levels on. I sequenced them, using their titles to form a loose narrative related to the concept of sending. Here are three tartans in the sequence (levels 6, 7 and 8) generated by an algorithm I inferred by looking at examples that reads a tartan specification and draws its pattern using a simple dithering technique to blend the color stripes.


Acadia


Eve


Spice Apple

It would be wasting an opportunity if I didn't animate the tartans, so I'm thinking about animations for them. One effect I want to try is making them look like water washing over the area where the ants are spectating. I've also recorded some music for the game. Here are the loops for the game over and high scores screens.

Game Over

High Scores