Archive for the Development Category

Randomized Dungeons

Posted in Development, Software, Video Games on April 19, 2017 by osake

I wrote a little dungeon maze generator using randomize Prim’s algorithm in Ruby.  The snippet below is the algorithm itself and works off of any sort of walls/rooms combo as long as it’s valid.  This should also work in hex or even a 3D maze since floors and ceilings are effectively a wall pair.

Screen Shot 2017-04-19 at 6.11.26 PM

I’m looking to port this over to my new game, but wanted to prototype it in Ruby.  I think I should add some variety by dropping rooms at random on a given size.  This piece will work, but my room and wall generators will need some tuning.

Advertisements

Eternal Card Game Simulator

Posted in Development, Video Games on February 8, 2017 by osake

It’s been a long time since I posted here. Blogs are dead, right?

Anyway…

I’ve been playing Eternal (eternalcardgame.com) since closed beta. It’s a nice departure from my Hearthstone tenure (played since beta as well). One thing I really liked in Hearthstone was the deck tracker, and I knew that there was a lot of work in the Hearthstone community around simulators, etc.

Eternal seems to use HTTP traffic, at least in my first stab at deck tracking. After writing up a silly little manual deck tracking app in Javascript (eternal-deck-tracker.appspot.com) and messing with a card creation tool, I took on writing a simulator for Eternal Card Game. It’s just my own little project to mess around with Scala while recreating some behavior of the online card game I’m currently playing.

Currently, I’ve got a simple AI vs AI simulator and I’m working through the basics of solitaire mode where you can pit yourself vs AI. As a text sim, the command parsing is going to take some work, along with needing a clean-ish rendering of the board state.

I had thought of doing a few more complicated things with this simulator: creating a graphic UI with ScalaFX, exposing a RESTful JSON API with Scalatra, or maybe even rebuilding Direwolf Digital’s Unity UI. I could go on with ideas, but I think I want to stick to a simple, messy text UI for now.

The next phase I’m really interested in jumping into, once the solitaire is done, is looking at 4 player modes, so an FFA and two-headed giant. So that’s your teaser.

If you want to keep up with the simulator development, then check it out osake.github.io/EternalCardGameSimulator/ or even contribute.

Getting qt4-qtruby-2.0.3 running on Mac OS X (and Qt)

Posted in Development, Software on August 21, 2009 by osake

History

Please bear with me to share a little history of how I even got an interest in trying Ruby/Qt on the Mac.

In the past I’ve tried to learn GUI development.  The biggest roadblock (aside from the learning curve) was getting one installed with all its dependencies.  And maybe I’m asking for it when developing on a Mac.  They’ve always been company provided, so I’m not going to whine too much.

Some time ago, I co-presented on a GUI toolkit talk at my Ruby user group (KCRUG).  My compatriots chose Ruby Cocoa and Gtk, while I chose Shoes (I miss you _why).  I wasn’t just chosing Shoes to be eclectic, but I wanted ease of cross-platform.  Shoes to me also seemed easier to get up and running at the time.

So now, you should understand where I’m coming from.  I want cross-platform and I want something simple to setup.  Well, unfortunately, my portion of the presentation was a fail.  Not the presentation itself, but I was unable to get what I needed to talk to Wee War’s site and do anything.  Even with an excellent Wee War API wrapper in Ruby done up by Sean.

Shoes (still young at the time) wasn’t going to float for me any longer.  It did receive constant love from contributors to the source, but the struggle for me to achieve anything on par with the excellent sample apps ruined my glorious vision of triumph with a simple, elegant tool.  Someone recently gave me their thoughts on why Shoes failed me, and maybe its true.  I just couldn’t adapt my comprehension of programming to the Shoes DSL.

Gtk and Cocoa.  Well, let’s just dump Cocoa now, I had no interest in limiting myself.  So after that presentation (which mind you, was done in an Ubuntu VM), I tried to fire up the whole Ruby/Gtk thing native on the Mac.  After flailing for a few days, I caved in and abandoned my search for some time.

Present

