Saturday, December 25, 2010

Holy crap! I haven't posted here since August!


Earlier today, I removed a semi-frozen 1 pound, 15 ounce solid chunk of pork shoulder from the fridge and cut it into smaller pieces. Being semi-frozen made it easier to cut up, but my left hand sure got pretty cold. It was a necessary sacrifice for the plan. Miss Lizzy will make the pickle meat and rice; I'll make the red beans. I can't wait. I love beans and rice, especially red beans and rice. One of the worst parts about having cancer was the truly awful food I was given to eat while incarcerated in Rush North Shore hospital. Exactly once, and only once in all the time that I was an inmate there did they serve red beans and rice. They were beyond adequate, they were actually pretty good. They were one of the few things that actually smelled appetizing when you lifted off the cover over the plate. Of course, that meant that they had to remove it from the menu, to better inflict the patients with more poorly cooked chicken, mystery meat and dry turkey sandwiches with no readily available mustard. You know, healthy food.

Such bad memories. Enough of that.

I wasted some more time today playing Kingdom of Loathing. Great fun! I finally killed Ed the Undying, got the Holy MacGuffin and had a ticker tape parade. Then I discovered that I could adventure in the CRIMBCO WC while falling down drunk, so a had a few more Salty Dogs and hit the head to fight some hobelfs. Yeah, baby! Unlike in the real world, in the Kingdom of Loathing I'm the man. That's one of the cool things about KOL.



In the real world, Miss Lizzy and I went to Starbucks to get out of the house. George was there, and being a true gentleman and scholar, he bought Miss Lizzy a Eggnog Latte and me an Americano. We spent some time chatting, and I got to talk geek with George for a while. I love talking geek. I get to do it so little these days. I told him about the current status of my great vaporware project, BrikWars Arena and my current Project Euler woes. Yup, I talked too much. I need to learn how to curb my enthusiasm a bit.

So Happy Crimbo to all, and to all, a good night.

Tuesday, August 3, 2010

Adventures in Notetaking

I'm testing out using vimwiki, yes, a Vim script, as a notes program to keep some information synced between my netbook and my desktop. Keeping some notes in Dropbox so they can be accessed from two different machines shouldn't be an exercise in rocket science, yet this been an annoyance for a while. I've looked at some other programs to do this:
  •  Tomboy, which is a pretty good program. It relies on Mono. I don't have many philosophical problems with Mono. (Hey, if Microsoft want to  support open source .NET, cool.) It's just that a huge pile of Mono needs to be installed for Tomboy to work, and I want to try to keep my netbook free of big, big, big programs. Especially big, big, big programs that use Microsoft-type technology.
  •  Gnote is a reimplementation of Tomboy using C++ instead of mono. It's as great as Tomboy, only less filling. The problems that I had with it was that Gnote (and Tomboy) want to put the note files in a fixed location. A fixed location that is not in my Dropbox directory. I want that location to be somewhere in the ~/Dropbox directory, so that both of my machines can work with the files. I tried to use a symbolic link to relocate the files to the Dropbox, and it seemed to work, at least for a while, before it screwed up. Data was lost. No fun. Definitely my bad.  Possibly this will work in a future version. It may even work now, for all I know. Cleaning up the mess was a pain and I don't want to do it again, so I'm avoiding these programs.
  •  Zim is yet another note program, this time implemented in Python. I like Python. It seems pretty good, and I can easily put the notes into my Dropbox folder. The problem that I have is the netbook version is older than the desktop version and can't easily find and read all the files created by the desktop version. The newer version on the desktop machine keeps wanting to uprev the files created on the netbook. They just can't get along. I tried to install the newer version on my netbook but that's a NOP. I get this error message:
       Error: Dependency is not satisfiable: python-support (>= 0.90.0)
Since the system uses Python for, well, I dunno, probably something  important, I'm not messing with it.
  •   Viki/Deplate is another vim script that provides wiki capabilities. I did not have a happy experience with it. I installed it, and a few other scripts that it depends on my machine. Let's just say that I had troubles with it. As the author so helpfully points out:
