Tuesday, December 8, 2009

I've been playing too many video games

Now, this statement is actually true is a number of senses, but what I'm talking about here is the phenomena in video games where you get some new ability and then find yourself with a challenge. Now, CLEARLY you're supposed to use your new power/ability somehow, so you can safely ignore your basic stuff from the beginning and just figure out what you're supposed to fire your shiny new hookshot at.

Real life does not work that way.

So I had a program that seemed to be acting oddly. SO I asked myself, "what did we learn THIS semester." and figured it had to do with void pointers and allocations an deallocations and whatnot... so turns out I put an = where I was supposed to have an ==...
I've been playing too many video games.

Sunday, December 6, 2009

Assignment too?

yeah, so I've gotten together with my group a few more times. Fixed a few bugs. A few typos. Got things compiling. I DON'T KNOW WHAT TO WRITE HERE! Nothing interesting happens! We make slow but steady progress towards a more complete program and none of it is newsworthy. Nothing I do in this class is interesting enough to be blogged about.

We write. We test. We bug fix. wash. rinse. repeat. We occasionally meet up.

Wednesday, November 18, 2009

Assignment 2. A halfway through retrospective

So I've been asked to blog about my feelings regarding assignment two for OOP344.
Which is problematic really since I haven't DONE anything for it beyond a very basic skeleton. The function I'm in charge of requires another function to be complete so that I can inherit from it so until that gets finished there's not much I can do. the group I have seems good. I think all of us made it past the dropoff date and we all seem to know what we're doing so I figure I can get to work on building and debugging the function soon but until then there's nothing I can really say.

Overall I dislike this group based structure. While I see the POINT of it I can't help but think it's going to hamper up in the long run. Since this course has no actual labs in it and the assignment is so broken up by the group we can go the entire semester without any practical experience with entire groups of concepts we're supposed to be learning. I guess we're supposed to be doing things on our own but lets be honest, we have other projects and labs for other courses and as college students, we're lazy. Without any structured requirements to practice the skills most of us won't and when the final exam comes I foresee a lot of people not knowing what their doing.

Monday, October 12, 2009

Mac Keycodes and keyboards

So for assignment one in OOP344 the optional task is to get it working on the Mac's OS X.
Seemed easy enough. Switches ncurses with curses and I'd be good to go right?
Of course not. I started with the Linux keys because they would probably be the closest, and for the most part they were. For the most part.

Turns out mac's key binding are... odd. The first problem was backspace returning an unknown key (127) so I made backspace 127.

FIXED!

Next problem: the fact that I had no "end" "home" or "insert" keys on my keyboard. I got around this in the least elegant way possible. I jammed random key combinations until I got one that returned an unknown value and assigned that the key.
This gave me "Insert" sitting on Ctrl 'w'(integer: 23 - Ctrl 'i' and 'o' both being taken) "End" sitting on Ctrl 'e' (integer: 5) and "Home" sitting on Ctrl 'h'(integer: 263).

So that took care of that. The next problem was the function keys. They all had pre-existent hardware command. A short trip to google told me how to disable them and I now have f5-f12 working properly.
Only problem is that f1-f4 don't return f1-f4. They return 'P' 'Q' 'R' and 'S' respectively... except for when they crash my program for some reason. There doesn't seem to be much reason for this as it happens only occasionally and with no real pattern but yeah, whole thing, just crashes.
I could assign the functions to ctrl 'p' 'l' 'k' and 'u' since they have unused codes but that seems sloppy since I HAVE the keys I just can't get them to distinguish between themselves and capital P through S and "die you miserable program".

Other than that though I have gotten my code to pass every test on the mac.

Thursday, October 1, 2009

OOP344 Challenge 3

For our third challenge, we had to reduce our display program even moreso. Down to one line as it were. This seemed pretty much impossible until I remembered 2 things. First that since "row" and "col" are passed by value, once we've positioned the cursor they aren't needed for anything and can be used as counters and second that we have conditional operators.

Don't let the wrap around and ridiculous size fool you. That's one, long, ridiculous For Loop.

void io_display(const char *str, int row, int col, int len){

for(io_move(row, col), (len <= 0) ? (col=len,(io_putstr(str))) : (col=0); col < len ;(str[col] ? io_putch(str[col]) : io_putch(' ')), col++);
}

Tuesday, September 29, 2009

Source Pawn: A journey of gaming discovery

OK, so it's not technically C++ but it's written in and based off C++ and I haven't done anything actually related to C++ yet this week so I'm going to talk about something that combines the schools love of open source and my love of the Source engine.

At the request of one of my Internet friends I have recently downloaded the tools for "Source Pawn" it's a psuedo interpreted, objectless, terribly packaged (It downloads as a.gz (an open source version of zip) that extracts into a .TAR (an open source version of RAR)that extracts into a proper folder) language designed for writing mods and plug ins for the Source gaming engine. It apparently shares attributes with PHP, C++, javascript and a big mess.

That's not to say it's a bad thing. Quite the opposite. While some parts of it seem very messy, this is probably the first time that a language has been written by fans specifically for the purpose of modding a single set of games. As a feat it's quite remarkable and a stellar example of what an open source fan community can do when united by a common love and goal.

No games outside of the source engine's has ever had as numerous a collections of plugins, mods, open source coders as the source games and Source Pawn is the main reason. The recent DOS attacks many servers were facing was fixed in it, and all for free, because (and this is the part you guys will like) in order to keep it all community generated and free the creators have a strict policy that anything created in Source Pawn MUST have it's source code posted online for all to see. There are of course developers who create their own extensions to write tools in allowing them to make a nice profit off their work but for the most part, when Team Fortress 2, Counter Strike Source or Half Life 2 get a new mod it's available for the public, free of charge and with its source code laid bare so that everyone can bug hunt it and improve it for the rest of the community.

So I look forward to writing and testing my first plugins for this strange love child of gamer geekdom and open source philosophy. And when I have nothing C++ based to say in the future I'll fill you all in on how it goes.

Monday, September 21, 2009

OOP344 Challenge 2

Our class was given the challenge "Modify io_display function to the shortest code possible."
After some brainstorming I was able to get each part of the function down to 1 line. The original code was:

void io_display(const char *str, int row, int col, int len){
io_move(row, col);
if(len <= 0){
io_putstr(str);
}
else{
int i;
for(i=0;i<len && str[i];i++){
io_putch(str[i]);
}
for(;i<len;i++){
io_putch(' ');
}
}
}

I moved the variable to the top since I was taking out the if else structure and left the io_move where it was since it was already only one line.
Then I turned the check for a len of 0 or less into a for loop that only executed if the length was less than 1 and had the io_putstr as an increment condition. This saved me 4 lines.
Then I basically just did the same thing for the other two for loops, making the output command part of the increment and closing the for with a semicolon instead of a set of braces. The final code is only 7 lines long compared to the original 15.
Were this a c++ program I could have made the int declaration part of the for loop bringing the line total down to 6 but since it's supposed to work as a standard c program that isn't an option.

Here is the final function.

void io_display(const char *str, int row, int col, int len){
int i;
io_move(row, col);
for(i=len; i <= 0;io_putstr(str),i=1);
for(i=0; i<len && str[i];io_putch(str[i]),i++);
for(;i<len;putch(' '),i++);
}