Well, a little more history, but relevant to the post topic.  Something recently spurred my interest in Qt.  I’ll be the first to admit that I’ve always used Gnome, Windows, or Mac for my windowing system.  I do occasionally boot Knoppix, but I really don’t get too deep into Qt stuff.  Oh yeah, and I’ve used/currently use many things that have their claim to fame in Qt.

I tried hitting up TrollTech to get started.  No go, the link I found was dead with no redirect or anything.  A quick search clued me in to Nokia’s recent involvement.  This is fine by me, there is still an LGPL version and now it’s funded love.

Let’s review real quick, my requirements: must be cross-platform, I’d like to do it in Ruby if possible, and I have to be able to get it working natively on my Mac.

Recipe

As of this post, here is what I had to grab (oh yeah, you’ll need Xcode I’m pretty sure, comes with your Mac though)

  • Qt (4.5.2 from Nokia)
  • cmake (2.6.4 from cmake)
  • ruby (1.8.6, compiled version of Ruby)
  • qt4-qtruby-2.0.3 (2.0.3 from RubyForge)

I installed Ruby first since I do that professionally.  Qt was next, and I actually went with the full SDK in case I want to explore outside the realm of Ruby, or find limitations or interests that take me back to C++.   I then made the mistake of trying to just build qt4-qtruby.  You need cmake to build it, so get cmake up and running.  I actually used the binary dmg and linked it up in my shell path during installation.

Now, just so you don’t spend a lot of time asking why cmake in the source dir fails, let’s get you on the right foot off the bat.

$ cmake -Wno-dev \
-DRUBY_INCLUDE_PATH=/usr/lib/ruby/1.8/universal-darwin9.0 \
-DRUBY_LIBRARY=/usr/lib/libruby.1.dylib \
-DENABLE_QTWEBKIT_SMOKE=off \
-DENABLE_QTWEBKIT_RUBY=off

You may need to change your Ruby paths, but the other options will help get you through cmake and make.

I saw a more detailed build on phosphorescence‘s blog, but my cmake params should suffice.

After cmake is complete:

$ make && sudo make install

Feel free to break that up, but I just like getting it all done in one pass.

The next headache that plagued me over night and into the morning was that my build was successful, but I was unable to complete the ‘helloworld’ example.

require 'Qt4'

app = Qt::Application.new(ARGV)

hello = Qt::PushButton.new('Hello World!')
hello.resize(100, 30)
hello.show()

app.exec()

Line 1 was throwing a LoadError exception for ‘qtruby4’.  I am not terribly good at figuring this sort of thing out.  I mean, I know what it’s saying, but I don’t understand why.  To my knowledge everything was done correctly.  I spent several hours in IRC and searching forums last night.

I came across a German post which Google tried to help me with it’s translation, but I didn’t quite grasp what the fellow was saying.  At this point, I tried a few things before going to sleep and eventually gave in to the sand man.

The next day, I popped in IRC and low and behold, Richard Dale himself was there.  A short while after summarizing my issue, he blessed me with the answer.  For my installation:

$ cd /Library/Ruby/Site/1.8/universal-darwin9.0
$ ln -s qtruby4.so qtruby4.bundle

So really, just change to whatever directory contains your compiled qtruby4 library and create the symlink to qtruby4.bundle.  Go figure.  I’m tempted to spend a little time understanding what these .bundle files are, but that’s another story.

Rails Rumble 2008

Posted in Development on October 20, 2008 by osake

Oh boy, this weekend was a blast.  To top it all off, Sunday was my 33rd birthday.  I am going to break down my team’s participation in Rails Rumble 2008 right here before your very eyes.

Friday Evening

We had decided earlier in the week to go ahead and start from home on Friday and get a good night’s sleep before meeting up Saturday at one person’s house.  Our team was also short a member for the first part of the competition.

Initially, we sat with baited breath at 6pm Central (at least I did) and then realized that we are still observing DST which caused the start clock to be 7pm instead.  It worked in our favor though because we were short a guy initially and planned to meet the next day anyway.

Once the timer started, I worked on the server setup and other system tasks while my partner was cranking out the base application.  Pretty rudimentary for a start, but had to be done.  We also decided to try and be at the host’s house around 9:30-10am the next day and really punch out some work.

Saturday

