A Few Misc. Star Citizen Images

I’m a supported of Star Citizen, an online space game currently in development.  Some people have put up websites that let you create custom images related to the game.  Here’s a few of them I’ve made.

CitizenCard

A Citizen Card for my original pledge.

CitizenCard2

A Citizen Card for my current pledge level.

ShipCertificate2A title for for my first spaceship.

How does your garden grow?

 

Surprise!  I’m making a new post!  Behold my garden!

2016 garden

2016 garden

Yeah, OK, so it’s not exactly your traditional garden, but hey, I live in  a motorhome, so it’s not like I have a real backyard to plant things in.  Initially I wasn’t going to grow much of anything this year because I had thought I would be moving at the end of the July, but my work situation has much improved itself recently (as has my income!) so now I’m going to be sticking around for a while.  Hence, I decided to not only have a garden but also to expand it.

I already had the six pots in the foreground – 3 of the big pots have serrano pepper seedlings in them that I’m growing from the seeds of the last peppers off of last years plants.  The small pot has garlic chives, which I mostly just munch on while I’m outside checking the other plants, and up against the wall are a couple of heirloom tomatoes (Red Beefsteak and Mr Stripey) that I picked up after getting the raise last month.

In the back are four plants that I got just yesterday – four different hybrid tomato plants.  I figure with six different varieties of tomato I should get at least a couple of them to produce well even though they are in pots and will have to put up with the nasty Texas summer heat.

That heat is a real killer for potted plants.  In the worst of it in late July and early August I have to drench every pot in the morning when I go to work and still the plants are drooping when I come home in the evening, so I have to water them again then.  As long as stormy weather isn’t threatening I try to keep my RV awning pulled down to keep the plants shaded in the middle of the day when the heat is the worst.

My First Game

The past month I’ve been learning about the Unity game engine, reading the manual, going through tutorials, and setting up some test projects to tinker on my own. This week I finally felt comfortable enough to do a real game of my own from scratch, so I decided to start with a good old classic by building a single player Pong-like game. I call it Pingish. It has two modes: Raquetball, and Brick Breaker.

Pingish

It’s not fancy, but it does make use of the most important systems in Unity.

  • It uses 3D graphics for the game objects, although the view is a top down isometric view.
  • It uses the UI system in worldspace to create the on-screen display of the score, ball count, and other informational messages.
  • I found some free to use sound files to give it a little music and some appropriate sound effects, all in a nicely retro 8-bit game style.
  • The physics engine is used in combination with some hand-rolled calculations to control the movement of the ball.

I am glad that I started with such a small project, because even as simple as it is I had a few moments of head scratching from actually trying to put Unity to use for real and finding out by experience that it doesn’t always behave the way I assumed it would.  For example, the ball bounces produced by the built in physics engine seem to result in a new trajectory that is biased towards the surface normal, and after a few bounces the ball actually started bouncing back directly along the normal!  I don’t know why this is, though I suspect it has something to do with the spin on the ball.  It was definitely not the behavior I wanted, though, so I ended up calculating the bounce trajectory by hand.

I didn’t bother putting too much polish on it since it was mostly a learning project, but if you would like to play it you can find a WebGL version of it on this site, or you can download a zip file with the Windows build.  The WebGL version has poor performance, at least in my browser.

The game uses the left and right arrow keys to control the movement of your paddle, Q quits, spacebar restarts after your game is over.

WebGL Pingish (Note: Seems to work best in Chrome.  It works in Windows Firefox, but not OSX Firefox.  Does not work in Safari either.)

Pingish for Windows

 

Games I Have

A recent post on a forum got me wondering how much I really need Windows for gaming, so I decided to see what games I have installed on Linux versus Windows.  To my surprise I have far more games installed on Linux!  However, the games I play most often tend to be only available for Windows.

