Hello Seña dialog rough

I sat down with my friend Tomoko and did an initial reading of my script Hello Seña.

It’s been a while since I did anything related to Little Robots, so this was fun.  Naturally, this is not the final recording.  My Japanese is pretty obnoxious, but it’ll help a lot for storyboarding the scene.

Here’s a spliced together dialog.  You can hear a lot of background noise in this… I’ll have to figure out how to clean it up.  The recording itself was done on my iPhone4S.  Tomoko and I used Skype for the actual conversation.

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

Weirdo mythology

I was considering the mythology of the Weirdo a moment and thought it might be fun to flesh out the character as a little kid.

It’s basically the start of 90% of all little kid stories.  You have a little kid who has an overactive imagination and next thing you know, all hell breaks loose.

I’m not really interested in coming up with a original story here, just a fun one… so starting with a cliche such as the weirdo being a little kid who happens to have a toy helmet is a safe premise to build from.

I find it unlikely any of the concept art stuff like the image to the left will ever actually make it into the game, but I need the drawing practice… and I wanted things fleshed out.

 

 

The Weirdo

After sketching out a few different characters, I think that this is the overall shape that the Weirdo will take.

Yeah he kind of looks like Marvin the Martian, but meh. He’s easy to draw and that’s pretty important for me.

 

Coursera Classes

I’ve been increasingly impressed by the quality of the online classes on Coursera.

At present, I’m taking two classes, Machine Learning and Human-Computer Interaction.

The Machine Learning class is provided by Stanford University and is taught by Andrew Ng.  The class is challenging but very gratifying.  The class uses Octive/Matlab for its assignments.  The biggest challenge for me so far has been the conversion of mathematical formulas into efficient “vectorized” Octave code.  I’ve always taken for granted that matrix operations did specific tasks… like rotate a shape or change the contrast in an image.  I’ve never really had to face the task of how they do it.  I enjoy that the class takes you from zero knowledge of machine learning to a Neural Network that recognizes handwriting in just the first 5 weeks.  Extremely gratifying.  As part of my learning process I’ll be coding some of the stuff that I learned from the class in Java and later C++.  These things will probably be useful as I work on the pi-like stock market predictor from my previous post… Hopefully I won’t end up drilling a hole in my head.

the Human-Computer interaction class only just started … so I have only gotten through the introduction videos, but I can already tell that the class will affect and inform a lot of the design decisions that I make in the future. The class is also provided by Sanford University and is taught by Scott Klemmer.   The class itself seems to be about formalizing the process of making good user interfaces.  By formalizing, I don’t mean some kind of rigorous proof that X is the best design, I just mean putting enough process around design that will make it approachable to people who have no design intuition (like myself).  I have to wonder if maybe I can use this as an excuse to explore some of Buckmeister Fuller‘s design and engineering principals…. I recently saw an exhibit at SFMOMA entitled “The Utopian Impulse: Buckminster Fuller and the Bay Area“.  Extremely inspiring.

Another Pi Image is Born

I recently saw the movie Pi for the first time.  A number of friends and family recommended the movie to me when it first came out.  Me specifically.  As in, this movie would somehow resonate with me on some fundamental way.   It just seemed, though, that the harder I was pushed to see the film, the less likely I felt like actually watching it.

Fast forward about 10 years to a week ago.  I was trolling Netflix streaming for something to watch and decided… “Oh, what the hell.”  I hit play.

I can understand why so many people thought that I’d like this movie.  I think though, that it hits a little too close to home in some aspects but is somewhat dumb in others.  I don’t really want to get into a technical review of the movie because I’m sure that it wasn’t intended to be scrutinized in that way.  I did enjoy it as a story though.

Every computer scientist I know has thought about how to predict the stock market.  I’m not sure that each and every one creates some explicit mantra as does the guy in the movie, but, you know… we don’t all live in a black and white film.

When I’m done with the Machine Learning class over on Coursera, I do plan on trying to make a short-term sale predictor AI.  I’m hoping that I won’t inadvertently learn a true name of God and end up drilling a hole in my head.  I guess we’ll see.

Instead of just stealing someone else’s colorful pi image, I thought I’d be fun to make one.  The image used in this blog post was based on the Wikipedia SVG of the Greek Letter.  I imported it into the GIMP and exported it as text (Yeah, you can do that!).  After cleaning it up a little, I wrote a program that would populate the actual pi digits into the exported image.