I woke up late and on top of that my carpool was running behind and to keep the run-on sentence going, the host had just woke up by the time we got ready to head over to his house.  I thought, “Rock on, this is going to be an awesome day.”  Okay, I didn’t really think that…

We arrived and setup our laptops.  I was the only non-Mac user, and my laptop is so old and dysfunctional that I couldn’t connect to the wireless.  Fortunately, the boy scout in me thought to bring some ethernet in hopes of having a jack to plugging in to.

We had to sacrifice the XBOX 360’s network so that I could participate with internet access.  Oh, the drama!

We broke out a whiteboard and started talking through our idea a bit more than the scant pre-rumble meetings.  This was also important because our Friday night AWOLer, who was our designer, was in attedance.

With the game plan solidified, we were seated in front of many donuts and donut holes, plenty of soda options, and a 60″ plasma playing Bee Movie (in progress).

This is where I get tired of journaling the entire adventure, so to summarize, I consumed:

  • half a dozen donuts
  • half a dozen donut holes
  • easily 8 20oz sodas (Diet Mt.Dew, Diet Dr.Pepper, Cherry Coke Zero…and more!)
  • a double burger and cajun fries from 5 Guys Bruger and Fries
  • a dozen cookies (home cooked, not sure if home made)
  • 6 slices of pizza (Papa Johns)
  • scrambled eggs
  • 2 slices of toast
  • chips w/salsa and cheese dip

We also turned on about a half dozen movies to varying degrees of completeness and a few TV shows.

Before we got too far into the actual design of the logo and other style choices, we decided to name our application “Back In Black” to play off the accounting world where being in the red is bad and black is good.

Later in the evening, our designer had rolled out a our logo and good start on the styling of the application.  And somewhere along that time, someone queued up AC/DC’s song “Back In Black”.  As the design neared is initial phase of completion, the energy levels went through the roof.  A good design can be a great motivator.

During the wee hours, we began to lull a little bit and even took a few power naps.

Sunday

As the morning hours neared, we gather ourselves and defined a checklist of remaining goals that we wanted to see completed before turning in the final product.

We quickly hammered out the last few features and even had time to add one last feature over the following hours until deploy time.

I had already been doing deploys to ensure that worst case scenario, we had something on the server by the deadline.  There was a kink.  As I went to do the actual deploy, I had to restart Apache so that it would take the phusion changes and the new virtual host.  Uh oh, error!  What?  Why?

It turned out to be something simple in the realm of permissions.  Crisis averted, we were set.  Application turned in, ready to be tagged.  But wait!  Another problem.  Great, this is the way of software isn’t it?  An IE problem.  Fortunately, the team was quick to solve the bug, we pushed the changes, tagged the branch, bid our farewells and grabbed a container of cookies to take home.

The End

View our completed project at http://diedebtdie.r08.railsrumble.com

Damage Assessment:

  • consumed way too many calories (didn’t bother to weigh myself when I got home)
  • ear ache (might be a sinus infection) exacerbated by lack of sleep
  • I aged another year (though it’s been 365 days coming …had to calculate for leap year)
  • wet keyboard from wet dog beard (golden retriever style)
  • dog snot on pants and face (from the little guy, I forget which breed)
  • pizza sauce on my bright green shirt…very festive
  • delirium from lack of sleep

Huge thanks to Eldon for hosting and coding skills and Scotty for design and coding.  I was going to fly solo for the rumble this year, but it was easily 10x more fun with a team.  Thanks to Eldon’s wife for hooking us up with the food and drink and his pets for their entertainment.

Test First

Posted in Development, Zen on October 17, 2008 by osake

I got a great lesson in test first today.  I had fixed a bug earlier in the week, but I really didn’t get much gratification.  I also had to test it, realize another problem, fix again.  You should see a pattern forming here.

So I called up another team member and asked for some help figuring out how to get a spec (a.k.a a test) to cover this error in the event that there is a change in the future.  It was kindly brought to my attention at this point that I should have written the spec first anyway.  This is part of the whole methodology that we’re following anyway.