Linux

  1. The Beginner’s Guide
  2. Beyond Eyes
  3. The Cat Lady
  4. Depression Quest
  5. Gone Home
  6. Grim Fandango
  7. Hate Plus
  8. Kerbal Space Program
  9. Last Word
  10. Portal
  11. Portal 2
  12. Amnesia
  13. Penumbra Overture
  14. Diaspora
  15. Doom
  16. Dreamfall Chapters
  17. Game Dev Tycoon
  18. Gish
  19. Aquaria
  20. Lugaru
  21. Samorost
  22. Word Of Goo
  23. Braid
  24. Cortex Command
  25. Machinarium
  26. Osmos
  27. Revenge of the Titans
  28. Beyond Zork
  29. Enchanter
  30. Sorcerer
  31. Spellbinder
  32. Wishbringer
  33. Zork 0
  34. Zork
  35. Zork 2
  36. Zork 3
  37. Leather Goddess of Phobos
  38. Starcross
  39. Limbo
  40. Analogue
  41. Neverwinter Nights
  42. Pingus
  43. Planeshift
  44. Silent Hill
  45. Psychonauts
  46. Second Life
  47. Shroud of the Avatar
  48. Ultima 4
  49. Ultima 5
  50. Ultima 6
  51. Ultima 7
  52. Ultima 8
  53. Ultima Underworld
  54. Ultima Underworld 2
  55. Vegastrike

Windows

  1. IL2
  2. Legend of Grimrock
  3. Neverwinter Nights
  4. Neverwinter Nights 2
  5. Planescape Torment
  6. Beneath a Steel Sky
  7. Lure of the Temptress
  8. Second Life
  9. Shelter 2
  10. Star Citizen
  11. Morrowind
  12. Oblivion
  13. Skyrim
  14. Fallout
  15. Fallout 3
  16. Fallout New Vegas
  17. Fallout 4
  18. Call of Cthulhu
  19. Wing Commander
  20. Wing Commander 2
  21. Remnants of Isolation
  22. Goats on a bridge
  23. Last Word
  24. Whisper of a Rose
  25. Labyrinthine Dreams
  26. Crimson Clover
  27. Dragon Age Inquisition
  28. Elite Dangerous
  29. The Path
  30. The Vanishing of Ethan Carter
  31. Mass Effect
  32. Mass Effect 2
  33. Mass Effect 3

A Tale of Two Languages

Recently I was talking to a colleague who is still in school and he mentioned a new blog post he had written about string search. He had implemented a brute force search and so I told him about faster algorithms that he should consider, specifically mentioning the Knuth-Morris-Pratt algorithm. He read up on it at Wikipedia and wrote a Perl implementation, but when we ran it I was shocked to discover that KMP was significantly slower than brute force! This made no sense. Further experimentation showed that Perl’s index function was even faster still!

When I wrote up an implementation of KMP and brute force in C, I got results that were in line with my expectations: KMP in C was much faster than brute force.

So what is going on?

What’s happening is a result of the way Perl implements it’s data types. They do not, after all, correspond to the primitive types available in C/C++, Java, or other languages. In particular a Perl “array” is actually a complex data structure that is manipulated by a set of non-trivial functions, while a string is a less complex (though still complex in it’s own right) structure, so it really makes sense that string processing would be faster than array processing in Perl. Furthermore, Perl’s index function implements the Boyer-Moore string search algorithm, which is even faster than KMP, so the speed of the index function should come as no real surprise.

The take away lesson here is that even when you know of a good algorithm for solving a problem, you should not rush to write it up. A lot of very smart people have spent their time creating and fine tuning the languages and libraries that we use, so it is quite likely that someone has already done the work you need, and there may be a better alternative to your own solution built right in to your language. Check it out before wasting your time reinventing the wheel!

Update, August 18, 2015

There is actually a second lesson here, which may be even more important. Just because the language you are using gives you a data structure that has an array like interface, that doesn’t mean it is actually an array, and if it isn’t an actual array, then standard algorithmic analysis techniques may not apply to it! This is the case for Perl’s “arrays”, and also for lists in Python, Lisp, and other languages. This is why KMP is slower than brute force in Perl: the assumptions made in the standard analysis of the algorithms is that we are working with real arrays – a group of primitive data elements stored in contiguous locations in memory which guarantees us constant time lookup of any arbitrary data element with a very small time per operation. Perl arrays fail on all counts, here.

