Monday, October 12, 2009

Still working on some tutorials... Objective-C is weird

One of the things I hate most is trying to learn a new language. Why? I find it hard to concentrate for the most part. But frankly, I like someone teaching me. Giving me examples and something to do (i.e., homework assignment). Having someone teach it to me allows me to stay focused on what I need to do.

Ok ok, these are really just excuses. The answer is really that I don't concentrate and I get distracted very easily. Like I mentioned before, I find it hard to concentrate. I don't know if it's my head, or if I'm just not that motivated, but man it's hard.

Having said all that - I've embarked upon learning a new language, a new system, and just generally jump into a whole new realm. One of my former classmates from UNM got a good jump on the iPhone development and set up this site which has some pretty good tutorials. They're a little light technical detail, but that's kind of a good thing, I'm sure I would get lost if it laid it on. Anyways, I've been going through the tutorials and reading Apple's Cocoa documents and iPhone dev documents. (hopefully those links work, might need an Apple account or something).

There are some other alternatives that maybe I'll take a look at. There's some Mono projects out there. In case you're too lazy to read that previous link, Mono is basically an open source project that allows C# to run on any platform. Why? Because C# is basically a Microsoft language that runs on .NET. Anyways, there are a couple Mono projects that allow C# apps to run the iPhone, not exactly kosher by Apple's iPhone dev EULA, but apparently there have been a few games written for the iPhone. Anyways, that might be worth checking out since the primary language I use at work.

Well, I think that's enough writing for now. I've got an incredibly bad headache...too much sugar...

Oh yeah, Objective-C the original reason I was going to make this post... uhm...yeah, it's weird. I've been with C# and Java for too long....yeah, that's it. lol

Thursday, October 8, 2009

eh...it's been about 5 months...

So might as well post something while I'm here.... it's been long enough....lets see...

Got a MacBook Pro to try my hand at some iPhone development. I've been wanting to jump onto this platform from the beginning, but I didn't want to spend the bucks on the equipment. Said "fuck it" with the blessing from my beautiful wife I got it :D

I have a feeling that I should have jumped in while it was still hot, I came across this article from Newsweek. That was very disheartening, but not surprising. However, this article is very promising. I dunno, I hope this was a good idea. Well, actually, regardless if I don't create interesting iPhone apps, I can always do some Android apps since that's java.

Ok, so I'll admit it. I love this little machine and I hope to be using it like crazy.

Frankly though, I'm still having trouble staying motivated. But just gotta keep at it... at least I've tried some tutorials for the iPhone.

Ok...that's it for now. See you in another 5 months. :D

Sunday, March 1, 2009

hrrmm...these puzzles are apuzzlin' me

So I was perusing the xkcd blag and came across this little puzzle (which was taken from LispClub.com).
Sue and Bob take turns rolling a 6-sided die. Once either person rolls a 6, the game is over. Sue rolls first. If she doesn’t roll a 6, Bob rolls the die; if he doesn’t roll a 6, Sue rolls again. They continue taking turns until one of them rolls a 6.

Bob rolls a 6 before Sue.

What is the probability Bob rolled the 6 on his second turn?
In the blag comment section, there was a lot of confusion over the wording. Personally, I read it as, "what is the probability of Bob winning the second roll?" In other words, what are the odds of Bob rolling a 6. If it is read like that, then most will probably guess 1/6. Makes sense; there are 6 sides to a dice and you have 1/6 chances of rolling the 6.

However, when you read it carefully and think about it, it's really asking for the probability of Bob winning on the second turn. Now, it's not as simple (to me anyways) and I get all sorts of confused. A commenter named Ian posted a lengthy description of the solution. The mathematics wasn't entirely clear to me, but makes kind of sense (very little to be honest). But math isn't my strong suit. Brute forcing is :D I decided to take Rotheral's approach in the comment section and write my own simulation. Granted, I created this the quickest way possible, and it's using java.util.Random, which from what I can remember isn't always the bestest of best random functions. But for all intents and purposes, it'll work just fine.

Here's the code (forgive the crudeness of how it's edited. I haven't figured out how to make blogger display code):

import java.util.Random;
public class RollOfDie {
  public static void main(String[] args) {
  Random rand = new Random();
    int bobRollCount = 0;
    int sueRollCount = 0;
    int sueWonRound2 = 0;
    int bobWonRound2 = 0;
    //loop for 1E8 games, that's 100,000,000
    for(int i = 0; i &lt 1E8; i++){
      //keep track of the turn
      int turnCount = 0;
      int roll = 0;
      //keep rolling until we hit 6
      while(roll != 6){
        roll = rand.nextInt(6) + 1;
        turnCount++;  
      }
      //even numbered turns are Sue's
      if(turnCount%2 == 0){
        sueRollCount++;
      //odd are Bob's
      }else{
        bobRollCount++;
      }

      //turnCount 2 and 3 are the second turn
      if(turnCount == 2){
        sueWonRound2++;
      }else if (turnCount == 3){
        bobWonRound2++;
    }
  }

  System.out.println("Bob won " + bobRollCount + " games");
  System.out.println("Bob won " + bobWonRound2 + " games on the 2nd round");
  System.out.println("Probability that Bob rolled a 6 on his second turn: " +
                      bobWonRound2 + "/" + bobRollCount + " = "
                      +((double)bobWonRound2/(double)bobRollCount));
  }
}