#!/usr/bin/perl
use strict;

open(my $pifd, "pi-image.txt") or die "couldn't open pi image";
open(my $numfd, "pi-digits.txt") or die "couldn't open pi digits";
my $ch;
while(1) {
    read($pifd, $ch, 1) or last;
    if ($ch eq "\n") {
        print "\n";
        next;
    }
    if ($ch ne ' ') {
        read($numfd, $ch, 1) or last;
    }
    print "$ch";
}
close($pifd);
close($numfd);

Once I had the numerically populated glyph, I pulled it back into the GIMP via screenshot and applied a rainbow gradient! Bam! Yet another Pi image is born!

Arduino Control from Web via WiFly

I bought a WiFly a while back but didn’t really do much with it.  For those of you not in the know, a WiFly is a compact wireless device that you can buy on a little break-out board… or in this case, on an Arduino Shield.

The interface to the WiFly is pretty straight forward.  You initialize the library then create a Client object.  This Client object has typical filehandle-like methods such as read(), available(), println() etc.

In this example, I took my previous setup with 8-bit latches and used the LEDs to display output that I submitted to a webservice using the WiFly.  The Webservice in question is a very simple php app that returns a single 8-bit hex number.  Here’s the code:

<?php print '@'.dechex(time() % 255); ?>

The prepended ‘@’ sign is a flag value.  Because read() returns just a single char, I wanted to skip through all of the http header information to the data.  I stop when I encounter the first ‘@’.

I modified the latch setup I had by using two triplets of pins instead of sharing the single triple.  This allowed me to independently control two latches. Here’s the final code for the project:

#include "WiFly.h"

int latchPin1 = 2;
int clockPin1 = 3;
int dataPin1 = 4;

int latchPin2 = 5;
int clockPin2 = 6;
int dataPin2 = 7;

Client client("www.tokyo3.com", 80);

void setup() {
  Serial.begin(9600);
  pinMode(latchPin1, OUTPUT);
  pinMode(clockPin1, OUTPUT);
  pinMode(dataPin1, OUTPUT);

  pinMode(latchPin2, OUTPUT);
  pinMode(clockPin2, OUTPUT);
  pinMode(dataPin2, OUTPUT);

  WiFly.begin();

  if (!WiFly.join("ssid", "password")) {
    Serial.println("Association failed.");
    while (1) {
      // Hang on failure.
    }
  }
}

int convert(char ch) {
    if (ch >= '0' && ch <= '9') {
         return ch - '0';
    }
    if (ch >= 'a' && ch <= 'f') {
         return ch - 'a' + 10;
    }
    return 0;   
}

int getWebValue() {
  if (!client.connected()) {
      Serial.println("Connecting...");
      if (!client.connect()) {
        return 0;
      }
  }

  client.println("GET /arduino.php HTTP/1.1");
  client.println("Host: www.tokyo3.com");
  client.println();  

  char ch;
  while (client.available()) {
    ch = client.read();
    Serial.print(ch);
    if (ch == '@') {
      break;
    }
  }

  if (!client.available()) {
     return 0;
  }

  int a = convert(client.read());
  int b = convert(client.read());

  return (a << 4) + b;
}

int count = 0;
void loop() {
    int a = getWebValue();

    if (count++ % 2 == 0) {
        digitalWrite(latchPin1, LOW);
        shiftOut(dataPin1, clockPin1, MSBFIRST, a);  
        digitalWrite(latchPin1, HIGH);
    } else {
        digitalWrite(latchPin2, LOW);
        shiftOut(dataPin2, clockPin2, MSBFIRST, a);  
        digitalWrite(latchPin2, HIGH);
    }
    delay(1000);
}

Pretty simple for the most part.  As with the WiFly examples, I use the Serial Monitor to echo print.  Very useful when trying to figure out what you’re getting via network.

 

Terrain Tiles

The challenge here is, What is the minimal set of terrain tile types to be able to build arbitrary terrain in a side scroller?  In theory, you don’t need minimal sets of anything if your blocks fit exactly into a square.  You see that all over; especially in the older Nintendo classics.  I want to be able to use a more diverse set of borders though… and I *think* the above image represents a complete set.

That’s not to say that each type of tile won’t have many distinct tilesets… Hopefully I will have quite a few distinct tilesets for this game.