kmp.c – Test program in C.
kmp.pl – Test program in Perl.
A Tale of Two Cities – Some sample data for searching.

Interview Questions: Call by reference and call by value

A common simple interview question is to explain the difference between “call by value” and “call by reference”. This refers to the way arguments are passed to functions.

In call by value, a copy of the argument is made and given to the function so that any changes made to the argument affect only the function itself. Once the function returns, the original variable passed as the argument is unchanged.

void foo ( int x ) {
    x = x + 1;
    printf( "In foo x is now %d\n", x );
}

int a = 0;
printf( "Before foo a is %d\n", a );
foo( a );
printf( "After foo a is %d\n", a );

 

This code snippet will produce the following output:

Before foo a is 0
In foo x is now 1
After foo a is 0

The value of a is unchanged because a is passed by value, and in the function foo(), x merely holds a copy of the value of a so that changes to x do not affect a.

Call by reference does things differently, however. In call by reference, the function argument refers to the exact same variable as the one passed by the caller, so changes made in the function are visible to the caller.

void foo ( int &x ) {
    x = x + 1;
    printf( "In foo x is now %d\n", x );
}

int a = 0;
printf( "Before foo a is %d\n", a );
foo( a );
printf( "After foo a is %d\n", a );

 

This code snippet will produce the following output:

Before foo a is 0
In foo x is now 1
After foo a is 1

Notice the subtle change to the definition of foo(). Now the argument is defined as “int &x“. In C++ this tells the compiler that the argument is a reference parameter instead of a value parameter. Therefore x becomes an alias for a when we call foo()

Different languages support different conventions. C++, for example, supports both call by value (the default) and call by reference (when you define an argument as a reference parameter as I did in the second example above). C, on the other hand, is purely call by value. To achieve the effect of call by reference in C you have to declare your argument as a pointer to something, in which case the pointer is passed by value, but you can dereference the pointer to change the thing it points at.

void foo ( int *x ) {
    *x = *x + 1;
    printf( "In foo *x is now %d\n", *x );
}

int a = 0;
printf( "Before foo a is %d\n", a );
foo( &a );
printf( "After foo a is %d\n", a );

 

Before foo a is 0
In foo x is now 1
After foo a is 1

Again, this is actually an example of call by value – x contains a memory address that is a copy of the address of a and if you change x then you are only changing what x points to – a is unchanged, and so is it’s address in memory. Some people refer to this idiom as “call by pointer”, though in my opinion that is really a misnomer since the language is not actually providing you with another calling convention, rather you are simply using a programming idiom to achieve the affect you want.

There are languages that are neither call by reference nor call by value. Python, for instance. You can read a nice writeup about that in “Is Python call-by-value or call-by-reference? Neither.

Perl is an interesting case to me in that it is actually a call by reference language, but the most idiomatic way of using it makes it seem like it is call by value. Consider the following sample.

sub foo {
    my $x = shift;
    $x = $x + 1;
    print "In foo $x\n";
}

my $a = 0;
print "Before foo $a\n";
foo($a);
print "After foo $a\n";

 

This produces the following output, which makes it look like Perl is passing the argument by value.

Before foo 0
In foo 1
After foo 0

But what is really going on is that you, the programmer, are making a copy of the argument as the first thing in your function. The line my $x = shift; actually makes a copy of the first element of the @_ argument array (and removes the first element afterwards). Look what happens when you avoid the shift:

sub foo {
    $_[0] = $_[0] + 1;
    print "In foo ".$_[0]."\n";
}

my $a = 0;
print "Before foo $a\n";
foo($a);
print "After foo $a\n";

 

Before foo 0
In foo 1
After foo 1

Now it is clear that Perl is really passing the variable $a by reference.