So as you can see, it's relatively straight forward. Just roll the dice until 6 is reached and then check if the turn was on the second turn (in this case, turnCount 2 or 3). I could have made it to run a few times and then take the average each running, but I felt that running 1E08 games was probably enough. That's 100,000,000 games. 

While I am convinced by the outcome of my result - it matches the ~21% others have reported, I'm not confident in the mathematics. There's a lot going over my head.

Regardless, I had fun making this little demo program. Maybe I should have tried making it in Haskell :D

Weezle-Wuzzle...again

So it's been another month since I've posted. I've done very little programming from home. I did work on my AI project some, but then, as was the case for my AI class, I got stuck trying to make my little bots turn and find their target properly and wouldn't you know it, I just stopped. I just cannot see where the problem is. UGH! So frustrating!

For a while, I sat down and tried to design a new system for this AI thing, but I'm unsure how to go about the design. What I need to do is just sit down and design it. Maybe even take out some of my books from my classes and read up (again) on how to properly design something. But then again, I need to make myself some clear cut goals.

This reminds me of this blog I came across some time ago. Looking at it, I'm fairly certain I have done 3 of the 7 items listed here.

So, how will I break this bad habit? Honestly, I'm not sure. I don't have a clear goal as to what I want or what I want to achieve. I also don't have a clear plan of any sorts to achieve any kind of goal. And then of course there's the motivation. I code all day at work, but don't find the energy to do so at home. It's one big cascading problem.

I've read that joining an open source project is a good way to get programming. Maybe I'll search around for something like that. But seriously, I need to sit my ass down and plan out my AI thing.

FOCUS FOCUS FOCUS

Saturday, January 24, 2009

uuuuuuuuuuuuugh...

Dag nabbit, I got totally lazy and didn't continue writing this friggin' blog.

So here's the deal, at work, I have a set schedule for writing my wiki/blog relating to work. But when I get home, gorram it, I have absolutely no motivation to update it. How am I supposed to stay motivated doing this? I'm finding it incredibly difficult. Yar yar yar...

Ok enough bitching. I am trying to start up little projects. I've been playing Supreme Commander a lot and it's made me want to work on some old AI stuff I had from the graduate class I took in Fall 08 (I dropped the class, felt a little bit overwhelmed, perhaps a post for another day). I figure, I can use the basic movement algorithms I got from it and build up from there. I love RTS games and it would be cool to make something.

I've decided to use Processing since the code I do have from the AI class was done in that. I'm very much tempted to use XNA since there is a nifty tutorial on selecting using using a game box. But, I also want to learn how to do it myself and not just copy and paste, which is what I will end up doing anyways. However, I use C# at work, and I want to work in a different language whilst at home. Even though at UNM I used Java.

Speaking of other languages, I've tried my hand at Haskell - aside from what I did for a class at UNM, but I dunno what to use it for. I need to go through the tutorials and figure out how it works to a decent point. There are some cool things you can do, but I'm not sure which ones. I'm thinking of doing Project Euler problems with it, but we'll see.

As for the old game that I had said I'd start working on. Obviously I'm not ranting and raving about it. I got distracted and lost interest. There was so much in there I was sure what to do anyways.

Saturday, August 23, 2008

Artillery Battlespace

In my fall semester of '07 I took a Graphics Processing class, which I absolutely hated no thanks to the professor, and our final project was to create a game using XNA. The game 2 other classmates and I created, Artillery Battlespace, was based off of Scorched3D and the Worms game series. The game, unfortunately, was not completed, and although we got good marks for it, it left a lot to be desired. I have taken it upon myself to continue with the project and see if I can finish it and add more interesting content. I have enlisted my old high school buddy Shikyi to help with some art stuff. This will primarily be a side project since I do currently have a full time job as a coder for a local software company in ABQ.

Currently my plan for the game is the following:
  • Rename game

  • Refactor

    • reorder and rename variables

    • set proper access (make most private) and use Properties as the main form of access (C#'s version of getters/setters).

    • clean up functions

    • clean up game states

    • Fix and/or reorder Player/Tank relation

  • New art - with help from Shikyi

  • New Models - with help from Shikyi

  • Add Shaders (is going to require some research on my part)

  • Fix lighting

  • Fix bounding box


Currently those are the items I've been thinking about. I've been doing the refactoring part mostly and occasionally fixing a function here and there. When we created the game we had 3 or 4 weeks to do it, so we were in quite a rush to get it done; code cleanliness took a backseat to code production. I hope to move on to fixing class structures afterward. I do believe they could definitely use it. After that, I'll probably work on a proper game layout, and hopefully, if I'm not tired of this, work on the gameplay. I'm trying to save the graphics for last since I had a lot of trouble with it before. There are a lot more tutorials out there now, so I plan to utilize them.

I'm definitely hoping to get a decent game set up. This has always been a big dream of mine and if I can create at least 1 game, then I can die a happy man ;)

First blag

This will be my 3rd attempt to blag about stuff, hopefully this time I'll stay consistent with it. Generally I will focus on codes and stuff, but I'll probably dabble in my personal stuff from time to time. Naturally I don't expect very many people (or any for that matter) to actually read this. But for those that do, I hope you find this blag interesting and occasionally entertaining. If you have _kind_ words to offer, emphasis on kind, then feel free to share. So, enjoy!