Depressed again

Well, it’s that time of life again, when depression rears it’s misshapen little head and smiles in my direction.  Things had been going very well for me this past spring, but then came a month of heavy rains and a flood that trapped me and ruined my RV.  Since then I’ve been living with my mother while most of my possessions sit in a storage unit.  While I’ve survived I’ve also fallen into a deep, deep funk.

I really enjoyed living in an RV.  I lived in a nice, quiet, almost rural setting where the noise and stink of city life didn’t reach.  I was living on a river bank, surrounded by woods, and my neighbors included rabbits, possums, cardinals, deer, and other wildlife.  It was very tranquil for the most part.   (Sometimes my neighbors in the RV park would get a little rowdy, but not too often.)  Being in an RV also gave me a sense of independence and security that was really very nice.  It meant that if any natural disaster threatened then I could easily pack up and drive away to safety. Of course, that didn’t happen in the end.

The day the flooding started I was a little worried, and I thought about driving out to a hotel as I had done the previous month during a different flood, but instead of following my instinct I got online to check out the Harris County Flood Control District’s website, as well as the National Weather Service’s flood monitor and prediction site.  Both of them indicated that the flooding would not be as bad as it had been the previous month, so I made the decision to stay put.  That was a bad decision.  By the end of the day, the predictions had been updated to show that things were going to be much, much, worse than they had ever been, and by then the road out of the RV park was too flooded for me to be able to get through it.  I was stuck.

The water kept rising throughout the night, and by the next day it was lapping at my tires.  I moved my RV to the highest ground I could get to in the RV park, but the water kept rising.  Late that Saturday afternoon I found myself getting into a fire department boat with my cats, my medicine, and a change of clothes.  Everything else had to be left behind to fare as best it could.

So I went to stay with my mother, and to let my hands heal – one of my cats panicked so badly during the evacuation that he bit and clawed my hands up very badly and they become swollen and infected to the point that I could hardly use them.  It wasn’t until the next Tuesday that I was able to really do anything again, so I went and rented a car.

And promptly got into a wreck that totaled the vehicle I had just rented.  In fact, it flipped over 360 degrees.  This did not help to improve my mood.  But I did survive the wreck with no injuries other than a soreness in my ribs that lasted a couple of weeks, and thank goodness I had made sure to get extra insurance coverage on the rental car, so I was able to get another one quickly.

The water didn’t go down until Thursday, and at that point it became clear that the road to the RV park was washed away.  It ran along the side of a large pond formed in an abandoned sand pit, and the walls of the pit collapsed during the flood.  The rush of water into the pit eroded away the ground under the road and a section of road about 50 feet across disappeared into the waters.

Thankfully, there was a back road – a very poorly maintained dirt road – into the area, so I was able to walk on that to get back to the RV and inspect the damage.  My car was a complete loss, and the RV sustained enough damage to the floors and electrical systems that I decided not to bother with trying to repair it.

I had lost my home.

So I began a weeks worth of trips in 100 degree heat to get my possessions out.  (Thankfully, most things were high enough to avoid getting wet, and I didn’t lose much.)  At first I had to carry things out by hand in big duffel bags that I bought for that purpose. On the weekend I bought a new vehicle for myself – a 2007 Toyota Tacoma pickup truck – and started using that to carry things in and out, and making things easier the county came out and roughly paved the dirt road making the drive back to the RV park much smoother. Eventually I donated my car to a charity for auction, and gave my dead RV to a former neighbor who was willing to try and repair it.

And so now here I am.  I have a roof over my head, but I still lost my home.  Most of my things survived, but I don’t have them with me because almost everything is in storage.  I feel like I’ve lost my independence and my security and I feel very vulnerable and miserable.  I blame myself for losing everything I did, because I could have gotten out if I’d listened to my instincts the Friday morning when things first started flooding.

My co-workers tried to help me out by doing a fund-raiser for me.  They raised almost $9000 for me, and this has greatly helped.  It covered the down payment for my new truck, and I still have some left over to get a new RV if I decide to do that, though I don’t think I will, at least not right away.  Living with my mother has made me realize how poor her health is and I now feel obligated to stick around and help her out as best I can, although I’m not doing that, really.  I am so depressed that when I get home at night I generally just go straight to sleep, and on the weekends I get out of the house to run errands or just spend some time trying to distract myself.

The depression has really worn me down badly, and I can’t concentrate at work.  In fact, I am writing this entry while at work, because I just can’t think straight and can’t seem to focus on the code in front of me.  I’m getting almost nothing done either at home or at work.  This is bad.

So this next week I am taking a vacation.  A real, honest to goodness, vacation that is purely oriented around relaxation and getting rid of stress.  This Saturday I’ll be flying to Seattle, WA, renting a car, and driving to Olympic National Park for a week of camping and photography.  I’ve got a list of waterfalls to see, and trails to hike, and I’ll get to see the Pacific Ocean for the first time in my life.  At the end of the trip I’m even going to take a couple of days to drive up to Vancouver and see a couple of online friends in real life for the first time.

I am hoping that taking this trip will help me to reset my brain and get me out of this depression.  This has worked for me in the past – 3 years ago when I was coming out of a divorce I did something similar and it really helped me then.  In fact, that was the first real vacation I’d ever taken in my life, and this will be the second.  I hope someday to take a third vacation under more pleasant circumstances.

 

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.