Link Bar

Home | Games | Programming | Tutorials | Donate | Legal (These are mostly empty right now. Placeholders!)

warning code

This website contains adult content.

Friday, March 23, 2012

Day 29: Solitaire-ish

Nearing 300 lines of code in Solitaire.  Mainly for how the interface is going to work out, since I haven't programmed card images or anything.  But it's a proof of concept!  I can make text-based Solitaire, dammit!

Just see if I don't...

You start the game in a room with a dealer, and the dealer can shuffle the cards, and that's about it right now.  But soon... soon... I shall be able to have the dealer deal the cards so that I can play the game.

And by extension, so shall you be.

Wednesday, March 21, 2012

Day 28: But I am le tired...

I did Google-maps'ed it, and between walking South to my job offer and North to the testing facility, I walked 16 miles today.  I got home and was beat and laid down for a nap, then just woke up.

Well, obviously I needed the sleep, and I'm going to be up for at least a couple hours, but it's already past midnight and I'm just poking around in Solitaire anyway.  So this is here for "something up around midnight," there should be something more substantial tomorrow evening.

Day 27.5: Two steps back...

Internet went down last night.  I tried to access the blog around 8, and that's when I first noticed it was down.  At 10, it was still down, so I went to sleep... because I had a job interview this morning!  (Cue excitement and applause!)  Just got back and the 'net is back up, now I have to go do the drug test.

You guys didn't miss much, honestly.  More reading, on how classes are made up of other classes, and can inherit things from parent classes, and so forth.  I'm learning (slowly) how things can be arranged into gangs of four, and how two-dimensional arrays can be "faked' from one-dimensional arrays, and it's all very fascinating and giving me lots of ideas.  But I'm having trouble scaling it down to the point where I can actually write the code; so once I've got that hacked, I'll be able to explode it up from there.

So... about that code-writing... the thing I wanted to be doing on day 26 (Monday)...

So, let's see... I told myself I'd have to start over at least six times.  If I work on a Solitaire game now to figure out objects, that will be my fourth time starting over (the RPG Toolkit world, Noob Game, Hula, and now this Solitaire game).  This is within acceptable bounds.  And then I can put objects in Hula.  And then I will know how I should have put them into Noob Game.  Maybe I'll have to re-do that, as well... Noob Game 2.0.  Then once I've got Noob Game's objects up and running, I think that might be at least the skeletal structure of an engine... so if Noob Game:  Objects is now the skeleton of an engine (and my fifth time starting over), then the game I was making with RPG Toolkit will be the sixth time starting over when I give it its own skeletal engine from scratch.  Except now I will know WTF I am doing.