I reverted my code and wrote a few specs, passing each as I went along.  Sure enough, there was the gratification I was longing for.  Now the code is a bit more hardened.  I could have easily written the specs after the code fix, but there are two problems:

  1. The specs may not have enough coverage, it’s just too easy to be lazy in this direction
  2. You understand the solution to the bug better because you are describing how the application should behave

Here’s my light analogy: Your lightbulb burns out, finding a bug and fixing it is like just replacing the 60W bulb with the other one that came in the 2-pack you bought.  Writing a spec first, then fixing the bug is like putting in a 75W equivalent CF bulb to replace that incandescent.  Hoo ahh!  Yeah, it’ll cost more, but you’ll save money over the long term and burn a heck of lot brighter (at least mine do).

RailsConf 2008 Part 2 (Finally)

Posted in Development, Humor with tags on June 16, 2008 by osake

This is a total tangent off of my doings at RailsConf this year.  Before completely losing the topic, let me dump some closing thoughts out real quick.

It’s been several weeks since RailsConf 2008 ended.  As they say, fresh thoughts from short crams tend to fade fast from your memory if you don’t put them to use.  Well, I took notes, so that I wouldn’t have to worry about memorizing the sessions until I could implement what I learned.  I also apologize to anyone who expected me to email them right away after getting many business cards to expand my contacts in this world.

The last few sessions that I attended were pretty non-Rails, which is where I wanted to strengthen myself anyway.  I need more Ruby help and I got exactly that.  I also got to enjoy talking with people more this year.  That was my greatest achievement: Stepping out of my comfort zone and being social in real life.  It was great to not only put faces to the names that I have learned of online.

While at the conference, it’s harder to talk social life instead of shop, but once you get out of the bounds of the conference realm (like the expo area, or even more fun…the restaurant scene).  I only wish I had more time.  Meeting more people this year and having less than a week makes it more difficult to enjoy the interaction.  I was also on a more limited budget, so lunch out and about was not in my itinerary.

So yeah, social life and Ruby were the big moments for my time in Portland.  I think I’ll just re-iterate that Ezra’s talk on the cloud computing management tool (code named Vertebra?) was the cream of the crop.  I also enjoyed the time with Tom, James, and Scott (hobocentral.net), the KCRUG guys, who all seemed to enjoy the conference, and finding out that a buddy of mine from high school is in the Rails scene (at least to some degree).

Anyway, let’s stop this spiral of crazy thinking and move on to the funnier part.  Mind you “funny” is very, very subjective.

So, I was talking on an IRC channel earlier today and realized that I like to emote a “bonk” to the head.  Much akin to the the monks from Monty Python and the Holy Grail.

monk_bonk

In turn, that caused me to think, “Writing Rails apps is as easy as hitting yourself in the head with a wood plank.”  If you’re not following, just ask yourself, “Who can hit themselves with a wooden plank, given the plank is in their possession?”  Okay, good.  That was easy!  Just like Rails!  There is a deeper philosophical meaning and honestly, I’d love to dive into that topic some day.  The only downside is that my comparison isn’t a perfect 1:1 mapping, but it sure is close.

So there you have it.

rails_wood_plank

Bonk away.

RailsConf 2008 Part 1 (Quotes)

Posted in Development, Zen with tags on May 31, 2008 by osake

RailsConf this year has been a lot better for me than last year.  I’m actually talking to people…crazy, I know.  The talks have been hit-or-miss for me just like last year.  I think it still lacks the extra Lightning Rounds.  But enough of that.  Here’s some quotes that I really liked.  I’ll apologize now if they’re not exactly what was said, but I believe they still convey the points:

Developers can write documentation that is comprehensive, not comprehensible. —Jim Weirich

Programs that are hard to write should be hard to understand. —Jim Weirich

People like choices a lot better than actually having to choose. —DHH

While talking to Jim, we were discussing documentation and the end-user.  This discussion spurred his two quotes.  Lastly, anyone attending tonight’s keynote likely picked up on DHH’s (no I won’t spell his name out) quote.

I guess I could stop there, but I just wanted to add that Joel Spolsky of http://joelonsoftware.com/ did a fantastic job of getting the main conference started.  He was a hoot.  Let the Angelina Jolie jokes run freely now that he’s broken the ice.  And with that said, I’m headed to bed.