See :help vimball for details. Also, make sure to read |viki-customization|. If you have difficulties to install this plugin or if you use vim 7.0, please make sure to use the current version of vimball (vimscript #1502). 
I did RTFM. It was like beating my head against the Great Wall of Vim. Guys, I just want to use a script, not study Vim scripting. This thing should just work out of the box.
  •  vimwiki is the current contender. So far, so good. It allows you to choose where it will save the notefiles, and selecting my Dropbox  directory was not a problem. I can look in the directory and see and open the files. The files are plain text files, readable by darn near anything. I like this. I'm going to play with this for a while. We'll see how it goes.

Thursday, July 22, 2010

July 2010 Update

I haven't written in my blog at all in July. Here's some things that happened:

  • The Feds have collected all my remaining  census materials. The only things that I had left were my training manuals and workbook. I had already turned in my ID and enumerator's bag, so I can no longer impersonate a g-man.
  • We had an end to the census NRFU (Non Response Follow UP) phase of the census. We had hot dogs, chicken kebabs and fun.
  • The Feds telephoned me asking for my ID and enumerator bag back. I told them that I had already turned them in. "Who did you give it to?" they asked. My crew leader, (name omitted here). "How do you spell it?" they asked. Being a super grass, I told them. I then emailed her to give her a heads up. You got to love dealing with temporary feds.
  • I fixed Python scripting in Golly on amd64, at least on my machine. It seems there is a two year old bug, reported to Debian, that has not yet been fixed.
  •  The bug report:
    • Installed and played a bit with some other cellular automaton programs. Golly and Mirek's Cellebration still rule, as far as I can tell. I plan to revise my CA (cellular automaton) program, but I'm in learning mode right now, picking up more C++ skills. I'm using a book from the library, Accelerated C++ by Andrew Koenig and Barbara Moo. I highly recommend it; at least it's working for me.
    • John Biggins, the author of A Sailor of Austria, is writing again! His new novel, The Surgeon's Apprentice, is available as a kindle book from Amazon.com. It's great, even though it's not about the Austro-Hungarian u-boat service. He's working on another novel, too. Life is good.
    •  It's bedtime, so I'll bore you dome more...  later.

    Monday, June 7, 2010

    Another day, without the dollar.

    Wednesday, June 2, 2010

    No longer a g-man

    I cleaned up my last addresses yesterday. Since there is no more work for me from the local census office, I was released. Surprisingly, I was the first to finish. I should have milked it more, but what can I say? Wen you're done, you're done. I had to turn in my ID badge, a boatload of paper forms, and sadly, the cool census enumerator's bag. I was hoping to keep the bag, but it is not allowed. I did get to keep the four government issue number 2 pencils, the surviving blue ballpoint pen (one messily self-destructed), a pencil sharpener, some pencil erasers and some paper clips. All useful stuff, even if the pen is a bit suspect.  I also have the D-547 2010 Census Nonresponse Followup (NRFU) Enumerator Manual and the D-590 Census Employee Handbook for Enumerators, Recruiting Assistants and Crew Leader Assistants - 2010 Census. The books never were good reading, and now that the census is over for me, they're not much good for anything except origami.

    It's good to be done, because I have definitely worn out my welcome on the street that I was working on. People get cranky with you if you keep showing up, asking the same questions. Of course, that gives them motivation to be a proxy for you, and give you information about their neighbors and landlords so you can complete the census questionnaires of people who did not fill out a census form, moved in or out on census day, etc. They give you the information so that they can see the back of you. They want you to go away and never come back. Now I never will, unless they want to get together, grill some burgers and drink a few beers.

    It would be nice to work s new street, but there's none left to enumerate. So it's back to unemployment for me. The job search continues.

    Friday, May 28, 2010

    Another One Bites the Dust

    I think I'm back in the game. My score is now 74.

    Thursday, May 27, 2010

    Project Euler Status Report



    Today I cracked not one, but two Project Euler problems: numbers 76 and 63. Woo-hoo! For the longest time I was stuck, but persistence finally paid off. My score is now 72.  I should not have been stuck for so long, but it is what it is. I'm not the best Project Euler competitor by a very long shot. I don't have great knowledge of  number theory and algorithms, but I'm working on it. Now, at least I know what "partition" means in number theory.

    Knowing the correct math terminology makes it much easier to research solutions. I need to spend some more time with a number theory text, pencil and paper. I never thought I would spend time on this kind of math...

    By the way, yes, the "private email" listed in the image will connect to me. It's not the best way, but it will work. 

    Wednesday, May 26, 2010

    G-men on SNL

    Tina Fey enumerating Betty White

    You can watch a very funny census skit from Saturday Night Live on Hulu, at least until it isn't there any more. For the record, Tina Fey's shoulder bag and ID appear authentic, but the clipboard isn't. Real live census enumerators will have an oversize 3 ring notebook binder, which doubles as a writing surface. If Tina was a boy, she would have to be wearing a necktie, but since she isn't, I believe her outfit is acceptable for a temp "g-man".  She should probably tuck in her blouse to look more professional, but that's really not my call.  I wonder if she's really earning a little extra money working for the census, or if the NBC prop department is just really good.

    Tuesday, May 25, 2010

    I'm now a Man in Black, but without the flashy thing.

    I am finally working again. I work for the federal government of the USA, albeit on a strictly temporary basis.  Although the USA has no Official Secrets Act, I am nevertheless sworn to secrecy and thus can't tell you much, on the pain of fines and imprisonment. Really! It's too bad, because I'm getting some really funny stories from this job. C'est la vie. I think it's OK to tell you that I made $US 77.5625 today (before taxes). Cha-ching!

    I have no flashy thing, but I want one. A Pilot G2 pen is a poor substitute. Even if you load it with a Mont Blanc cartridge. Government issue ballpoint pens tend to self-destruct and leak ink. The government will disavow any knowledge of (or responsibility for) your ink stained self, including your clothing. I found one of my father's old pocket protectors; it not only gives me a warm feeling (I really miss Pop) but it protects my shirts from federal blue ballpoint pen ink. The government issue number 2 pencils and the federal blue pencil sharpener do kick ass.

    I don't get to ride in a helicopter, or carry a firearm, or any other weapons for that matter. I don't have a car with a siren or lights, either. Everyone should feel much safer knowing that. I do get to wear a spiffy non-photo ID card on a lanyard around my neck. I also wear a shirt and tie, and I don't wear sneakers or jeans, so I look almost professional. If you close one eye and squint a bit.

    Life is good, for now. Best of all, tonight was taco night. And did I mention the $77.5625, before taxes?

    Saturday, May 22, 2010

    PAC MAN turns 30

    Yesterday was the 30th anniversary of PAC MAN, and Google celebrated with a working version of the game in in the logo of their search page. Of course I inserted a few coins, just like the good old days. Play it while it's still available.

    Update May 25, 2010:  Since everybody loves PAC MAN, he's now a permanent fixture at  http://www.google.com/pacman/. Go there and insert coin now!

    Tuesday, May 18, 2010

    My Life as a Ronin II: Easy Peasy Lemon Squeezy

    The story of Theresa's HP Netbook continues.

    Brian eventually gave the now working HP netbook back to Phil, who gave it back to Theresa. It was working well. We put it through it's paces, and everything was good. Windows XP was singing bel canto.

    Brian kept the netbook for a few days, and played with it a lot. He liked that little HP, and would love to get his hands on one. (As they say, it's not in the budget.) He dragged it all over town, computing up a storm... well, at least he watched a lot of storm and tornado videos on it. (That's his thing.)  He was smitten, and wants get something just like it, except he wants to install OS X on it. This is possible on some models. Not legal, mind you, but possible. Steve Jobs is so pissed.

    The netbook was working well, really, until the Theres-in-ator got her hands on it. The HP then became "goofalized". I have no idea what happened. (Some people should avoid computing devices.) Brian emailed me that he had it again, and that there was an "incident", and it now wasn't booting correctly. Brian's stock repsonse is "hardware problem, it's broken". I emailed back my stock response -- boot into safe mode and fix the beast. He tried, no joy. Eventually he showed it to me at the office, a.k.a. Starbucks. It was really goofed up, and I frankly, I had no idea how to fix it. It would boot up, but nothing ran. Safe mode was no help here.

    This was going to be a royal pain. Phil and Brian were talking about using it for target practice. I thought that would be a waste of a good machine. My contention was it's probably just a software problem, and that we should fix it.  Brian and I talked about reinstalling Windows XP. You would think we could sort that out, but nope. No way. (We're pretty useless I guess.) We had troubles. (Not to mention that Theresa didn't have Windows XP media, even though she paid for a license when she purchased the machine. Brian had a Windows XP disk of some sort -- insert pirate sounds here -- that we were working with.)  It's possible to install Windows XP from a thumb drive (Google says so), but you have to jump through a few hoops to do so and Brian and I didn't make it through. Aw, snap!

    To save the HP from being used for target practice I offered to put Linux on it. Theresa's files were on a SD card, while Windows was on the internal SSD. We could install Linux on the internal SSD, and just leave the SD card alone. Since Theresa is a windows user, so I wanted a easy to use Linux distro.

    I chose Easy Peasy for her. It's very point and clicky, really easy to figure out, but under the hood it's a robust Linux distribution based on Ubuntu. Just the thing for a girl who breaks Windows. Although it was originally designed for Asus eeePC netbooks, [1] I was betting that it would run on the HP. One nice thing about Easy Peasy is it has all the goodies installed from the get go. As the website puts it:
    EasyPeasy is a simple netbook operating system, but still provides you with the codecs and drivers you need for running most music and video right out of the box.
    You should read that as Adobe Flashplayer and and things like mp3 codecs are already installed. Some Linux distributions adhere to GNU philosophy, and you have to futz around to install things required to get more music and video choices on your machine. While we're the subject: play ogg, OK? It really is a good thing. Even if you run the proprietary stuff, use and support free and open source software. It's good to have choices. 
     


    I got things working with Easy Peasy: audio, web cam, wireless networking. It was only slightly annoying. The wireless chipset is from Broadcom, and to work with Linux, it requires the firmware to be downloaded from a manufacturer's site on the internet. It seems that the firmware can't be included in a Linux distro, which is a shame. It's real hard to download firmware from the internet while sitting in Starbucks if your wifi ain't working. I had to drag it home to connect to my local network over a cat5 cable to get the firmware. While annoying, it worked well. Almost easy peasy lemon squeezy. And I got a little exercise walking, too.

    Brian, who is enamored with Mac OS X, really liked Easy Peasy. He downloaded it at home and wanted to install it on a windows desktop box that he uses. The Easy Peasy user interface is really designed for netbooks; I know I wouldn't want to use it on a desktop machine. I pointed him to wubi, which would install the regular Ubuntu Lucid in peaceful coexistence with the Windows OS already installed on the machine, much to the annoyance of Bill Gates. He downloaded and ran wubi, and a bunch of hours later (he was working over the Cricket modem), it finished installing successfully. The cool thing was Ubuntu recognized and used the Cricket modem. I wasn't sure if that was going to happen, which was one reason I recommended wubi. Before this Brian was talking about buying Snow Leopard and turning this machine into a hackintosh. We'll have to see if he continues down the hackintosh road, now that he has has Ubuntu. You know that Brian is broke, and Ubuntu is free (as in beer) as well as free (as in speech), while OS X is neither.

    George saw Easy Peasy, played with it a bit and loved it. Now he wants to install it on his HP netbook.  I'm not really trying to convert people to Linux, but I seem to be doing so anyway. Go figure.

    A few hours later:

    [1]  When I wrote this, I thought that Easy Peasy was once called eeebuntu. I was wrong. According to Wikipedia:
    Eeebuntu (not to be confused with Easy Peasy, formerly known as Ubuntu Eee) is an operating system for netbooks. The current version is based on Ubuntu, newer version will be based on Debian Unstable[1]. Eeebuntu was designed originally for the Asus Eee PC line of netbooks.
    I think Ubuntu eee was what I think I used to run eeebuntu om my Asus eeePC 900, but I'm not sure at this point in time. I know I ran one or the other, and whichever one it was, it was darn good. Both were originally intended to run on Asus eeePC computers, but now work on a variety of netbooks.

    Sunday, April 25, 2010

    I'm up to no good

    I'm in the process of making a virtual hackintosh, using OS X 10.4 Tiger:



    It's going pretty slow. The above process is now at 15%, and it's been running for some time now. It was tricky to get it to this point, so I'm just going to let it run. We'll see if runs to completion. Maybe I have something configured poorly.

    I made two other virtual machines, one Ubuntu Linux "Lucid Lynx" 10.04 and the other Crunchbang 10 "Statler" Alpha 1. They both installed faster than OS X, and both are working well. I plan to eventually put Lucid on my desktop and Statler on my netbook. I'm just playing with OS X; I don't plan on making a real hackintosh.

     Quite a bit later...


     The next morning...


     The network is (finally) up

    Friday, April 23, 2010

    Mirage

    Earlier, I wrote that my pal Brian had a client who wanted to pay us to install OS X on his netbook. (Creating a "hackintosh".)  I neglected to mention that Brian's reality differs from mine in many respects. In some other universe, Brian has a client who wants us to install OS X on a HP netbook and is willing to pay. In this universe... nah.

    I still like the guy, but I'm a little pissed at myself for taking him seriously, even for a moment. It's just that I'm broke and unemployed right now, so a few extra bucks would be nice.

    I've been preparing my desktop system for an OS reinstall. I have Ubuntu 10.04 "Lucid Lynx" running in Virtual box, and it's running well. It's running  well despite the rich goof's current master plan to change the default color scheme from disgusting orange brown to putrid eggplant purple and move the window control buttons from the right side of the screen to the left side of the screen.  This is button move is major stuff. They are sitting around right now finding new and innovative uses for the newly freed real estate on the right hand side. I don't know about you, but I just can't wait. Seriously. I'm sure that I will eventually get over the bad habit of trying to click on the right hand side top of every fricking window eventually.

    If I was a wealthy guy with my own software company people would take me seriously, too. Money buys a lot of respect. Especially paycheck money. "Move those darn buttons! This is big!" I think that Mark Shuttleworth wants to be like Steve Jobs. I'm thinking that one Steve jobs is enough, but since he tends to keep his snout out of Linux I can live with him. The problem is, Ubuntu is Mark Shuttleworth. We're stuck with him. He is a self appointed benevolent dictator for life, and he's paying good money for the right.

    Well, if Lucid is too annoying, I can revert back to Debian. Or even jump to another distro. It ain't that big a deal. There's not much special sauce in Ubuntu.

    Wednesday, April 21, 2010

    My Life as a Rōnin

    Toshiro Mifune as an old school rōnin
    "A rōnin (浪人?) [1] was a samurai with no lord or master during the feudal period (1185–1868) of Japan. A samurai became masterless from the death or fall of his master, or after the loss of his master's favor or privilege."
    Source: wikipedia

    So Theresa, who is someone that I saw once, but never really met, has a problem. She has a pierced tongue, which freaks me out, but that's my problem. She's the girlfriend of Phil, who is someone that I have met but I don't see a lot. Phil and I hang around  sometimes while holdings things like beer and fishing rods. He has a really cool dog named Austin, who seems problem free. Theresa's problem is an HP netbook running Windows XP. The problem is the computer just ain't right. It's a really cute little machine -- much nicer that my eeePC 900. It has a nice big keyboard and a slightly larger screen. I want one, but, as they say,  it's not in the budget. She gave the netbook to Brian to fix and he worked on it a bit. He cleaned up some, but not all, of the ugly mess. He managed to blow out the passwords that her ex-boyfriend had helpfully added to the machine, and got rid of a few hundred items that a virus scanner flagged as malware.  The system was still borken: it would not connect to the Internet and it was doing really strange things, and it was doing them very slowly. Brian asked me for help. It seems that since none of us is working, the budget for this job is zero. Fool that I am, I agree to take a look at it. It feels like work, which I like, but pays nil, which I don't like. Aw, snap! I have to quit giving it away.

    It's so beautiful! I want to put Crunchbang Linux on it!

    Mind you, I am not really an IT person. I'm an electronics technician who went to night school to get a degree in electrical engineering. I was a UNIX system administrator for an engineering group, a CAD librarian, a printed circuit board designer, a sort of general-purpose electronics technician. I used to wire TV sets with about a hundred thermocouples so we could see how hot the components would get. (Pretty hot, sometimes.) I run Linux for my desktop, I use Vi and Emacs, GIMP and moc. I can write crap-ass software in C, C++ and Python. In short, I am just another jack-of-all-trades, master of none, who is currently unemployed. Life stinks, sometimes. These skills gives me some ability to beat computers into submission. I try to pick up a few bucks sorting out computer problems for people. These are usually not difficult problems involving hardware repair. These are usually simple things related to system configuration and using software, things that someone could and should handle themselves. Finding a solution usually involves asking Google, thinking logically and maybe learning a thing or two.

    I get few takers for my services. People do not want to pay. I hear complaints about the lack of service technicians, closely followed by complaints about what service technicians charge. Service technicians tend to want a living wage. Clients seem to like "free", closely followed by "really cheap". At times it's hard to find a middle ground, so I get few jobs, while they keep doing whatever they do.

    My pal Brian once charged a guy $50 to sort out a computer. The guy paid him $12, because it only took an hour. I guess computer techs are only worth $12/hour, with no benefits or secure employment. Brian took the $12, and then formatted the guy's hard drive for him, giving him a minty fresh computer. Brian is a natural born BOFH. The client was not happy. Brian kept the $12. Life stinks, sometimes.

    Be afraid.

    My aunt's brother is having phone problems. He will not call AT&T to come out and check things out. He says that they charge $80/hour, and he doesn't want to pay that. He thinks that a huge bill will be run up, and that they are out to screw him. AT&T will check the phone line up to the house for free, but he will not even ask for that. He would rather complain about things. Kvetching sure is more fun. He did go out and spend $80 for a new DSL modem, as if that would fix his problem. It didn't. I took a look at things. He has two phone lines, and one is borken. That's as far as I went. I was not about to chase the line through the house from the second floor, especially since he refused to call AT&T to have the phone line checked to the house. I was not going to call AT&T for for him; he should know how do do that. As far as I know, it's still borken. Life stinks, sometimes.

    So I fixed Teresa's netbook for free. Why not? A loss leader, and maybe I now have another fine friend that I will hear from only when they need me. It took 3.5 hours, mostly because that's how long it takes. He's what I did:
    • Wifi was not working, but Brian's Cricket modem worked, so I did not have to fix the wifi now or take the little beast home to my router to get Internet access. You can't do jack without an Internet connection.
    • I updated Malwarebytes, which Brian had installed. I like this program; it has done good things for me in the past.
    • I ran yet another full virus scan in "limited driver mode" using Malwarebytes, which removed yet more malware. 
    • I ran Microsoft update. They were 9 updates. 7 or 8 of them were security updates. Why didn't she run Windows update regularly?
    • I then tried to turn Microsoft Security Essentials back on. (Brian had turned it off.) It would not turn on. (Insert joke here.)  OK. Microsoft's anti-virus program did not work on Microsoft's operating system. It also would not reinstall, and gave an error message with the long hex error code 0x8004ff07. (It should have said guru meditation 0x-long-hex-number, but it didn't. Amigas were so much cooler, even when they screwed up. I miss my Amiga.) Following the hex error number to a Microsoft forum, some guy gave this fix:

      1.       Uninstalling MSE
      2.       Reboot.
      3.       Reinstall MSE.
      4.       Cancel the update and scan.
      5.       Reboot.
      6.       Launch MSE and trigger upgrade via Help, Upgrade.
      7.       Download and install completed successfully.

      Someone from Microsoft urged the parties involved to file bug reports with Microsoft. He gave helpful web links. At times it's hard to find a middle ground.  I want Microsoft to run more tests on their code before they release it to the wild. They want me to write bug reports. Neither of these things are going to happen. 
    • I started on the Microsoft Security Esentials fix. After the first step (remove MSE), I made a command decision: I was not going to reinstall it. MSE blows. Microsoft blows. MSE gets good reviews for malware detection, but I have been having problems with it doing simple tasks, things like updating virus definitions and turning on. So I uninstalled it and replaced it with the free version of AVG. The AVG install told me that I should remove MSE. Since I had already removed MSE, I installed AVG anyway. (Déjà vu: I have seen this before.) AVG works OK, despite the bogus warning.
    • I update AVG. I run a configuration scan. I run yet another virus scan using AVG. It finds nothing bad.
    • I turn the Windows firewall back on. (Brian had turned it off.) (Insert yet another turn-on joke here.)
    • If fixed the wifi. Someone or something mucked around with the tcp/ip settings. Once they were set correctly, wifi worked.
    Maybe I should have turned on system restore, but I stuck a fork in it because I was done and Starbucks wanted to close. 
       After, 3.5 hours the netbook was now working fine. While it did not demand my complete attention the whole time, I had to be there to shepherd the process. For zero dollars. Brian has another job, which is supposed to pay actual US dollars. Some doofus wants us to install OS X on his HP netbook, and is willing to pay us something for it. Since Apple really doesn't want you to do this, it's kind of tricky. This should be fun.

      Saturday, March 20, 2010

      Cooking With Dog

      I am not an entrée!

      I found another cooking show on You Tube that I really enjoy. It's called Cooking With Dog. Yep, only on You Tube can you find such quality cooking shows. Fortunately, the dog is a narrator, not an ingredient. Maybe the title isn't so ambiguous in Japanese. The dog should get his own TV show, because he's talented. He seems to speak English, albeit with a Japanese accent. He narrates the whole show. He's pretty awsome for an such sissy looking dog. I wonder if he speaks Japanese, too. The lady's usually cooking something tasty. She's pretty skilled in the kitchen. She's also a bit of a fuss budget, but the results look really great.  I bet they taste great, too. I'm not so sure I can cook like her, but I'm going to try.



      The only bad thing is now I want to eat tonkatsu, even though I just finished eating lunch. Maybe later. I need to go to the store and get a few things.

      Monday, March 15, 2010

      CA Updates

      Although I haven't been blogging, work on the cellular automaton program has continued.  It now has an on screen display of some interesting parameters. I also have been learning how to use FLTK 1.1 (Fast Light Tool Kit, pronounced "full tick", although I keep wanting to say "foot lick".) Somehow I have figured out how to write a GUI control program to control the whole ca shebang. I was going to call it lcp, "Life Control Program", but the name seems to imply mind control cult membership and it also seems to be already used in Ubuntu Linux.
      mikey@hatshepsut:~/workspace/ca$ lcp
      The program 'lcp' is currently not installed.  You can install it and be assimilated by typing:
      sudo apt-get install lsh-client
      lcp: command not found
      mikey@hatshepsut:~/workspace/ca$
      So I decided on cacp, "Cellular Automata Control Program".  Now available on Launchpad. Thanks to Greg Ercolano's FLTK cheat sheet and videos, which were very helpful.


      I want to create a war game similar to the old Avalon Hill war games of my youth, something like Afrika Korps or possibly like SSI's Allied General. I'm not sure how to do this, so I'm going to have to put my thinking cap on for a while. While I'm figuring that out, I'll be working on the cellular automatons. I have a few more ideas for improvements.




      Last night's International Mystery was Tatorte ("Crime Scene"), which is one of my faves. The bier drinking, currywurst eating detectives Max Ballauf and Freddy Schenk were on the job again, chasing yet another killer. I like these guys -- they once even arrested an elderly SS murderer for crimes committed back in the 1930's. They sure are natural born po-lice, as they used to say on The Wire. Alas, L'ispettore  Coliandro will return next week. He's definitely la natural born doofus who somehow manages to make time with a hot chick, solve a little crime and order mass quantities of yoghurt. C'est la vie.

      Saturday, February 27, 2010

      CA project status

      The cellular automata project continues.  It is currently working in a bare-bones, command line manner. You can load start files in plaintext (.cells) format, start in single step mode, toggle on/off single step mode while the program is running and select fixed plane or toroid modes on startup. It's now actually usable.

      The toroidal surface took longer than expected, which seems to be the norm for me. (I had changed the code for countNeighbors() in the C++ version and  I had some incorrect code to handle cells on the edges. It took me a while to sort it out.) The code is up on launchpad.

      Features to work on:
      • Save a snapshot of the current state to a plaintext (.cells) file.
      • Input rulesets from the command line.
      • Set the global constants from a configuration file.

      Wednesday, February 24, 2010

      The Third Time's the Charm

       L'ispettore Coliandro on Wikipedia

      I caught the rebroadcast of Inspector Coliandro on MHz Worldview's International Mystery last night. This time the broadcast engineers rediscovered how to vertically center the video on the screen. This is a good thing, because that's where the English subtitles are located. The subtitles make it much easier for me to follow the story, because I sure don't understand much Italian.

      Even with subtitles, Inspector Coliandro is still a doofus who needs to stand closer to a razor. Much closer. Despite his scruffy appearance, he somehow got transferred back to the flying squad, even after ordering a multi-lifetime supply of yoghurt cups for the police. (Sadly, the flying squad has no airplanes. They just cruise around in unmarked police cars, just like the Chicago PD.) He did solve some crime: he rescued his partner from a frame-up, got the goods on a bent copper and put the whammy on a purse snatcher. Even better, he made kissy face with a hot chick from a family of petty criminals. (They were sort of like an Italian version of the Timson clan from Rumpole of the Bailey.) Still, I'm not sure if Coliandro is a keeper, even if he does get lucky with a different hottie in each episode. (I do bet ya that he never even gets near to first base with the smoking hot prosecutor, Dottoressa Longhi.)

      I guess time will tell. They seem to have more episodes of Inspector Coliandro in the pipeline, and they're going to run them no matter what I think.

      Tuesday, February 23, 2010

      Hey, it works!


      Earlier, I determined that I would need to implement just a few more functions in C++ to get a bare-bones version of my cellular automaton (CA) program working. Here's a list of the necessary functions:
      • countNeighbors
      • cellNextgen
      • updateCAMatrix
      • a 2D vector to hold the ruleset information
       I wrote out the functions using pencil and paper. True to my past performance, none of them ran as written on paper. One of these days, I'll get it right from the get-go. Whatever. At least I was correct in that these were the functions required get the job done. At the end of a small hack-a-thon, I was left with a working, bare-bones version of Conway's Game of life. I decided not to fill the blog up with too much source code. If you're interested, the source code is available here on launchpad. I'll only add code snippets as necessary, or when I just feel like it.

      Next on the agenda is implementing:
      • Toroidal surface version.
      • Single step mode.
      • Start pattern file input.
      The nice thing about C++ is that it is faster than Python. In this case, the C++ version of the CA program is much, much faster than the Python version. It's so much faster that I want to take another look at my Python code to see if there's something amiss. I think C++  is my new language of choice for sound and graphics.

      The downside is that C++ is more painful for me to code in. Part of it is my ignorance, and part of it is just the nature of C++. I studied things like "pass by reference", "pass by value" and "dynamic memory allocation" in school, and I quickly left them behind because I was an electrical engineering student, studying other topics. Now that I've started writing more code, and I'm beginning to use C++, I have to start paying attention to these things.

      Python is free and easy language. Python has automatic memory management (garbage collection), while in C++ the programmer must take out the trash. C++ has static typing; Python has dynamic typing. C++ is compiled; Python is interpreted. These differences make Python much easier to use, which means it is much faster to write code in. C++ is more painful to code in, but it sure runs fast. The C++ CA program runs so fast compared to Python version that I think it's worth the trouble of climbing the C++ learning curve. And what a steep curve it is! This is going to take a while.

      One problem that I notice when asking Google how to do things with C++ is the widespread use of C idioms and libraries to solve problems in C++. While C++ was developed from C, and can run almost everything just like C, it also has a number of distinctly C++ ways of handling tasks. It seems that so many C coders segued into C++ they carried many of their C solutions into C++ code. For example, I wanted to convert some text into an integer. Google shows that many people would use a C method:
      ...
      #include <stdlib.h>
      ...
      ...
      int myint;
      char *mystring;
      ...
      myint = atoi(mystring)
      ...
      which works just fine in C++. It's just that C++ has another way, a native C++ way to do the same thing.
              ...
              #include <string>
              #include <sstream>

              using namespace std;
              ...
              ...
              int myint;
              string mystring;
              stringtream ss;
              stringstream ss;
              ...
              ...
              ss << mystring;
              ss >> myint;

      I don't have a big problem with using C idioms in C++; it's just that while studying Python I found it best to write Python code in Python, not translated Scheme or C. I suspect that this will hold true in C++ as well.  While it's true for this example the C code is nice and concise, the C++ version is pretty flexible and can do some interesting things. For example, it could parse a long string of whitespace separated items, and deposit each item into a separate variable. The variables could have varying types, if desired. The infrastructure is already there. I'm just learning this C++ stuff, but it seems to me that you might not always want to immediately just grab a tool from C to tackle a problem in C++.

      Another problem is C++ has changed over the years. If in searching for C++ wisdom you see something like #include in sample code, go somewhere else. That does not work anymore, and hasn't for a while.

      I've been working through Lazy Foo's Beginning Game Programming tutorials. These tutorials are using Simple Directmedia Layer  so they are of great interest to me. I highly recommend them. I got a copy of Programming Linux Games:  Building Multimedia Applications with SDL, OpenAL(tm), and Other APIs by Loki Software, Inc. with John R. Hall. These days I don't buy too many computer books because they are expensive, often quickly obsolete and just do not give you a lot of bang for your buck. I mean, Google is pretty good at answering questions about computing, and my local library has beau coup books on the subject, as well as a subscription to Safari Books Online. I made an exception for this book, because it's from the people who developed SDL, and the excerpts looked pretty good. Now that I have it in my hands, I glad I spent the money. It's a little old (I think some things have changed with SDL since the book was written), but it's still pretty solid.

      Sadly, the author, John R. Hall, is now blessed memory. He died way too young. My condolences to his family and friends.

      Monday, February 22, 2010

      Regular TV

      I'm a terrible couch potato. It's a not-so-secret sin, a guilty pleasure. These days, I watch most of my video entertainment on my computer, rather than on my television. Given a fast enough connection to the Internet, you can get free video on demand. I just love it. I think when I get working again I am going to build a MythTV box and go nuts.

      I don't have cable or satellite. (They cost money, which is currently in short supply.) I just have plain old Chicago-area broadcast TV, which is free.  I don't watch a lot of regular TV these days, except for Sundays. Sundays I can get my fix of foreign detective shows on MHz Worldview's International Mystery. What a great show! It's not available online. WYCC Chicago carries it on channel 20.3. I get to watch Henning Mankell's Kurt Wallander in subtitled Swedish, George Simenon's Inspector Maigret in subtitled French, Andrea Camilleri's Salvo Montalbano in subtitled Italian... you get the picture. Every week, you get detectives in a foreign land chasing the bad guys. I just love it.

      How cool is this: French police get to drink on the job. I love when Inspector Maigret (played by Bruno Cremer) orders une bière or cognac while working. This is normal for him, as normal as eating cassoulet. In the USA, cops aren't supposed to drink on the job.

      My absolute fave is Tatort ("Crime Scene"), which is in German. The episodes currently being shown are with the detectives Max Ballauf and Freddy Schenk, who are in the kripo ("kriminal polizei") in Cologne, Germany. They chase murderers. As the characters in The Wire used to say, they are natural born po-lice. They even arrest an elderly fugitive nazi murderer in one show, which gives them bonus points in my book. I am jealous of them because they have easy access to currywurst and unpasteurized beer, even while on the job.

      I don't like all of the shows. There's a show with some Italians running around in it (OK, it's titled La Omicidi) where the only cool thing is the bad guy, who wrote Dante's La Divina Commedia on the walls of his cell in prison, and is smarter than everyone else in the whole world. Then there's the current guy, Inspector Coliandro, who seems to be a doofus who bulk orders more yoghurt than even the guy on Burn Notice could eat. I'm not the only one who is less than thrilled with Inspector Coliandro. MHz Worldview sent me this in a email:


      Inspector Coliandro: Second Time's the Charm?
      Many of our viewers had mixed feelings about the premiere of Inspector Coliandro last month. The tone of this series is different than some of our other offerings, but give it another chance. You may like the second episode better. Inspector Coliandro: Into A Trap, Sunday, February 21 and Tuesday, February 23 at 9PM ET/PT

      OK, let's give the show another chance. So, it's Sunday, time for the show. I sit and watch some of the news from Germany, which is on before International Mystery. The video is just fine. The opening for International Mystery comes on. The video is just fine. Inspector Coliandro comes on. The video is now "borken". Whiskey Tango Foxtrot. The video is shifted down from the top of the screen, which cuts of the bottom of the video frame, while leaving an empty black bar at the top. The subtitles are conveniently invisible because they are in the cut off portion of the frame. Aw, snap! Can't these idiots center the video on the screen?

      To be fair, if I could find the remote for my wonderful set top converter box I may have been able to fix the problem. Maybe. The first episode, which sucked by the way, had flawless video. The second required knowledge of Italian. Maybe the third time's a charm. We'll see.

      Sunday, February 21, 2010

      The New Crossword Puzzle Workaround

      I may have previously mentioned my need to print a daily crossword Puzzle for Lizzy. One day, literally overnight, the crossword puzzle from the Chicago Tribune  would not print from my computer. To be more precise, it would not print from my  fully up to date 64 bit Ubuntu 9.10 "karmic koala" machine to my Samsung SCX-4200 printer. Neither would any of the other Flash crossword puzzles. Aw, snap!

      Did I change anything? Yep, I do so all the time. I have software updates running all the time. It might be any of the bleeding edge crap that that's installed on my machine. Many computers in the desktop Linux world have a delicate software ecology, and mine is no exception. It could also be any of the stupid things that I do to my computer. It also could be any of the stupid things the folks at Ubuntu and Canonical do to my computer. It could be someone else, somewhere else. I break software all the time. I'm real good at that. I break things, then I fix them. I don't think that I broke Flash crossword puzzle printing -- it could have something to do with the software update installs that are going on all the time -- but I'm not sure. It could be that Flash update that slid in the other day, so don't be quick to blame me and my promiscuous use of synaptic and configure; make; make install to /usr/local.

      Chasing for an answer, I researched Samsung, Cups, Linux, Adobe Flash and the Dark Magical Arts. I tried different web browsers. Opera. Chrome. Kazehakase, even. I reinstalled the printer drivers, following tweedledee's excellent and exhaustive instructions on the Ubuntu Forums. (I know, tweedletee? You're taking advice from someone called tweedledee? Hush up! Tweedledee know what (s)he is talking about.) I waved a dead chicken over the computer, the printer and my unemployed son. No joy.  As far as I can determine, I can print from anything except an Adobe Flash crossword puzzle program.

      It will not print to the printer,
      It will not print to a PDFer.
      It will not print on a box,
      It will not print from Firefox.
      It will not print here or there
      It will not print anywhere.
      I like green eggs and SPAM,
      but I do not like Flash, Sam I Am. 

      I think the printer and the print system is OK, but there is some problem related to Flash. My last problem related to Flash was also related to the crossword puzzle. That one one was really annoying -- Flash would not respond to mouse clicks. Great fun. I couldn't do anything with it, it just sat there and ignored me, like just like my friends and family. The problem was neither Flash, nor the Firefox web browser.  The problem was the Compiz window manager used by the default Ubuntu Gnome desktop.  Change the window manager to Metacity, and the crossword puzzle works. (Remember, a delicate software ecology can be part of running of a free and open source operating system. There are a lot of cooks stirring the pot.)

      Someone else on the web figured this out. I didn't know Compiz from Metacity before this. I'm running Metacity right now. Compiz is still "borken".

      Well, everything worked until now. Now printing is "borken" for the Flash crossword puzzle, and I can't find a fix. The work around was to boot Windows Vista, and print the crossword puzzle. (Go figure. It works great there.) This is unacceptable not only because it is surrendering to the dark side of the force, but because it also takes half of forever. It wouldn't be so bad to be evil if it were only a bit faster. I spent a day tweaking this broken-down Edsel of an operating system, and it's still is way too slow. It's like a Crown Vic with a four cylinder engine. For an evil company, full of really smart people, bent on world software domination, this is a sorry excuse for an operating system. I'm tired of booting this slowpoke every stinking day for the woman I love.

      So the new work around is to change crossword puzzles. I needed to find one that I can print out for Lizzy. So good-bye, Chicago Tribune crossword puzzle. Good-bye to flash crossword puzzles. Yes, even though both of Lizzy's parents worked for the Trib, it's time to move on.  It' been fun. Hello, Washington Post crossword puzzle, which uses Java instead of Flash. It also can generate a .gif file, which I can print out.

      Problem almost solved. I'm calling it a day.

      Saturday, February 20, 2010

      Pseudo-Life

      Nothing much to report here. I worked a bit on the cellular automata program; now it generates screen after screen of random patterns. This is not the final goal, but it is a step in the right direction. A game of pseudo-life, instead of Conway's life. When I first compiled and ran this bit of code, I saw something strange. In just a few moments the screen would fill up with green blocks. It took me a little while to figure out what the problem was. D'oh! I neglected to clear the cells vector, which would keep on magically growing. This gives you a minty green screen o' blocks.

      I kept pouring over the SDL sections of the code. There was no problem with SDL code, just the plain vanilla C++ code. Happy cells.clear(); to all.

      I went through the Python version of this program and figured out what functions would have to be ported to get a bare bones working version of the program. It looks like just a few:
      • countNeighbors
      • cellNextgen
      • updateCAMatrix
      • a 2D vector to hold the ruleset information.
      No I haven't posted them yet -- they're still vaporware. They will all be showing up as I go along. I actually coded them using pencil and paper, but to date I have a poor track record of writing down working code with pencil and paper. I will code and debug them, then post.

      One thing I learned after writing the paper and pencil code is that using c++ vector <bool> is probably not a good idea. Too bad, it looks so good on paper.

      #include <iostream>
      #include <vector>
      #include <cstdlib>
      #include "SDL/SDL.h"

      using namespace std;

      // Globals
      const int XRES = 1024;
      const int YRES = 768;
      const int BLOCKSIZE = 4;
      const int DELTA_T = 250;
      const int FCOLOR = 0x0000FF00;
      const int BCOLOR = 0x00000000;
      const int ROWS = YRES / BLOCKSIZE;
      const int COLS = XRES / BLOCKSIZE;

      int randomStart(vector & cells, vector > & world) {
              srand(time(NULL));

              SDL_Rect p;
              int pct;

              for (int row = 0; row < ROWS; ++row)
              {
                  for (int col = 0; col < COLS; ++col)
                  {
                      pct  = rand() % 1000;
                      if (pct < 200)
                      {
                          p.x = col * BLOCKSIZE;
                          p.y = row * BLOCKSIZE;
                          p.w = BLOCKSIZE;
                          p.h = BLOCKSIZE;
                          cells.push_back(p);
                          world[row][col] = 1;
                      }
                      else
                          world[row][col] = 0;
                  }
              }
          return 0;
      }

      int main() {
          vector cells;
          vector< vector > world(ROWS, vector(COLS,0));

          // initialize SDL
          SDL_Init(SDL_INIT_VIDEO);

          // populate the world
          //randomStart(cells, world);   // pass by reference

          // set the title bar
          SDL_WM_SetCaption("Cellular Automata", "Cellular Automata");

          // create window
          SDL_Surface* screen = SDL_SetVideoMode(XRES, YRES, 0, SDL_DOUBLEBUF);

          // Create background and block
          SDL_Surface* bg = SDL_CreateRGBSurface(SDL_SWSURFACE,XRES, YRES, 32, 0, 0, 0, 0);
          SDL_FillRect(bg, NULL, BCOLOR);

          // Display the bank screen
          SDL_BlitSurface(bg, NULL, screen, NULL);
          SDL_Flip(screen);

          // creak the block image for a live cell
          SDL_Surface* block = SDL_CreateRGBSurface(SDL_SWSURFACE, BLOCKSIZE - 2, BLOCKSIZE - 2, 32, 0, 0, 0, 0);
          SDL_FillRect(block, NULL, FCOLOR);

          SDL_Event event;
          bool gameover = false;

          // message pump
          while (!gameover)
          {
              // look for an event
              if (SDL_PollEvent(&event)) {
                  // an event was found
                  switch (event.type) {
                      // close button clicked
                      case SDL_QUIT:
                          gameover = true;
                          break;

                      // handle the keyboard
                      case SDL_KEYDOWN:
                          switch (event.key.keysym.sym) {
                              case SDLK_ESCAPE:
                              case SDLK_q:
                                  gameover = true;
                                  break;
                          }
                          break;

                  }
              }

              randomStart(cells, world);

              // draw the background
              SDL_BlitSurface(bg, NULL, screen, NULL);

              // blit the blocks
              for (unsigned int i = 0; i < cells.size(); ++i)
                  SDL_BlitSurface(block, NULL, screen, &cells[i]);

              // empty the vector of cells
              cells.clear();

              // update screen
              SDL_Flip(screen);

          }

          // free the background surface
          SDL_FreeSurface(bg);

          // cleanup SDL
          SDL_Quit();

          return 0;
      }

      Friday, February 19, 2010

      Addicted to Binary Blobs

       The Mono folks, lead by Miguel de Icaza, released a Moonlight 3.0 Preview that actually plays Microsoft Silverlight 3 videos on my 64-bit Ubuntu Linux box. I was able to go to the NBC Olympics website ("Powered by Microsoft Silverlight") and actually watch videos on Linux. Before this did not work at all, and yes, I had Moonlight installed. It just didn't work on these videos. With the 3.0 preview installed, it just worked. (Well, it just worked after I followed the prompting to accept a license agreement and download some codecs, but that's the norm for non-free software.) When I played a video, first I am warned that I am using an unsupported operating system, and then the video plays. It plays pretty good in the small window embedded in the web page, but it seems to have problems with full screen. (That could be a problem with my network connection.) Well done, folks! Kudos!

      Of course, if I go to the site for Microsoft Security Essentials and try to play the installation video, all I get is audio. Not that I could (or would) install that software on Linux, but still, the Silverlight installation video still should play. It works on Windows.

      Wow. I have just now lost all my open source credibility. Umm, play ogg?


      I'm a sucker for sound and video. Seriously. I listen to more music, radio and TV on my computer than I do using any other device. I probably should not be wasting so much time, but I do need to get my fix. I watch my video and listen to my music on Linux, not on Microsoft Windows or Mac OS X. It all works pretty well most of the time, but I can't do it without using non-free "binary blobs" of software. This is the norm for Windows and Mac OS X, but Linux is generally free and open source. Generally. The dirty secret of Linux is that almost everyone who plays sound and video usually does so with proprietary, non-open source software, such as MP3 or Flash. This stuff may be free as in free beer, but it is not free as in free speech. There are open source alternatives, but it can be hard to find radio stations and video sources using them. It's not pretty, but that's the way it is. You can read all about Free and Open Source Software issues at the Free Software Foundation. Play ogg, if you can. If you can't, you must make you own choices. I put the binary blobs in. You might choose to leave them out.

      According to my beautiful and talented sweetie, Miss Lizzy, the most important thing my computer does it print out the day's crossword puzzle for her.  She's not very upfront about this, but that's that the way it is. She will hover around me in the morning, waiting for me to print out the crossword puzzle. (This is a good thing, because I like sugar.) This crossword puzzle in question is an Adobe Flashplayer application that runs in a web browser, usually Firefox for me. All was well until one fine day, the puzzle would not print out. Aw, snap! Dang old software upgrades.

      The printer is still working fine, and I can print from any application I want, except from the Flashplayer crossword puzzle. Even the frickin' built in scanner still works. No fun here, and sugar may soon be rationed. There is a work around, but it's fugly. The work around is to tell grub to boot Windows Vista, where Firefox and Flash can print out a crossword puzzle for Lizzy. Yuck! Windows one huge non-free binary blob, and now I need it. This is killing me. Help me! Help me! Next, I'll be on TV with Bill Gates, saying "I'm a pc!" and "Bing!".

      The things I do for love.
       

      Thursday, February 18, 2010

      Adding SDL


      Now that I have the basic data structure representing the cellular automata "world", it's time to start hacking in the graphics code. I'm using Simple DirectMedia Layer (SDL) to make the magic here. Why SDL? Well, I started doing this stuff in Python, where I used pygame to make the magic, and SDL is the magic behind pygame.

      SDL was the library that Loki Games used to port commercial games from Windows to Linux. I even purchased one. Sadly, Loki is gone, but SDL is still here and is even still under development. Ignorant as I am, it seems as good a choice as any.

      The magic so far

      The display portions of the code were copied from a demo that I found somewhere on the net. Sorry, I don't remember where.  Ask Google -- the code is out there. Most of the comments are from that source. Originally the program displayed a bitmap; I hacked it to my bidding. I won't say much more about the code, although I could go on until the cows come home.

      One tweak that come to mind is to change the world vector's data type, which is currently a C++ int, which is 4 bytes on my machine. I really don't need 4294967296 different values to hold 2 states, 0 or 1. A bool would do nicely, or maybe a shorter king of unsigned integer type, if I decide to encode more information about the cell. It's on the TODO list.


      #include <iostream>
      #include
      <vector>

      #include
      <cstdlib>
      #include "SDL/SDL.h"


      using namespace std;

      const int XRES = 1024;
      const int YRES = 768;
      const int BLOCKSIZE = 8;
      const int DELTA_T = 250;
      const int FCOLOR = 0x00FF00;
      const int BCOLOR = 0x000000;
      const int ROWS = YRES / BLOCKSIZE;
      const int COLS = XRES / BLOCKSIZE;

      int randomStart(vector<SDL_Rect> & cells, vector<vector <int> > & world) {
              srand(time(NULL));

              SDL_Rect p;
              int pct;

              for (int row = 0; row < ROWS; ++row)
              {
                  for (int col = 0; col < COLS; ++col)
                  {
                      pct  = rand() % 1000;
                      if (pct < 375)
                      {
                          p.x = col * BLOCKSIZE;
                          p.y = row * BLOCKSIZE;
                          p.w = BLOCKSIZE;
                          p.h = BLOCKSIZE;
                          cells.push_back(p);
                          world[row][col] = 1;
                      }
                      else
                          world[row][col] = 0;
                  }
              }
          return 0;
      }

      int main() {
          vector<SDL_Rect> cells;
          vector< vector<int> > world(ROWS, vector<int>(COLS,0));

          // initialize SDL
          SDL_Init(SDL_INIT_VIDEO);

          // populate the world
          randomStart(cells, world);   // pass by reference

          // set the title bar
          SDL_WM_SetCaption("Cellular Automata", "Cellular Automata");

          // create window
          SDL_Surface* screen = SDL_SetVideoMode(XRES, YRES, 0, SDL_DOUBLEBUF);

          // Create background and block
          SDL_Surface* bg = SDL_CreateRGBSurface(SDL_SWSURFACE,XRES, YRES, 32, 0, 0, 0, 0);
          SDL_Surface* block = SDL_CreateRGBSurface(SDL_SWSURFACE, BLOCKSIZE - 2, BLOCKSIZE - 2, 32, 0, 0, 0, 0);
          SDL_FillRect(block, NULL, FCOLOR);

          // blit a block
          for (unsigned int i = 0; i < cells.size(); ++i)
              SDL_BlitSurface(block, NULL, bg, &cells[i]);

          SDL_Event event;
          bool gameover = false;

          // message pump
          while (!gameover)
          {
              // look for an event
              if (SDL_PollEvent(&event)) {
                  // an event was found
                  switch (event.type) {
                      // close button clicked
                      case SDL_QUIT:
                          gameover = true;
                          break;
                      // handle the keyboard
                      case SDL_KEYDOWN:
                          switch (event.key.keysym.sym) {
                              case SDLK_ESCAPE:
                              case SDLK_q:
                                  gameover = true;
                                  break;
                          }
                          break;
                  }
              }
              // draw the background
              SDL_BlitSurface(bg, NULL, screen, NULL);

              // update the screen
              SDL_UpdateRect(screen, 0, 0, 0, 0);
          }
          // free the background surface
          SDL_FreeSurface(bg);

          // cleanup SDL
          SDL_Quit();

          return 0;
      }