OK, this is all within tolerance so far.  I'm leaving now to take the drug test, but it's across town and I'm walking, so that will eat up my time well into the evening.  When I get back, it will be time to work on Solitaire by coding objects for it.  If I don't get anything ready before I go to bed, I'll at least post to say so (giving at least the appearance of maintaining a schedule, and hey, I'll at least have learned a thing or two at any rate).  That gives me Thursday to also work on Solitaire, and Friday too, and then we'll see what's up by the weekend (hopefully I'll be scheduled for the orientation next Tuesday!).

Tuesday, March 20, 2012

Day 26: Object-Oriented Programming

So I pulled up a bunch of stuff to read on OOP over the weekend.  I started with Wikipedia's page on object-oriented programming, and when I got to methods, I thought, "Gee, this looks important.  Wonder what it is?"  New tab.  That article fairly swiftly mentions classes, so that meant another new tab.  And somewhere in there was a mention of UML, which term I did not recognize, so I checked it out for good measure.

Hmm... with the other pages I've got pulled up (introductory lessons for C++ from gillius.org, tenouk.com, and desy.de which looked interesting, then this from cplusplus.com and that from intap.net), this was starting to look suspiciously like a wiki walk.  I started with classes and read it all the way through, then back up to methods and finally into OOP generally.  Whuff, that's already quite a bit of reading.

What's more, it's informationally dense, too.  Check this out:

In a language that supports inheritance, an abstract class, or abstract base class (ABC), is a class that cannot be instantiated for it is either labelled as abstract or it simply specifies abstract methods (or virtual methods). Abstract classes specify virtual methods via signatures, that are to be implemented by direct or indirect descendents of the abstract class. Before a class derived, directly or indirectly, from an abstract class can be instantiated, all abstract methods of its parent classes must be implemented by some class in the derivation chain.
 - Wikipedia on abstract classes


Now, I had to read that a second time to really get it.  But now that I do, good Lord, is that last sentence important to remember!  And the whole thing is like this, pretty much, for a beginner like me.


I got to Chapter 3 in the tutorial at gillius.org and was referred to a page with information on dynamic memory allocation (covered way back in reg'lar C++, and now taken for granted in object-oriented C++) for not knowing about the "new" and "delete" commands.


And after more reading like this, it's becoming clear to me that OOP is much more complicated than I thought it would be (...surprise?).  I guess I'm back into a reading phase, then, since I'm not really sure quite how to start coding my objects.  And by "start," I mean how I want things to be organized in the grand scheme of things so that I know what classes I'll have and what individual objects will belong to what classes and so on, all of which it looks like I'll need to plan out in some manner of detail beforehand - oh, gosh, this means I need a Big Boy design document.  OK, so I guess that's the next step before I get objects into Hula, and then I can worry about instantiating the items in the game once I've got some classes & such described from which to draw when representing the game world.  Well, let's just start with one, like in Noob Game, and then blow it up to two, and then many, and we'll see where that takes me.


Oi, I love reading and learning and filling my brain with exciting new things... but this is tough sometimes!  Zach, things are certainly "spiralling out of control naturally," just like you said they would.

Friday, March 16, 2012

Day 25: TECS Project 2, and Arguing on the Internet

Arguing on the internet is like competing in the Special Olympics:  it doesn't matter who wins, you're still retarded.
 - Internet Wisdom


I was playing an online game last night, when I got into quite the disagreement with another guy in my group.  I casually mentioned that I was teaching myself how to program, and he offered his help as a professional programmer, which was very nice of him to do.  He suggested I dive right into OOP, and asked what I was doing now, and I said I was learning some C++ with the help of a friend (Zach) and going through TECS to learn how computers work from the bottom up.  Then came that fateful moment where someone says something which maybe they don't really mean, but then they stick to their guns and everything blows up in everyone's face.

He said, "No, you should start with a top-down approach.  Top-down is always better than bottom-up."

I added emphasis to "always," because that was the one word that stuck in my craw.  I am a philosopher, and I know from my philosophical training that the word "always" should almost always be preceded by the word "almost."  So I said, "Not necessarily."  To which he responded, "Yes, necessarily.  I do this for a living, I know what I'm talking about."

Oh, boy.

So I offered to cook him up an example of a situation where you'd want a bottom-up approach instead of a top-down one, and he was receptive.  I went on to say that if you wanted to simulate an ecosystem but don't know how it works, you should start at the bottom and tweak the parts until the high-level interactions look acceptably like what you see in reality.  I thought this would be a knock-down argument, since ecosystems do in fact emerge from the bottom up and not from the top down, and designing an ecosystem from the top down requires precisely the sort of understanding which the example stipulates to be lacking.  He replied that no, a better way would be to simply simulate all the high-level interactions without worrying about the bottom-up organization, because the internal structure doesn't matter so long as the output is correct (and fair play to him, that latter clause is true).  Having sprung my trap, I pointed out that this presupposes exactly the understanding which is missing from the example - in other words, if you could design the simulation accurately from the top down, then you've already got what the simulation is for.

It gets better.

Then he says, "Well, that's just one specific example.  In general, the top-down approach is better for achieving professional results."

I replied, "Wait, you just changed the subject!  You said that top-down is always better than bottom-up, which means that 'just one specific example' of bottom-up being better is all that's needed to show that top-down is not always better."

"Fine, but in a professional environment, you've still got to do things from the top down."

"But I'm not doing this in a professional environment!  I'm doing this as a hobby."

"Top-down gets results faster, though.  Working bottom-up usually engages you in a bunch of aimless wandering that doesn't get anything done."

We then discussed the virtues of curiosity-driven exploration and the importance of enjoying one's work, and it was all very edifying.  There was a happy ending, too.  I asked him if he had any hobbies (he does:  writing), and then asked him how many hours a week he spends working with his agent and trying to get published (answer:  zero).  Then I told him that he'll never get a good publishing deal without an agent to help him tweak his book for maximum marketability and so he's never going to make it as a professional writer with his current approach - and said that that's how he sounded to me during the last ten minutes.  Then he understood where I was coming from, and now we're friends again.

Jeez, some people (and in case it wasn't clear from my opening quotation, yes, I know that I am some people, too).

In Other News:  I built the half adder, full adder, 16-bit adder, and incrementer.  Oddly, the incrementer gave me the most trouble of the four, but then I had a flash of inspiration and facepalmed at the obviousness of the solution.  I still can't hack the ALU, though, and apparently that's the centerpiece of the virtual machine I'll eventually be building.  Moreover, it's not like I tried a bunch of different things and just kept failing; I don't even know where to start.  My instinct is that I'm intimidated by it at some level, probably because of all the different pins and the fact that it's just a black box on the inside and I need to specify everything that goes into the box.  But in the greater scheme of things, knowing how to build an ALU is tangential to my long-term goals at best, so I'm skipping it and moving on for now.  I gave it an honest effort (I re-read the chapter, and I'm a little clearer on what it's supposed to do, but no clearer at all on how I need to get it to do that), and maybe I'll come back to it after the next chapter or two and see if I have any epiphanies.  And anyway, I'm repeatedly finding myself thinking, "This would be so much easier if I could just write the function of the chip in C++ instead of the HDL," which A) means that I'm learning to think like a programmer, if nothing else, and B) shows that I still have a ways to go, because I wanted to use software to tell the hardware how to do what it does on its own.  But hey, at least I realized that.

OK, so that's week five down.  Over the weekend, I'll be reading up on OOP and classes and such, and Monday should bring another substantial update to Hula.  Y'all have a good one!

Thursday, March 15, 2012

Day 24: "Hula" Beta Update

New and Improved Hula beta here.  Source code below the jump.

Notes:
  • Fixed levels, thanks to Zach's excellent suggestion.  Now working as intended.
  • Added NPC "The Janitor."  Still no NPCs in the world, though.
  • Finished the introduction blurb, smoothed the transition into the game proper.
  • Refined the "consult device" mechanic; still not quite sure how I want this to work, but it's backburner material for now.
  • Put fish in the world for the player to mine, one per location (except inside the CoW or the Inner Hoop).
  • Added a "hunger" stat:  each action adds 1 hunger, player receives suggestions to eat at 90+ hunger, loses health at 101+ hunger (eating a fish restores all health and removes all hunger).
  • Sneaking through the CoW's armory now provides ten bullets to the player.  I'll make it a one-time thing later, but I'll need infinity bullets for future playtesting.
  • There is now an empty pistol at the starting screen.
  • Note to self:  not quite sure if cover is working like I want it to (even in the rudimentary build I've got at the moment).  Probably not.  Display auxiliary counters to check.
Zach's been encouraging me to look into object-oriented programming, and I've been putting it off because I have so many good ideas for my simple conditionals and so I wanted to just run with them while the creative juices were flowing.  But I am now thoroughly convinced that OOP will make NPCs way the Hell easier to handle, as I've been thinking about just exactly how to handle them without it, and it seems like a terrible exploding brute force problem.  So I'm going to read up on that over the weekend, and we'll see what I've got by Monday.

OK, that's all for now.  Tomorrow:  back to project 2 in TECS.  Ciao!

Wednesday, March 14, 2012

Day 23: TECS, Project 2

Holy carp, you guys.  Getting a computer to do math is hard.

Project 2 looks pretty simple at the outset:  build a half-adder (which I get), a full adder (which I also get), an adder (which I kinda get), an incrementer (which I so get that I almost forgot about it), and an arithmetic logic unit (which I don't get at all).  Something about that ALU is just irreducibly magical to me right now, and I'm not quite certain why.

I gave up and went to sleep, resolving to get up in the morning and take another crack at it.  I had hoped that the magic would go away, perhaps by more magic, but no dice.  I'm beating my head against the wall right now on this, which means it's time to do something else and then come back to this later.  If this were one class among many, I'd be tempted to "look for outside inspiration" (i.e. cheat); but I am under no such constraints, and that would simply defeat the purpose of the intellectual exercise (i.e. to learn).  So I'm calling it quits for now.

After today's errands, I'm going to take another pass at Hula and update the beta (assuming I don't just break it over and over again).  So that's something for day 24, and on day 25 I'll take another crack at project 2 after I've had some time off to let my failures sink in and learn some lessons from them.  OK, plan is planned, now execution just needs to be executed.