Monkeying with 8-bit Latches

I while back, I bought a couple of 8-bit Latches which I had intended to conquer the world with… but just never got around to it. As I’ve just found out… these specifically may not be the right model for that purpose. sigh.  Let me expound…

As I’ve explored in previous Arduino setups, I want to control lots of things with few output pins.  With this specific setup, I was hoping to populate two different 8-pin latches using a large number of shared pins like with the LCD project… but alas, these latches don’t really like sharing their pins…

If I share pins between the latches (clock/latch pins) but have a selectable data pin, the unselected latch still *thinks* I’m talking to it… What I need is a latch with an Enable Pin.

Pictured above, I was just testing to verify that both latches actually worked. Both are connected to the same outputs, so their values are mirrored. I won’t post any code this time because I used the ShiftOut example verbatim.

Building for Windows!

Download the Windows Version!

It took me a while to get there, but I’ve finally gotten a Windows build of the Weirdo in a Weird Land bootstrap project!

My first attempt at building one involved grabbing Visual Studio 10 Express but it really wasn’t meant to be used from the command line… at least not easily…

The successful strategy was to use the Minimalist GNU for Windows toolchain.  This lead to some heartache which began with linker issues… but working with the SDL FAQ, I got things mostly working.  Of all the problems, the most surprising to me was the fact that including libraries in gcc is significant.  Specifically… the following did not work:

$(CC) -o $(BUILDDIR)/$(EXETARGET) $(BUILDDIR)/main.o \
    $(BUILDDIR)/Level.o $(BUILDDIR)/SDLAppMain.o \
    -L$(SDLDIR)/lib -L$(SDLIMAGEDIR)/lib/$(ARCH) \
    -lSDLmain -lSDL -lSDL_image -lmingw32 -mwindows

but THIS did!

$(CC) -o $(BUILDDIR)/$(EXETARGET) $(BUILDDIR)/main.o \
    $(BUILDDIR)/Level.o $(BUILDDIR)/SDLAppMain.o \
    -L$(SDLDIR)/lib -L$(SDLIMAGEDIR)/lib/$(ARCH) \
    -lmingw32 -lSDLmain -lSDL -lSDL_image -mwindows

The significant part here is the -lmingw32 being first.  Without that, I got the following linker issue…

Undefined reference to 'WinMain@16'

Which is discussed in the FAQ… but the answer did not point out that the ordering of the libraries was significant!

Now i just need to create a proper Makefile that will switch easily between the two architectures…. then it’s time to actually write the game!

UPDATE: The original zip that I uploaded seemed to be missing a few necessary files… specifically two DLLs: libgcc_s_dw2-1.dll and libstdc++-6.dll both of which are now part of the distribution.

Weirdo in a Weird Land

Weirdo in a Weird Land is the working title for the slowly progressing game.

It took a while to actually get the application bundle squared away.

Click Image to Download v0.0.1!

One of the more irritating parts of creating the bundle was referencing the image resources.  Mac Applications are supposed to keep their data in a Contents/Resources but using the provided SDLMain, your application’s working directory is the PARENT of the resource bundle… so you’d have to make the assumption that the end user didn’t rename the application bundle on you and build your path including what you think your resource bundle is named.

I modified the SDLMain a little bit, putting the working directory at the top level of the Application Bundle.  This allows me to reference my image files as: Contents/Resources/Images/ which is still a little ugly, but probably more reliable.  The “correct” thing to do would be to have SDLMain expose a method which allows me to retrieve the path of individual resources.  That’s probably a much later change though.

My most recent efforts are to get a Windows build going.  I’d like to do the up front work to make this game cross platform.  This way, I can release builds for both Mac and PC/Win32 relatively easily in the future.  My first attempt at creating a Win32 build was using Visual Studio 2010 Express, but I ran into a lot of strange linking issues.  The compilation process was tough too.  cl.exe command line compiler had radically different invocations than gcc… so it’s unlikely that I’d be able to reuse the same Makefile. There has to be an easier way to build a windows app than this…

The SDL Tutorial suggests using mingw32 which is a minimalist windows toolchain built on top of all GNU tools.  This means that I *SHOULD* be able to reuse my Makefile and if it’s part of the tutorial… I shouldn’t run into weird issues.  We’ll see how that pans out.  Hopefully by Thursday I’ll have a slightly expanded build that runs on both Windows and OSX!