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.
Link Bar
Home | Games | Programming | Tutorials | Donate | Legal (These are mostly empty right now. Placeholders!)
warning code
This website contains adult content.
Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts
Tuesday, March 20, 2012
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!
- 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:
OK, that's all for now. Tomorrow: back to project 2 in TECS. Ciao!
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.
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.
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.
Tuesday, March 13, 2012
Day 22: "Hula" Open-Source Beta!
I got the "help" button working. Turns out, back when I had thrown a "}" in at the end (because one was missing), I should have put it before the Help subroutine, because that's where it was missing from. But I put it in after the Help subroutine, which subordinated it to the Inventory subroutine. Dammit.
I don't want to admit how long it took me to figure that out.
I also think I've figured out what's causing playerLevel to start out at minus two billion, even though I know by math that it's supposed to start out at zero. See, the exact player level on a new game is -2,147,483,648. Recognize that number? Yup, it's -231, the lowest number that can be displayed in 32-bit number-crunching. I wanted "XP to next level" to always be twice what it was the last level - which is given by the function:
Anyway, that's a headache for another day. Here's the Hula beta, source code below the jump. Also, I learned how to make the binary logarithm function here on Stack Overflow, since Microsoft decided to excise it from cmath. Because who would ever want to take a binary logarithm of something? Huge dorks and lesser dweebs1, that's who.
Notes:
1. I swear by the stars that I got this from Strong Bad, but I can't find it right now.
I don't want to admit how long it took me to figure that out.
I also think I've figured out what's causing playerLevel to start out at minus two billion, even though I know by math that it's supposed to start out at zero. See, the exact player level on a new game is -2,147,483,648. Recognize that number? Yup, it's -231, the lowest number that can be displayed in 32-bit number-crunching. I wanted "XP to next level" to always be twice what it was the last level - which is given by the function:
[LEVEL] = log2(([XP] + 1) / 2) +1
At zero XP, then, you're level zero, because log2 of 1/2 is -1 (and then add one to make it zero). Take one action, and BAM, you're level one. Two more actions and you're level two, and so on and so forth. For some reason, though - probably because of how the logarithm function works under the hood - it's making it (for all intents and purposes) negative infinity. This could be caused by the fact that I'm calculating the binary logarithm as "log2n = log10n / log102," which is mathematically correct but might be causing the 'puter to throw a fit. Hmm.Anyway, that's a headache for another day. Here's the Hula beta, source code below the jump. Also, I learned how to make the binary logarithm function here on Stack Overflow, since Microsoft decided to excise it from cmath. Because who would ever want to take a binary logarithm of something? Huge dorks and lesser dweebs1, that's who.
Notes:
1. I swear by the stars that I got this from Strong Bad, but I can't find it right now.
Friday, March 9, 2012
Day 20: "Noob Game" launched!
Early update today, since I stayed up writing my tutorial. Feels good to be ahead of schedule for a change! Now if only I can find some work today...
Noob Game can be downloaded on the free right here! Below the jump is a tutorial on how to write this game (or something like it) all by yourself in C++. But be warned: the source code contains spoilers. Because I know you're super-concerned about those.
Noob Game can be downloaded on the free right here! Below the jump is a tutorial on how to write this game (or something like it) all by yourself in C++. But be warned: the source code contains spoilers. Because I know you're super-concerned about those.
Thursday, March 8, 2012
Day 19: A quest! And a world!
So I recoded everything from scratch in a new project called "Noob Game," rather than keep everything in "Hello World."
You start in Noob Camp and can talk to the Noob Trainer, who gives you a quest to take some Noob Shit to Noob Town. If you keep trying to talk to the Noob Trainer, he tells you to get going. You can then turn the Noob Shit in to the Noob Civilian, who gives you a gold piece. Now you're on a first-name basis with the Noob Trainer! That's some status right there!
The source code is beneath the jump, for anyone who is curious and/or wants to compile and play this pile of a game before I "officially" release it. There are still a few bugs, like levels don't work right (also, attacking is a lie and does not work), but I have ideas of how to fix them and just wanted to put something up on the blog before midnight.
EDIT: Uhh... finished the game? Compiled and released before midnight. Lots more quest, figured a couple neat new things out, posting a tutorial tomorrow. Who knows of a nice free place to make .exe files available for download?
DOUBLE-EDIT: Aaaaand... BAM!
You start in Noob Camp and can talk to the Noob Trainer, who gives you a quest to take some Noob Shit to Noob Town. If you keep trying to talk to the Noob Trainer, he tells you to get going. You can then turn the Noob Shit in to the Noob Civilian, who gives you a gold piece. Now you're on a first-name basis with the Noob Trainer! That's some status right there!
The source code is beneath the jump, for anyone who is curious and/or wants to compile and play this pile of a game before I "officially" release it. There are still a few bugs, like levels don't work right (also, attacking is a lie and does not work), but I have ideas of how to fix them and just wanted to put something up on the blog before midnight.
EDIT: Uhh... finished the game? Compiled and released before midnight. Lots more quest, figured a couple neat new things out, posting a tutorial tomorrow. Who knows of a nice free place to make .exe files available for download?
DOUBLE-EDIT: Aaaaand... BAM!
Wednesday, March 7, 2012
Day 18: A game, at last!
It's not much, but I have the rudiments of a game here, now. Thanks to Zachary's superior tutelage, I now have a game with a functioning victory condition, failure condition, and means of quitting. You can't save, or talk to anyone, or do anything besides win/lose/quit... but still! I have something functional here, and now it's just a matter of scaling it up until I get something worth distributing.
For those of you playing along at home, this is how Noob Game works (so far):
#include "stdafx.h"
#include "HelloWorld.h" //this header is empty at the moment, but I have a feeling I'll be using it eventually
using namespace std;
int _tmain(int argc, _TCHAR* argv[]) //this is the main function!
/* If I'm reading it right, the main function is simply an integer (albeit a really, really big one in binary). What this means is that any possible game state could also be represented as an integer, Library of Babel-style, such that there is a set of integers which in aggregate represent all possible game states. Whoah. */
{
cout<<"One Man Show"<<std::endl;
cout<<"Welcome to Noob Game. Enter 1 to win, 2 to lose, or 3 to quit."<<std::endl;
char choiceOne[100];
std::cin.getline(choiceOne,100);
if(choiceOne [0]=='1'){
std::cout<<"You win! Thank you for playing!"<<std::endl;
}
else {
if(choiceOne [0]=='2'){
std::cout<<"You lose! Please play another time."<<std::endl;
}
else {
if(choiceOne [0]=='3')[
std::cout<<"You quit! Fuckin' quitter."<<std::endl;
}}}
std::cout<<"The game is over. Enter anything to close."<<std::endl;
std::cin.getline(choiceOne,100);
;
return 0;
}
And that's it! I have extra comments in there & stuff, but I don't really care about that on such a small program. I compiled it and ran the .exe on my computer many times! It works! Well, entering "4" or anything else besides 1, 2, or 3 will simply advance to ending the game, but as far as I'm concerned right now, entering unacceptable input is a failure condition.
I'm working on a replay module right now; I'll probably have to learn something else to make it work the way I want to, since I can't use "goto" any more. Or at least shouldn't...
Anyway, even that was the result of an embarrassingly long session of poking, prodding, and just trying different things. I'm going to go back to doing that now; just wanted to share that I've actually got something! The simple fact that I'm using a program I created myself, no matter how rudimentary, is giving me a bit of a rush.
For those of you playing along at home, this is how Noob Game works (so far):
#include "stdafx.h"
#include "HelloWorld.h" //this header is empty at the moment, but I have a feeling I'll be using it eventually
using namespace std;
int _tmain(int argc, _TCHAR* argv[]) //this is the main function!
/* If I'm reading it right, the main function is simply an integer (albeit a really, really big one in binary). What this means is that any possible game state could also be represented as an integer, Library of Babel-style, such that there is a set of integers which in aggregate represent all possible game states. Whoah. */
{
cout<<"One Man Show"<<std::endl;
cout<<"Welcome to Noob Game. Enter 1 to win, 2 to lose, or 3 to quit."<<std::endl;
char choiceOne[100];
std::cin.getline(choiceOne,100);
if(choiceOne [0]=='1'){
std::cout<<"You win! Thank you for playing!"<<std::endl;
}
else {
if(choiceOne [0]=='2'){
std::cout<<"You lose! Please play another time."<<std::endl;
}
else {
if(choiceOne [0]=='3')[
std::cout<<"You quit! Fuckin' quitter."<<std::endl;
}}}
std::cout<<"The game is over. Enter anything to close."<<std::endl;
std::cin.getline(choiceOne,100);
;
return 0;
}
And that's it! I have extra comments in there & stuff, but I don't really care about that on such a small program. I compiled it and ran the .exe on my computer many times! It works! Well, entering "4" or anything else besides 1, 2, or 3 will simply advance to ending the game, but as far as I'm concerned right now, entering unacceptable input is a failure condition.
I'm working on a replay module right now; I'll probably have to learn something else to make it work the way I want to, since I can't use "goto" any more. Or at least shouldn't...
Anyway, even that was the result of an embarrassingly long session of poking, prodding, and just trying different things. I'm going to go back to doing that now; just wanted to share that I've actually got something! The simple fact that I'm using a program I created myself, no matter how rudimentary, is giving me a bit of a rush.
Tuesday, March 6, 2012
Day 17: Program runs!
Well, after much hemming and hawing, I finally sat through the MS Visual Studio tutorial and followed along instead of just watching it. Within minutes, I got this:
It works! Working code! But then when I entered "Hot cha!" as you can see above in Figure 1, I got a run-time check failure - apparently, some stack around the memory of "myLine" was corrupted. I can Break or Continue, and I don't know what those mean. Glad I can JFGI before I decide!
OK, I didn't find anything in two minutes and I'm too excited, so I clicked "break." Apparently, breaking things is the wrong thing to do. I don't know how I could have possibly known this in my previous life experience. Now I can't close the window. I ctrl+alt+deleted and tried to end the process, and it just won't die.
I was all set to reboot, and then VC++ asked me if I wanted to stop debugging when I closed it. Then the window closed on its own. Not spooky at all. This magic box is haunted.
Back up and running, and the machine tells you you've played even when you press 2. Hmm... I thought that maybe that "if(myLine[100]=1" bit might mean "if it's true," so I tried putting the 1 in quotes, and got, "1>c:\users\d\documents\visual studio 2010\projects\helloworld\helloworld\helloworld.cpp(23): error C2440: '=' : cannot convert from 'const char [2]' to 'char'; 1> There is no context in which this conversion is possible." That's at least intelligible, but it doesn't fix my problem.
OK, that's it for today. I also did a bunch of art stuff, but it's sketches at this point and nothing really presentable. Toodles!
Fig. 1 A window that asks for a 1 and everything!
It works! Working code! But then when I entered "Hot cha!" as you can see above in Figure 1, I got a run-time check failure - apparently, some stack around the memory of "myLine" was corrupted. I can Break or Continue, and I don't know what those mean. Glad I can JFGI before I decide!
OK, I didn't find anything in two minutes and I'm too excited, so I clicked "break." Apparently, breaking things is the wrong thing to do. I don't know how I could have possibly known this in my previous life experience. Now I can't close the window. I ctrl+alt+deleted and tried to end the process, and it just won't die.
I was all set to reboot, and then VC++ asked me if I wanted to stop debugging when I closed it. Then the window closed on its own. Not spooky at all. This magic box is haunted.
Back up and running, and the machine tells you you've played even when you press 2. Hmm... I thought that maybe that "if(myLine[100]=1" bit might mean "if it's true," so I tried putting the 1 in quotes, and got, "1>c:\users\d\documents\visual studio 2010\projects\helloworld\helloworld\helloworld.cpp(23): error C2440: '=' : cannot convert from 'const char [2]' to 'char'; 1> There is no context in which this conversion is possible." That's at least intelligible, but it doesn't fix my problem.
OK, that's it for today. I also did a bunch of art stuff, but it's sketches at this point and nothing really presentable. Toodles!
Day 16(+1): Oops!
It got to midnight last night before I really knew what time it was, and at that point I didn't have time to write a post. Sorry about that. I also had lots to do today, but now I'm done. So this is what's up with yesterday, and there ought to be something up about today's doings later on this evening.
Yesterday: trying to get SDL to work. Lazy Foo says that if I get an error, I probably skipped a step. I double-checked to make sure I didn't skip a step, but I don't know, maybe I'm glossing over the same part each time and then forgetting that I did it. That could also be happening.
I also read the lecture notes for Chapter 2 in TECS. Whooole lotta math in there, glad I had some calculus from my physics days or some of them thar numbars would've really screwed me up. Also, getting a clearer picture of how a computer does so much math so fast.
OK, time to get down to work. Err, play, that is. Hobby? We'll go with hobby. Time to get down to hobby.
Yesterday: trying to get SDL to work. Lazy Foo says that if I get an error, I probably skipped a step. I double-checked to make sure I didn't skip a step, but I don't know, maybe I'm glossing over the same part each time and then forgetting that I did it. That could also be happening.
I also read the lecture notes for Chapter 2 in TECS. Whooole lotta math in there, glad I had some calculus from my physics days or some of them thar numbars would've really screwed me up. Also, getting a clearer picture of how a computer does so much math so fast.
OK, time to get down to work. Err, play, that is. Hobby? We'll go with hobby. Time to get down to hobby.
Saturday, March 3, 2012
Day 15: Wiki Walking
A Wiki Walk is a train of thought that left the track and is Riding into the Sunset. When going for a Wiki Walk you know where you begin, but no one knows where you'll end. Are you a Mad Scientist building an orbital death ray? Well, too bad, inspiration struck and now it's the world's biggest dancing dish washer with a fully adjustable cup holder. You want to have a serious talk about the Middle East? Within ten minutes you'll be arguing whether Darth Vader could take Gandalf in a fight. Just want to check the Rule Of Cool page? Before you know it you're adding examples to Bungling Inventor. You, my friend, have just had a Wiki Walk.Bit of a late start (that's my King Understatement for today). Well, on writing this entry, at any rate. I've been reading and organizing ideas all evening (more on the ideas later). I'm starting to see the wisdom in the Chinese proverb, "Better to be deprived of food for three days, than tea for one" (and that's from before researchers scientifically established the health benefits).
- TVTropes: Wiki Walk
I finished project 01 in TECS. I'm going to keep posting my progress through the course by chapter and project, because otherwise I'll probably fall off the ball and publicizing my progress increases my commitment to it. But I'm stopping with the "step-by-step herp-a-derp" because it probably won't be helpful to anyone just getting started any more, and so will just amount to cheating for anyone who's actually taking the class. If I am struck by some kind of inspirational tangent, I'll blog about that, but the focus will be on where the tangent ends up and not on the project/chapter itself.
I also poked around quite a bit on LazyFoo.net. This guy's got a load of tutorials ranging from setting up libraries and displaying images to game saves and joysticks, and articles covering topics ranging from the nature of pixels to making a level editor. Like any good neophyte, I'm gradually coming to terms with the fact that the more I learn, the more I'll be able to appreciate just how much I have left to learn. But just as my knowledge of computer systems becomes clearer and more concrete the more I do it, so shall my programming knowledge grow. In this vein, Lazy Foo's page on Nerd Girls: The Game also has a very illuminating (not to mention humbling!) list of "Ten Things About Game Development They Didn't Teach Me in School." I have a feeling I'll be learning a lot from this guy.
So yeah: ideas! I think a happy medium between "game I can start out building" and "game I will have fun playing" is a card-based game. Obviously, I'll have to learn how to code a complete game of Solitaire before I can make my own crazy variation on it, but Solitaire (from what I've read) is a good one to cut your teeth on. We'll worry about the specifics of what would make this more fun to play than any other free version of Solitaire later - y'know, after I've actually made Solitaire and can get a feel for exactly how out-of-control my feature bloat has become. But I spent lots of time between my readings drinking green tea and thinking very explicitly about how to get from A to B one step/feature at a time, and I'm excited to see how it takes shape!
OK, I seriously have to get to bed now. I've got a busy weekend ahead of me, what with the layout stuff I want to do and getting a head start on content for next week. Y'all have a great one!
Thursday, March 1, 2012
Day 14: Eureka!
I took my homework with me this morning when I went to look for work. This was a good decision, because I only had like ten pages left to read in Phantoms in the Brain, and I needed something else to do besides all the paying work the temp agency didn't give me. I had ten more chips to build: DMux, Not16, And16, Or16, Mux16, Or8way, Mux4way16, Mux8way16, DMux4way, and Dmux8way. I built the first six, and half-decided/half-succumbed to saving the last four for when I was able to make sure that the first six actually worked, despite the roll I was on.
Last night, I built a multiplexor by a rather circuitous and wasteful, albeit functionally intact, method. But a two-way multiplexor, using one selector input to choose between two other inputs, only has an eight-value truth table when expressed propositionally. Mux4way, on the other hand, has two selector inputs and four primary inputs (a-d), resulting in a 64-value truth table that still comes out only 1 or 0. Don't even get me started on Mux8way! I realized that yesterday's approach simply wasn't practical, but was stumped as for how to proceed.
Necessity is the mother of invention, and I invented an epiphany. I honestly don't know how I missed this - it must have been decision fatigue - but I realized at some point when trying to draw up the 64 truth values for Mux4way that since it only comes out 1 or 0, I could just express the 1 values as ganged-up And functions, then disjoin them together into a giant Or function! Now I am slightly embarrassed over yesterday's fiddle-fartin'; but that's what I get for doing my homework in public. More importantly, I learned a valuable lesson, and I'm proud for having solved the problem in a more elegant fashion anyway, so it's all good. Behold: Mux2.0!
Meaner. Leaner. Also greener!
And here's the new and improved NAnd-Only HDL:
IN a, b, sel;
OUT out;
PARTS:
Nand (a=sel, b=sel, out=NotS);
Nand (a=a, b=NotS, out=r1);
Nand (a=sel, b=b, out=r2);
Nand (a=r1, b=r2, out=out);
Wham! Bam! Flim and flam! That's over 75% fewer lines of functional code, for those of you playing along at home. My inner quality consultant is serenely satisfied. OK, moving on!
DMux, the demultiplexor which takes a single input and uses a switch between two outputs, gave me a little bit of trouble. But that was only because I was thinking I still had one output, when actually I've got two output pins coming out of my own little black box space. That realization cleared it up right quick! The diagram seems almost absurdly simple in hindsight - even the NAnd-Only diagram!
Gallons easier once you paradigm shift out of truth-functional
propositions per se and just start black-boxing everything.
I'm not even going to bother with the code, here. If you've been following, it's simple enough to work it out for yourself, and I'm starting to feel pangs of "give a man a fish" guilt about doing this all in public. At this point, though, I think the only "damage" I've done is to help along somebody just getting started, like I am. That said, my code works beautifully! (Also, I found via typo that this HDL is case sensitive - good to know!)
Next up, Not16: the first 16-bit gate. This is the reason I wanted to try out a proof-of-concept at home before actually diagramming and coding Mux4way16 and the rest. Turns out, I can't just put in the variable "i" for inputs 0-15, I have to code them line-by-line. Or I could type it once in Word, and use Replace! Not a big deal for Not16, but definitely going to appreciate it for Mux8way16! I have never been so grateful for Ctrl+H in my life (true story!). I can imagine a program that takes code with [i] as a variable, expands it n times, and replaces [i] in each iteration of the code with [n-1] (because you start with zero, duh)... but this would save me a fairly minor amount of time (even though it feels like a lot of tedium), and anyway if I knew how to do that, I wouldn't be doing this in the first place. Heh. Whatever, Ctrl+V x 16 and highlighting a few lines then pressing Ctrl+H, Tab, n-1, Alt-A, N, Esc over and over isn't exactly hard. So that's And16, Or16, and Mux16 out of the way.
Or8way throws a bit of a curve, since it's not mapping multiple inputs to multiple outputs like the last three chips. Instead, we're taking in eight inputs to the same giant Or function which maps to a single output. What we're coding here is not to do one thing with many inputs and outputs, but rather to check for any of eight things (rather than Or's mere two). Here I think it pays to point out that how we code this may have an appreciable effect on performance: I could code 4+2+1 (or 8-1, ganging them serially rather than pairing them) Or gates, making the machine instantiate the Or chip (and its 3 component NAnd gates) seven times "inside" this chip; or I could directly code all 7*3 NAnd gates and have it be its own thing rather than making the machine look elsewhere first. While the difference between configurations is infinitesimal for just this one Or8 gate, it adds up cumulatively in the processor load when turn on the "computer" and run the "chips." Not of particular importance to the lesson at hand, but of tangential relevance and so I thought I'd point it out.
Also, I found out by experience that pins cannot be named beginning with numbers - who knew? I named the outputs from some of my NAnd gates as "out=xvy" for clarity (where x and y were integer values corresponding to input pins), rather than the relatively nondescript r1/r2, etc. I kept getting the error, "A pin name is expected," and jiggered around with it for over half an hour, giving myself a headache in the process. I have a feeling I should be expecting a lot of these in the weeks and months to come...
Taking stock: I seriously refined my multiplexor, which is a big deal to me, and wrote up the first six of my final ten gates. Good progress for one day, I think; and my brain is feeling full now, to boot! I also watched a great introductory video over at the Khan Academy, during which an idea for a text adventure began crystallizing. I'm not sure quite how to do the "window" stuff yet, but I've got a good handle on how to declare values like player health, experience, and level, and how to nest conditional dependencies inside them to link derived stats to their primaries (now I just need, oh, the rest of a game to house them!). I've also got some good ideas for a weekend mini-project to overhaul the site with a custom image header and a few layout features, so there's quite a bit going on under the hood today, as well. Plus Zach gave me another tip for making forward progress on Fetris, so I'll be looking into that right now. Y'all have a great one!
Final Thought: I just realized while proofreading that the program I pined after above - the one that would do my homework for me - would actually be pretty easy to code using the principles taught in Python by that video at the Khan Academy. The only real "invention" would be to code the recursive function that iterates the steps n times. Great, now I'm going to be thinking about that all night. Anyway, I'm not writing the code here, since that would be providing a tool that actually does actual homework in an actual class, but the principle will be super-useful when generating content procedurally in future games.
Or8way throws a bit of a curve, since it's not mapping multiple inputs to multiple outputs like the last three chips. Instead, we're taking in eight inputs to the same giant Or function which maps to a single output. What we're coding here is not to do one thing with many inputs and outputs, but rather to check for any of eight things (rather than Or's mere two). Here I think it pays to point out that how we code this may have an appreciable effect on performance: I could code 4+2+1 (or 8-1, ganging them serially rather than pairing them) Or gates, making the machine instantiate the Or chip (and its 3 component NAnd gates) seven times "inside" this chip; or I could directly code all 7*3 NAnd gates and have it be its own thing rather than making the machine look elsewhere first. While the difference between configurations is infinitesimal for just this one Or8 gate, it adds up cumulatively in the processor load when turn on the "computer" and run the "chips." Not of particular importance to the lesson at hand, but of tangential relevance and so I thought I'd point it out.
Also, I found out by experience that pins cannot be named beginning with numbers - who knew? I named the outputs from some of my NAnd gates as "out=xvy" for clarity (where x and y were integer values corresponding to input pins), rather than the relatively nondescript r1/r2, etc. I kept getting the error, "A pin name is expected," and jiggered around with it for over half an hour, giving myself a headache in the process. I have a feeling I should be expecting a lot of these in the weeks and months to come...
Taking stock: I seriously refined my multiplexor, which is a big deal to me, and wrote up the first six of my final ten gates. Good progress for one day, I think; and my brain is feeling full now, to boot! I also watched a great introductory video over at the Khan Academy, during which an idea for a text adventure began crystallizing. I'm not sure quite how to do the "window" stuff yet, but I've got a good handle on how to declare values like player health, experience, and level, and how to nest conditional dependencies inside them to link derived stats to their primaries (now I just need, oh, the rest of a game to house them!). I've also got some good ideas for a weekend mini-project to overhaul the site with a custom image header and a few layout features, so there's quite a bit going on under the hood today, as well. Plus Zach gave me another tip for making forward progress on Fetris, so I'll be looking into that right now. Y'all have a great one!
Final Thought: I just realized while proofreading that the program I pined after above - the one that would do my homework for me - would actually be pretty easy to code using the principles taught in Python by that video at the Khan Academy. The only real "invention" would be to code the recursive function that iterates the steps n times. Great, now I'm going to be thinking about that all night. Anyway, I'm not writing the code here, since that would be providing a tool that actually does actual homework in an actual class, but the principle will be super-useful when generating content procedurally in future games.
Wednesday, February 29, 2012
Day 13: TECS, Chapter 1, Part 2.
Zach gave me a suggestion that I thought would work. After half an hour of Googling, it still did not work. Back to the books!
I picked up exactly where I left off, on the testing scripts. Here is a test script from the textbook (testing the Xor gate which I discussed yesterday):
Next is what the chips are and how to build them. Easy-peasy, quick an' breezy. Well, up until we get to the 4-way 16-bit multiplexor, anyway. The Alert Reader will recall that multiplexors gave me a small headache yesterday, but today I only got slightly narrowed eyes and increased attention. Demultiplexors were a cinch after that; it's just the same thing, backwards! Building these exclusively out of NAnd gates? Ehh, not so much.
But that's the end of the chapter! Now for the project: build all the chips/gates mentioned in the chapter out of NAnd only (that would be Not, And, Or, Xor, Mux, DMux, Not16, And16, Or16, Mux16, Or8way, Mux4way16, Mux8way16, DMux4way, DMux8way). If this were a real course, I'd have a week to do this, so let's see how I feel after doing Not, And, Or, Xor, and Mux. Then I'll sleep on it and try the rest tomorrow.
Ready? Go!
First up, Not via NAND. Easy enough, right?
IN in;
OUT out;
PARTS:
Nand(a=in, b=in, out=out);
Ha ha, NAnd already does the heavy lifting for me! Load the test script, and: SUCCESS! Now for And via NAnd. Whoah, I almost thought I could just put a Not at the end, but herp-a-derp, that wouldn't work because NAnd isn't the... Wait. No, that's exactly what I want!
IN a, b;
OUT out;
PARTS:
Nand(a=a, b=b, out=r1) //the R is for RESULT, get it?
Not(in=r1, out=out); //let's make it more explicit, shall we?
Nand(a=r1, b=r1, out=out);
Load the test script, make sure I didn't do anything stupid, and... SUCCESS! I'm on a fuckin' roll! Now for the inclusive Or. This will require gymnastics...wait, no it won't, because I can just put Nots after a & b before they go into NAND, and poof! Let's be super explicit again:
IN a, b;
OUT out;
PARTS:
Nand(a=a, b=a, out=nota);
Nand(a=b, b=b, out=notb);
Nand(a=nota, b=notb, out=out);
Too sexy, too sexy! This is going smoothly. Now, I can't help cheating for Xor, since I was already given a diagram and the HDL for it; what I can help is whether I cheat further by simply copying, or instead translate the existing HDL into Super-Exciting Mega-Explicit NAnd-Only Language! (I'm not shouting, the "!" is just part of the phrase.) The tough part here is now no longer coming up with the HDL, but keeping my terms straight. I'll make a new diagram and divide it up into three phases like the old one: the Not phase, the And phase, and the Or phase, finally leading to the output. Here it is:
IN a, b;
OUT out;
PARTS:
Nand(a=a, b=a, out=nota);
Nand(a=b, b=b, out=notb);
Nand(a=a, b=notb, out=r1);
Nand(a=nota, b=b, out=r2);
Nand(a=r1, b=r2, out=out);
Instead of crossing my fingers, I'ma crack my knuckles. Crackita-pop! Plow! Annnd... SUCCESS! In the same number of lines of code as their original Xor gate, which needed Not, And, and Or! HOO-HA!
Uh-oh. Now for Mux. OK, there's a reason I decided to make this the last one for the night, and it's not just that it's 10:22. You're on a roll, just keep it going, man. Think out loud. Or on paper. Erm, in type. Whatever. You've got your a in, your b in, and your selector, and the selector decides which input comes through. I can do this. Think of it in terms of the shortcuts, first. Then blow it up into NAnd-Only, then simplify (if you can). OK.
Dammit, now it's 10:42, and I've been staring at this for 20 minutes and thinking, "No, this won't work. No, that won't work. Shit, what am I gonna do?" Urge... to cheat... rising... WAIT. Re-draw the truth table so it's less confusing. OK, now it looks like an Or for a & sel when sel=0, and it looks like an And for b & sel when sel=1. Good, you can work with this. Keep going. All right, it can't trigger the And for b & sel when sel=0, so... run an And from sel & b (result: selAndb). Duh. Keep going. Run an Or from sel & a (result: selOra). Now we've got selAndb which gives b when sel=1 and 0 when sel=0; and we've got selOra which gives 1 when sel=1 and a when sel=0. Good. Paragraph break.
Now compare your "mini" truth tables with each other. Wait. Duh. You're barking up the wrong tree here. Stop trying to make it explicitly perform based on why you know it ought to go, and make it perform based on why it needs to go. Back up and brute force the fucker, then clean it up in post. You'll be fine. OK. Start with sel&a&b=1. Work up from there. Run them all to And gates, then make those come out how they ought to do. Then funnel them into bottlenecks so that you get what you need at the end.
OK, finally. I got it. It's 11:50, and I fucking got it. First, I just did everything in terms of "and," "not," and "output" - not HDL-wise, just logic-wise. Like, I wrote on a piece of paper:
s&a&b=1
s&a&~b=0
s&~a&b=1
...and so on. Then I drew up HDL-like parsings of those functions, and tried to make them as similar as possible. I noticed that I could capture three correct outputs with only (s*a)*b (call it x), four more with (s+a)*b (call it y), and the last one with (s+a)*~b (call it z). (For the uninitiated, + = or, * = and, ~ = not.) Then I drew up a truth table for s, a, b across from x, y, z, and also drew up the output. I noticed that y predicted three of four outputs of 1, and z got the other one when s=0. The x function was useless, so I discarded it, and made x': y+(z*~s). (Fun Fact: I accomplished this step by folding over the s/a/b section, MAD Magazine fold-in style! Now that's thinking outside the box!) Finally, I drew up a schematic for a, b, and s inputs, into y and z functions using And, Or, and Not gates, then put it all through to the x' function, and that gives the output. So we have:
IN a, b, sel;
OUT out;
PARTS:
Or (a=a, b=sel, out=sva);
And (a=sva, b=b, out=y); //these lines describe the y function
Not (in=b, out=notb);
And (a=sva, b=notb, out=z); //these lines describe the z function, and I can re-use sva from above
Not (in=sel, out=nots);
And (a=z, b=nots, out=zAndNots);
Or (a=y, b=zAndNots, out=out); //these three lines describe the x' function, which is just output
OK, let's see if that runs... SUCCESS! Holy carp, that was insane. OK, that's my proof of concept, now to break it down into NAnd-Only. Picture first? Picture first!
IN a, b, sel;
OUT out;
PARTS:
Nand (a=a, b=a, out=nota);
Nand (a=sel, b=sel, out=nots);
Nand (a=nota, b=nots, out=sva);
Nand (a=sva, b=b, out=r1);
Nand (a=r1, b=r1, out=y); //BAM! That's y, now for z.
Nand (a=b, b=b, out=notb);
Nand (a=sva, b=notb, out=r2);
Nand (a=r2, b=r2, out=z); //Sweet. Now to wrap it all up!
Nand (a=z, b=nots, out=r3);
Nand (a=r3, b=r3, out=zAndNots);
Nand (a=y, b=y, out=noty);
Nand (a=zAndNots, b=zAndNots, out=notzAndNots);
Nand (a=noty, b=notzAndNots, out=out); //done!
Plug & chug, and... BAM! Success on the first try! And it only took me - TWO AND A HALF HOURS?! Whatever, I'm done now. By the stars, I've got a lot to do tomorrow, though... I'm starting to see why hardware designers burn out and how programming conventions become insane.
I picked up exactly where I left off, on the testing scripts. Here is a test script from the textbook (testing the Xor gate which I discussed yesterday):
load Xor.hdl,output-list a, b, out;Oh, man. This is easy, after understanding the chip itself! Just load up the chip, specify what goes onto the output list (in this case, our values for a, b, and the evaluated outputs), then set a & b to all combinations they could be, evaluate the chip's function, and output it. Like unto a pie. Sure enough, we get:
set a 0, set b 0,
eval, output;
set a 0, set b 1,
eval, output;
set a 1, set b 0,
eval, output;
set a 1, set b 1,
eval, output;
a | b | outHot cha. What's next?
0 | 0 | 0
0 | 1 | 1
1 | 0 | 1
1 | 1 | 0
Next is what the chips are and how to build them. Easy-peasy, quick an' breezy. Well, up until we get to the 4-way 16-bit multiplexor, anyway. The Alert Reader will recall that multiplexors gave me a small headache yesterday, but today I only got slightly narrowed eyes and increased attention. Demultiplexors were a cinch after that; it's just the same thing, backwards! Building these exclusively out of NAnd gates? Ehh, not so much.
I just learned this yesterday. Now you want me to build it with
two pop tabs and a paperclip? CHALLENGE ACCEPTED.
(From The Elements of Computing Systems, by Noam Nisan & Shimon Schocker)
But that's the end of the chapter! Now for the project: build all the chips/gates mentioned in the chapter out of NAnd only (that would be Not, And, Or, Xor, Mux, DMux, Not16, And16, Or16, Mux16, Or8way, Mux4way16, Mux8way16, DMux4way, DMux8way). If this were a real course, I'd have a week to do this, so let's see how I feel after doing Not, And, Or, Xor, and Mux. Then I'll sleep on it and try the rest tomorrow.
Ready? Go!
First up, Not via NAND. Easy enough, right?
IN in;
OUT out;
PARTS:
Nand(a=in, b=in, out=out);
Ha ha, NAnd already does the heavy lifting for me! Load the test script, and: SUCCESS! Now for And via NAnd. Whoah, I almost thought I could just put a Not at the end, but herp-a-derp, that wouldn't work because NAnd isn't the... Wait. No, that's exactly what I want!
IN a, b;
OUT out;
PARTS:
Nand(a=a, b=b, out=r1) //the R is for RESULT, get it?
Nand(a=r1, b=r1, out=out);
Load the test script, make sure I didn't do anything stupid, and... SUCCESS! I'm on a fuckin' roll! Now for the inclusive Or. This will require gymnastics...wait, no it won't, because I can just put Nots after a & b before they go into NAND, and poof! Let's be super explicit again:
IN a, b;
OUT out;
PARTS:
Nand(a=a, b=a, out=nota);
Nand(a=b, b=b, out=notb);
Nand(a=nota, b=notb, out=out);
Too sexy, too sexy! This is going smoothly. Now, I can't help cheating for Xor, since I was already given a diagram and the HDL for it; what I can help is whether I cheat further by simply copying, or instead translate the existing HDL into Super-Exciting Mega-Explicit NAnd-Only Language! (I'm not shouting, the "!" is just part of the phrase.) The tough part here is now no longer coming up with the HDL, but keeping my terms straight. I'll make a new diagram and divide it up into three phases like the old one: the Not phase, the And phase, and the Or phase, finally leading to the output. Here it is:
I haven't felt this enlightened since I learned why
the square root of two is necessarily irrational.
Hey, r1 & r2 just get Not'ed twice - at the end of the And phase, and at the beginning of the Or phase - which means... carry the one... I can skip steps. As long as I skip the right ones. Now I'm actually learning! Doing that, my new Optimized NAnd-Only Xor HDL is:IN a, b;
OUT out;
PARTS:
Nand(a=a, b=a, out=nota);
Nand(a=b, b=b, out=notb);
Nand(a=a, b=notb, out=r1);
Nand(a=nota, b=b, out=r2);
Nand(a=r1, b=r2, out=out);
Instead of crossing my fingers, I'ma crack my knuckles. Crackita-pop! Plow! Annnd... SUCCESS! In the same number of lines of code as their original Xor gate, which needed Not, And, and Or! HOO-HA!
Uh-oh. Now for Mux. OK, there's a reason I decided to make this the last one for the night, and it's not just that it's 10:22. You're on a roll, just keep it going, man. Think out loud. Or on paper. Erm, in type. Whatever. You've got your a in, your b in, and your selector, and the selector decides which input comes through. I can do this. Think of it in terms of the shortcuts, first. Then blow it up into NAnd-Only, then simplify (if you can). OK.
Dammit, now it's 10:42, and I've been staring at this for 20 minutes and thinking, "No, this won't work. No, that won't work. Shit, what am I gonna do?" Urge... to cheat... rising... WAIT. Re-draw the truth table so it's less confusing. OK, now it looks like an Or for a & sel when sel=0, and it looks like an And for b & sel when sel=1. Good, you can work with this. Keep going. All right, it can't trigger the And for b & sel when sel=0, so... run an And from sel & b (result: selAndb). Duh. Keep going. Run an Or from sel & a (result: selOra). Now we've got selAndb which gives b when sel=1 and 0 when sel=0; and we've got selOra which gives 1 when sel=1 and a when sel=0. Good. Paragraph break.
Now compare your "mini" truth tables with each other. Wait. Duh. You're barking up the wrong tree here. Stop trying to make it explicitly perform based on why you know it ought to go, and make it perform based on why it needs to go. Back up and brute force the fucker, then clean it up in post. You'll be fine. OK. Start with sel&a&b=1. Work up from there. Run them all to And gates, then make those come out how they ought to do. Then funnel them into bottlenecks so that you get what you need at the end.
OK, finally. I got it. It's 11:50, and I fucking got it. First, I just did everything in terms of "and," "not," and "output" - not HDL-wise, just logic-wise. Like, I wrote on a piece of paper:
s&a&b=1
s&a&~b=0
s&~a&b=1
...and so on. Then I drew up HDL-like parsings of those functions, and tried to make them as similar as possible. I noticed that I could capture three correct outputs with only (s*a)*b (call it x), four more with (s+a)*b (call it y), and the last one with (s+a)*~b (call it z). (For the uninitiated, + = or, * = and, ~ = not.) Then I drew up a truth table for s, a, b across from x, y, z, and also drew up the output. I noticed that y predicted three of four outputs of 1, and z got the other one when s=0. The x function was useless, so I discarded it, and made x': y+(z*~s). (Fun Fact: I accomplished this step by folding over the s/a/b section, MAD Magazine fold-in style! Now that's thinking outside the box!) Finally, I drew up a schematic for a, b, and s inputs, into y and z functions using And, Or, and Not gates, then put it all through to the x' function, and that gives the output. So we have:
IN a, b, sel;
OUT out;
PARTS:
Or (a=a, b=sel, out=sva);
And (a=sva, b=b, out=y); //these lines describe the y function
Not (in=b, out=notb);
And (a=sva, b=notb, out=z); //these lines describe the z function, and I can re-use sva from above
Not (in=sel, out=nots);
And (a=z, b=nots, out=zAndNots);
Or (a=y, b=zAndNots, out=out); //these three lines describe the x' function, which is just output
OK, let's see if that runs... SUCCESS! Holy carp, that was insane. OK, that's my proof of concept, now to break it down into NAnd-Only. Picture first? Picture first!
And to think, this is still the easy part...
Whoops, that "&s" at the bottom coming out of the first NAnd should read "~s"; and I need to label some results r1, r2, and r3; and I should also label that bit that comes out notzAndNots when you come anticlockwise around the lower-right corner. Not taking another picture, though. Now for code:IN a, b, sel;
OUT out;
PARTS:
Nand (a=a, b=a, out=nota);
Nand (a=sel, b=sel, out=nots);
Nand (a=nota, b=nots, out=sva);
Nand (a=sva, b=b, out=r1);
Nand (a=r1, b=r1, out=y); //BAM! That's y, now for z.
Nand (a=b, b=b, out=notb);
Nand (a=sva, b=notb, out=r2);
Nand (a=r2, b=r2, out=z); //Sweet. Now to wrap it all up!
Nand (a=z, b=nots, out=r3);
Nand (a=r3, b=r3, out=zAndNots);
Nand (a=y, b=y, out=noty);
Nand (a=zAndNots, b=zAndNots, out=notzAndNots);
Nand (a=noty, b=notzAndNots, out=out); //done!
Plug & chug, and... BAM! Success on the first try! And it only took me - TWO AND A HALF HOURS?! Whatever, I'm done now. By the stars, I've got a lot to do tomorrow, though... I'm starting to see why hardware designers burn out and how programming conventions become insane.
Tuesday, February 28, 2012
Day 12: Poking around the internets.
Zach left a helpful link in a comment on yesterday's post, and after reading through the whole thing, I have a slightly clearer idea of what's going wrong. See, line 187 says:
I don't know how to fix that, though. Either I need to do something different in the WinMain function (which I'm not sure what that would be), or I need to change my definition up at the top (and I'm not sure how I ought to do that). Well, this is what I get for using someone's code from over eight years ago. And holy carp, I spent over half an hour just typing out the above. Well, more like five minutes typing and revising it, and 25 minutes cradling my head trying to sort everything out. This is in addition to the hour I spent poking and prodding and reading and trying to make it work. And I'm still probably missing something (like a real programming course). Fine.
I'm going to play around with that NAND to Tetris thing.
Got the hardware simulator running after installing the 64-bit version of Java (had to consult their forums to find out I needed to do that - apparently the version I had before wasn't good enough). Got the Hardware Simulator running, and figured out how to load and test gates/chips in it. Nice. Project 00 complete, on to Chapter 1!
I started flipping through the slides for the lecture, figuring I'd read the chapter after I got an idea of what I'll be learning. Right away, multiplexers stumped me (well, on slide 9 of 24, anyway). I could not for the life of me figure out what was going on in that truth table. Wikipedia to the rescue! (By the way, is Wikipedia being wonky for anyone else lately?) Man, multiplexers are easy once you know that the selector picks which input gets to be translated into output! (I did not know that more than five minutes ago.) The rest of the slide show was easy after that - but now I have to basically re-learn all of my logic using NAND only, which is doable, but confusing. Whatever, that's the point of the exercise.
Reading the chapter itself, I further learned what the "canonical representation" of a Boolean function is (it's the inclusive disjunction of all the possible values which yield "true" on the truth table). I've also got the hardware description language (HDL) down. See, twenty minutes ago, this was gibberish to me:
OK, I've been doing this for hours, I'm halfway through the first chapter, and this is like a week's worth of work anyway. My brain is full. G'night, everybody!
wcx.lpszClassName=WINDOWCLASS;...and the error returned is:
error C2440: '=' : cannot convert from 'const char [7]' to 'LPCWSTR'So, OK, at least that's not gibberish to me any more. And way, way back up in line 15, when I wrote:
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
#define WINDOWCLASS "Fetris"...that must have made "WINDOWCLASS" into a constant. OK. And on line 187, I'm not certain what that "wcx" bit is all about, but "lpsz" means that I'm setting a long pointer to a null-terminated string - so it wants ASCII. Right? But... if it's trying to use a long pointer to a constant wide string... that means it wants Unicode. So I'm telling the machine to do something with ASCII, and it's trying to do it in Unicode, and that's the problem? I think so.
I don't know how to fix that, though. Either I need to do something different in the WinMain function (which I'm not sure what that would be), or I need to change my definition up at the top (and I'm not sure how I ought to do that). Well, this is what I get for using someone's code from over eight years ago. And holy carp, I spent over half an hour just typing out the above. Well, more like five minutes typing and revising it, and 25 minutes cradling my head trying to sort everything out. This is in addition to the hour I spent poking and prodding and reading and trying to make it work. And I'm still probably missing something (like a real programming course). Fine.
I'm going to play around with that NAND to Tetris thing.
Got the hardware simulator running after installing the 64-bit version of Java (had to consult their forums to find out I needed to do that - apparently the version I had before wasn't good enough). Got the Hardware Simulator running, and figured out how to load and test gates/chips in it. Nice. Project 00 complete, on to Chapter 1!
I started flipping through the slides for the lecture, figuring I'd read the chapter after I got an idea of what I'll be learning. Right away, multiplexers stumped me (well, on slide 9 of 24, anyway). I could not for the life of me figure out what was going on in that truth table. Wikipedia to the rescue! (By the way, is Wikipedia being wonky for anyone else lately?) Man, multiplexers are easy once you know that the selector picks which input gets to be translated into output! (I did not know that more than five minutes ago.) The rest of the slide show was easy after that - but now I have to basically re-learn all of my logic using NAND only, which is doable, but confusing. Whatever, that's the point of the exercise.
Reading the chapter itself, I further learned what the "canonical representation" of a Boolean function is (it's the inclusive disjunction of all the possible values which yield "true" on the truth table). I've also got the hardware description language (HDL) down. See, twenty minutes ago, this was gibberish to me:
/* Xor (exclusive or) gate:If a<>b out=1 else out=0. */But now I get it! See:
CHIP Xor {
IN a, b;
OUT out;
PARTS:
Not(in=a, out=nota);
Not(in=b, out=notb);
And(a=a, b=notb, out=w1);
And(a=nota, b=b, out=w2);
Or(a=w1, b=w2, out=out);
}
/* Xor (exclusive or) gate:I feel smarter already!
If a<>b out=1 else out=0. */
CHIP Xor { //we have a chip, called "Xor"
IN a, b; // it has inputs "a" and "b"
OUT out; // it has output "out"
PARTS: // these are its parts
Not(in=a, out=nota); // A "not" gate with input from a, outputting to "nota"
Not(in=b, out=notb); // A "not" gate with input from b, outputting to "notb"
And(a=a, b=notb, out=w1); // An "and" gate with input from a and notb, outputting to "w1"
And(a=nota, b=b, out=w2); // An "and" gate with input from nota and b, outputting to "w2"
Or(a=w1, b=w2, out=out); // An "or" gate with input from w1 and w2, outputting to "out"
}
OK, I've been doing this for hours, I'm halfway through the first chapter, and this is like a week's worth of work anyway. My brain is full. G'night, everybody!
Monday, February 27, 2012
Day 11: Fetris bug-huntin'.
Before I dive into the "actual" errors, I decided to fix the "pretend" errors (i.e. the errors caused by my human error, like typos). In addition to the errors I found last week, I found one case of necessary capitalization, one case of extra comma (which caused three other syntax errors in the same line), one case of super-exciting extra "}", and one case of a comma that should'a been a semicolon.
I take solace in the fact that I was able to solve my own syntax errors (which were the larger portion of the errors generated) simply by looking at them. I said, "Oh, that's obviously what's causing the problem," attempted to compile it once again, and BAM! Error gone! There was one case where I put a 1 (one) instead of an l (lower-case L), but... look, they look the same. I would say to them, "You want an ice cream cone?" Both of them say, "Yes." Everything that got more complicated than that, I checked against the original post, and yeah: did it exactly like he said (except for the one part where I kinda-sorta skipped a line).
I am unlikely to get support from Evil_Greven himself on this, but that's OK. It wouldn't be a learning experience without like six bajillion hurdles. My high school chemistry teacher, Dr. Landorf, once gave us a universal problem-solving method. I forget most of it, but the two parts that stuck with me were: "A problem is not when you simply have to get from A to B. A problem is when you have to get from A to B and have no idea how. Otherwise you merely have a number crunch," and, "When you can't find the solution to a problem, start at the answer and derive the question." I couldn't find the list itself on the internet (this was a handout from before the internet was everywhere, and apparently drew from several sources), but I did find a really great joke while I was looking:
OK, so the guy in thread number two said that I could either switch the compiler settings to multibyte character set, or use unicode strings instead (the recommended option). I can't find that option after combing through them all, and I don't know how to make it unicode compliant quite yet, so I'm calling it a night. It's quarter after ten, I have learned some things and done some things, and I'm happy.
For now.
I am unlikely to get support from Evil_Greven himself on this, but that's OK. It wouldn't be a learning experience without like six bajillion hurdles. My high school chemistry teacher, Dr. Landorf, once gave us a universal problem-solving method. I forget most of it, but the two parts that stuck with me were: "A problem is not when you simply have to get from A to B. A problem is when you have to get from A to B and have no idea how. Otherwise you merely have a number crunch," and, "When you can't find the solution to a problem, start at the answer and derive the question." I couldn't find the list itself on the internet (this was a handout from before the internet was everywhere, and apparently drew from several sources), but I did find a really great joke while I was looking:
A mechanical engineer, an electrical engineer, and a software engineer are in a car that breaks down. The mechanical engineer says, "Maybe is's a stuck valve." The electical engineer says, "Maybe it's a dead battery." The software engineer says, "I know. Let's all get out and get back in again, and see if that fixes it."BWAHAHA! Oh, what a groaner! Love it! OK, so I've now got it down to three errors:
1>------ Build started: Project: Fetris, Configuration: Debug Win32 ------Much more manageable than the two dozen I had on Friday. I can handle this. I think. I Googled the first error, in accordance with the prophecy (the prophecy is "JFGI") and found this thread, which led me to this other thread., which led me to this excellent article. The article is called "Making Wrong Code Look Wrong," and the author goes on about the true history of Hungarian notation (which I did not know was a thing until today) and how to be your own best friend with your programming conventions. Since one of my errors from this very day was an extra "}" nestled amongst some 50 lines of nested "how to make teh bloxxxorz," I really wish that Evil_Greven had followed rule 5: "Don't put closing braces more than one screen away from the matching opening brace." It would've been gallons easier to spot that extra brace, had he done so. But no worries! I learned a valuable lesson. And I bookmarked that guy's blog, because it's rad as Hell.
1> main.cpp
1>c:\users\d\documents\visual studio 2010\projects\fetris\fetris\main.cpp(187): error C2440: '=' : cannot convert from 'const char [7]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\d\documents\visual studio 2010\projects\fetris\fetris\main.cpp(196): error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [7]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\d\documents\visual studio 2010\projects\fetris\fetris\main.cpp(260): error C2664: 'BitMapObject::Load' : cannot convert parameter 2 from 'const char [11]' to 'LPCTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1> BitMapObject.cpp
1> Generating Code...
OK, so the guy in thread number two said that I could either switch the compiler settings to multibyte character set, or use unicode strings instead (the recommended option). I can't find that option after combing through them all, and I don't know how to make it unicode compliant quite yet, so I'm calling it a night. It's quarter after ten, I have learned some things and done some things, and I'm happy.
For now.
Sunday, February 26, 2012
Down the Rabbit Hole...
I started reading the textbook for The Elements of Computing Systems, it's very accessible and I recommend it to anyone who wants to know more about how computers work. Here's their course map:
I just read through the preface & introduction, and I can't wait to get started! I'm already learning new things, like the different levels of abstraction (as represented in the image above, and the text block below) that really go on inside the box. I used to think that you just had your programming language, which was made "binary compatible" (whatever that would mean) by the compiler (whatever that did), and the computer ran on binary. Well, binary and smoke (if you let the smoke out, the computer stops working). Lo and behold, the introduction comes to the rescue, curing me of my misconceptions:
I also read the tutorial on the hardware simulator, and the lecture notes on the introduction. I'm calling it: my brain is officially full. Project 00 can wait until, I dunno, whenever I get sick of trying to fix Fetris. Catch you crazy cats later.
From The Elements of Computing Systems, by Noam Nisan & Shimon
Schocker (free online course) http://www1.idc.ac.il/tecs/book/preface.pdf
If you have taken any programming course, you’ve probably encountered something like the program below early in your education. This particular program is written in Jack—a simple high-level language that has a conventional object-based syntax.
// First example in Programming 101:
class Main {
function void main() {
do Output.printString("Hello World");
do Output.println(); // New line.
return;
}
}
Trivial programs like Hello World are deceptively simple. Did you ever think about what it takes to actually run such a program on a computer? Let’s look under the hood. For starters, note that the program is nothing more than a bunch of dead characters stored in a text file. Thus, the first thing we must do is parse this text, uncover its semantics, and reexpress it in some low-level language understood by our computer. The result of this elaborate translation process, known as compilation, will be yet another text file, containing machine-level code. Of course machine language is also an abstraction—an agreed upon set of binary codes. In order to make this abstract formalism concrete, it must be realized by some hardware architecture. And this architecture, in turn, is implemented by a certain chip set—registers, memory units, ALU, and so on. Now, every one of these hardware devices is constructed from an integrated package of elementary logic gates. And these gates, in turn, can be built from primitive gates like Nand and Nor. Of course every one of these gates consists of several switching devices, typically implemented by transistors. And each transistor is made of— Well, we won’t go further than that, because that’s where computer science ends and physics starts.Computers are like way faster than I ever realized. Also, no wonder my framerate starts chugging when I jack up the draw distance.
I also read the tutorial on the hardware simulator, and the lecture notes on the introduction. I'm calling it: my brain is officially full. Project 00 can wait until, I dunno, whenever I get sick of trying to fix Fetris. Catch you crazy cats later.
Friday, February 24, 2012
Day 10: FETRIS (work in progress)
I went through Evil_Greven's tutorial on how to build a Tetris clone in an hour with C++. I followed his instructions using Microsoft Visual Studio 2008 Express. I'm much less intimidated by C++ now than I was two days ago, but I feel like I'm back in the 5th grade again, learning Spanish for the first time. "Yeah, I know what 'buenos días' means. 'Pantalones?' Oh, man, this is gonna be easy. Wait, why is N-yay a totally different letter from N-eh?" Seriously, you guys, for the longest time I thought that "vedevaca" was the name of the letter, not just "veh" - I didn't learn about "b de burro" until I was in freakin' high school. Same with "y griega," I didn't know it was as opposed to "i latina" until I dated a girl from Uruguay and she told me.
I guess what I'm saying is, I need to date a programmer now. No, that is not the most cynical use of dating ever. But, uhh... I can't come up with a more cynical one. Because I'm so totally not cynical. Double-promise.
Anyway, I got through with no problem, except that VC was telling me that I hadn't declared shit which I had so too declared, just look. But whatever, I didn't let it bother me, and I kept on chugging through. I would highlight everything that turned blue and hit F1 to bring up the help, and read through those articles. This made it take like three hours instead of one, but that's OK. Then I went to compile it at the end, and that's when shit hit the fan.
As my grandma would say, "Errors out the yin-yang." Yes, my grandma talks like that. No, it's not cool if you say that while being under 70 years old. Yes, that's a moving target; it won't be cool for 70-year-olds to talk like that when you're 70. Modern medicine has made it culturally impossible for us to be ironic by speaking in the fashion of young people when we are in fact old people. And no, current old people do not suffer from this flaw in our age-based system of behavioral standards. But hey, that's what you get for longevity. Stupid double-standards.
ANYWAY.
I dutifully read the errors and went to the lines of code where they allegedly occurred. Ahh, shit, I forgot a "( )". Oh, damn, a legit typo; must'a fat-fingered it. Whoops, left out a semicolon! And... that... I can't...
This tutorial was written in 2003. This might be nobody's mistake, just a case of mismatched standards. Maybe. But if it is Evil_Greven's mistake, it's almost certainly beyond my ken to fix it now. Dammit. I really wanted to play my very own Fetris. I even made the bitmap for the blocks!
Whatever, I'm putting this aside for now. I'll come back to it over the weekend and see what else I can learn. It's not like those errors are going anywhere, right? Besides, there's nothing like fixing a broke-ass machine to get you familiar with its workings. But for now, I'm done with this. You get the Tetris God:
Also, you should check out Hatetris. Because I just bet you're a masochist.
I guess what I'm saying is, I need to date a programmer now. No, that is not the most cynical use of dating ever. But, uhh... I can't come up with a more cynical one. Because I'm so totally not cynical. Double-promise.
Anyway, I got through with no problem, except that VC was telling me that I hadn't declared shit which I had so too declared, just look. But whatever, I didn't let it bother me, and I kept on chugging through. I would highlight everything that turned blue and hit F1 to bring up the help, and read through those articles. This made it take like three hours instead of one, but that's OK. Then I went to compile it at the end, and that's when shit hit the fan.
As my grandma would say, "Errors out the yin-yang." Yes, my grandma talks like that. No, it's not cool if you say that while being under 70 years old. Yes, that's a moving target; it won't be cool for 70-year-olds to talk like that when you're 70. Modern medicine has made it culturally impossible for us to be ironic by speaking in the fashion of young people when we are in fact old people. And no, current old people do not suffer from this flaw in our age-based system of behavioral standards. But hey, that's what you get for longevity. Stupid double-standards.
ANYWAY.
I dutifully read the errors and went to the lines of code where they allegedly occurred. Ahh, shit, I forgot a "( )". Oh, damn, a legit typo; must'a fat-fingered it. Whoops, left out a semicolon! And... that... I can't...
fetris\main.cpp(187): error C2440: '=' : cannot convert from 'const char [7]' to 'LPCWSTR'What the blue fuck does that mean? OK, let's go to line 187:
wcx.lpszClassName=WINDOWCLASS;Right. And what did Evil_Greven say to do here?
wcx.lpszClassName=WINDOWCLASS;All right. Double-check each and every character, and... yup, that's exactly the same. And what other sage advice does VC have to give me on this?
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style castOhhhhh-kayyyyy... I know what that means and everything. And I've got 21 more errors to go. That's not bad, for over 600 lines of code on my first day. Wait. Hold on. Remember Alexander the Great.
This tutorial was written in 2003. This might be nobody's mistake, just a case of mismatched standards. Maybe. But if it is Evil_Greven's mistake, it's almost certainly beyond my ken to fix it now. Dammit. I really wanted to play my very own Fetris. I even made the bitmap for the blocks!
Whatever, I'm putting this aside for now. I'll come back to it over the weekend and see what else I can learn. It's not like those errors are going anywhere, right? Besides, there's nothing like fixing a broke-ass machine to get you familiar with its workings. But for now, I'm done with this. You get the Tetris God:
Thursday, February 23, 2012
Day 9: The Alexandrian Solution
After reading some more about the Playskool programming that is RPGcode, I grew despondent at the idea that anything I learn here is going to need to be re-learned or un-learned whenever I get my Big Boy programming in gear - because some things will work and some things won't, and I'll probably have to learn which is which one by one. Hmm... let me think for two seconds here.
OK, I'm not doing that.
So has all this been a waste of time? Absolutely not. I've learned a lot in the last eight days, not only due to the reading I've been doing but also by playing around with things. I now have a much clearer picture of what goes into a video game. Look, here it is:
So yeah. There's this big, mysterious hurdle right there in the middle, and it turns out it's the part that actually holds everything together.
I don't know how to untie this Gordian knot - at least not in any way that I would consider to be an effective use of my time - so I'ma straight-up cut the fucker in half. I'm just gonna learn how to program. It's a valuable skill, it will help me accomplish my goals, and it's bound to be less time in the long run. I feel farther from finished game, but I know I'm closer to good game, and that's better to my mind. However, this means that my daily progress is going to be much less interesting. Actually, looking back... maybe not.
I'll probably also be able to research the things I'm interested in more directly, and take better advantage of Stack Exchange. We'll see how this goes.
...ahem.
Doop a doot doo.
What? You're still here? Oh, right. Progress. Y'know, that thing I said I'd do a little bit of every weekday.
There was a minor tab explosion and I took a walk around the internet. I learned a little bit o' FORTRAN way back when I was doing undergrad theoretical physics research (ugh, I let the professors write my bio and now it's stuck like that forever... that's what I get, I guess), so this shouldn't be too difficult. Although I bet it'll be much harder than writing a program that brute-forces a square root approximation and laughs at you if you enter 1 or 0. From poking around the 'tubes, it's looking like my best bet is C++. Python seems easier, but I'll just have to learn C++ after it, anyway; and I bet I can learn Python faster after C++ than the other way 'round. DarkBASIC could also be easy, there's a free version that runs only on ads, but I have little mini-versions of the same issues I've got with Python, and I don't want to wind up in any kind of legal limbo if I actually make something salable (or just have to do it all over in C++ anyway, which may or may not be worse). Anyway, here's the best of what I've read today:
OK, I'm not doing that.
So has all this been a waste of time? Absolutely not. I've learned a lot in the last eight days, not only due to the reading I've been doing but also by playing around with things. I now have a much clearer picture of what goes into a video game. Look, here it is:
Green means "I get it." Purple/Blue means I'm fuzzy on it.
Red & gold mean I'm fucking clueless.
So yeah. There's this big, mysterious hurdle right there in the middle, and it turns out it's the part that actually holds everything together.
I don't know how to untie this Gordian knot - at least not in any way that I would consider to be an effective use of my time - so I'ma straight-up cut the fucker in half. I'm just gonna learn how to program. It's a valuable skill, it will help me accomplish my goals, and it's bound to be less time in the long run. I feel farther from finished game, but I know I'm closer to good game, and that's better to my mind. However, this means that my daily progress is going to be much less interesting. Actually, looking back... maybe not.
I'll probably also be able to research the things I'm interested in more directly, and take better advantage of Stack Exchange. We'll see how this goes.
...ahem.
Doop a doot doo.
What? You're still here? Oh, right. Progress. Y'know, that thing I said I'd do a little bit of every weekday.
There was a minor tab explosion and I took a walk around the internet. I learned a little bit o' FORTRAN way back when I was doing undergrad theoretical physics research (ugh, I let the professors write my bio and now it's stuck like that forever... that's what I get, I guess), so this shouldn't be too difficult. Although I bet it'll be much harder than writing a program that brute-forces a square root approximation and laughs at you if you enter 1 or 0. From poking around the 'tubes, it's looking like my best bet is C++. Python seems easier, but I'll just have to learn C++ after it, anyway; and I bet I can learn Python faster after C++ than the other way 'round. DarkBASIC could also be easy, there's a free version that runs only on ads, but I have little mini-versions of the same issues I've got with Python, and I don't want to wind up in any kind of legal limbo if I actually make something salable (or just have to do it all over in C++ anyway, which may or may not be worse). Anyway, here's the best of what I've read today:
- Stack Exchange: What are good games to "earn your wings" with? Several perspectives on how to go about learning game development from scratch. Lots of agreement, and well-articulated disagreement.
- The Game Programming Wiki: Beginner FAQ. More grounding on exactly what the Hell I'm getting myself into. Getting many sides of the same issue is really helpful; repeatedly seeing the same ideas reinforces those ideas, and also "filters" some of the mere opinionating because it isn't repeated.
- TGC: Newsletter. These guys sell software (they made DarkBASIC), which does not interest me. But they have a newsletter, which does interest me. So I signed up for it. Hope that doesn't bite me in the ass... now I just gotta make sure I read it.
- Nisan & Schocken: The Elements of Computing Systems. Zach once explained to me how computers work at the transistor level. I understood that part. I then asked him how you get from "physical logic gate" to "game on screen," and I was unable to comprehend his explanations (due in no small part to the fact that we were drinking that night). This is a course on pretty much exactly that. I now have great weekend filler for twelve weeks! (Fourteen, if I stretch it.) Here's a sweet video with one of the authors explaining what the book/course are about in more depth:
- Lazy Foo' Productions: Beginning Game Programming. Lots of simple tutorials on things I do not yet understand but expect to understand soon. Bookmarked for now, I didn't open any of them.
- GameDev: Tetris clone in an hour with C++. Fucking YES. This is exactly the sort of thing I was looking for. This is tomorrow's project.
Wednesday, February 22, 2012
Day 8: More book-learning.
Seriously, you guys. I am thoroughly convinced that making a game takes forever and is impossible.
I got program vectors on the board, and I got NPC sprites on the board near the program vectors, but obviously they won't just go, I have to tell them to go and when to stop and blah blah blah.
I need to learn more programming, is what I'm saying.
So I looked up the section on vectors for more precise instructions, and it tells me to write things like "playerPath(variant handle, int flags, ...)" and "itemPath(variant handle, int flags, ...)" and expects me to know how to use RPGCode already (which borrows from programming languages I also don't know). Fine. I know when I'm in over my head, so I went to the RPGCode section to find something on "make sprite follow path vector." This section is written by Occasionally_Correct, who you may remember from that useful tutorial I read on Day 4. But the topic headings look like this:
OK. So. None of those is on assigning an NPC to a path vector. And in case you can't tell, this is not how I learn things. I don't do well with things like "basics" and "principles" unless what I'm learning is something simple and limited, like playing cards, and I can immediately do a bunch of trial and error. You get two through ten, then these three "face" cards (King beats Queen beats Jack beats Ten, and so on), and an Ace which can be high or low or both depending on the game. That's it. That I can learn with basics an' shit. This is like nailing Jell-O to a wall: you tell me something and I listen, but it's boring, and when I finally understand the second boring thing then I've already forgotten all about the first boring thing. I can never learn exciting things this way, because I can't remember all those boring things all at once. I need to start with an exciting thing, pre-formed and ready for dissection, and just use it first. Then when whatever it does isn't good enough for me any more, I learn one boring piece of that exciting thing at a time, and tweak it into oblivion until I get what I want out of it (or at least have a more robust understanding of what I can/can't get out of it). That way I can do something exciting, even if I'm doing it poorly, but I have practical knowledge straight out the gate and a way to branch out. Then when I've amassed enough exciting things (or at least enough facets of the one exciting thing), that's when I'll grasp the basics in a broad-based way.
I want to be clear here that I'm not saying the guide is bad. It's actually very good, but it doesn't fit me. It's like a well-made tuxedo that's two sizes too small: I can't fit it on and it looks like crap if I force it, even though it's evident that serious craftsmanship went into its design and manufacture. What I'm saying is, this guide's start point is my end-point. This guide wants to go backwards through my learning curve. The cheek!
It's like I want the internet, but I have a textbook. Yes, I can use the textbook; but the internet would work so much faster! Whatever. If this were easy, there's be zillions more shitty games out there. There's nothing else really to do at this point, since I can't execute the other game features I want without learning everything about coding. I guess I ought to keep working on the first game, then. So fiiiiine, I'll reeeeead the tutooooorial, and probably like three others too. Even though they put me to sleep because they start with things I don't care about and work up, rather than starting with things I do care about and working out. Although I suppose it would be really hard to write a guide centered around "what I care about."
So that's what I've been doing today. Found another good tutorial by this guy Marz, so hopefully that should mean "game updates" and not "learning updates" tomorrow. I don't think you guys wanna hear about what variables and functions and arguments all are, anyway.
I got program vectors on the board, and I got NPC sprites on the board near the program vectors, but obviously they won't just go, I have to tell them to go and when to stop and blah blah blah.
I need to learn more programming, is what I'm saying.
So I looked up the section on vectors for more precise instructions, and it tells me to write things like "playerPath(variant handle, int flags, ...)" and "itemPath(variant handle, int flags, ...)" and expects me to know how to use RPGCode already (which borrows from programming languages I also don't know). Fine. I know when I'm in over my head, so I went to the RPGCode section to find something on "make sprite follow path vector." This section is written by Occasionally_Correct, who you may remember from that useful tutorial I read on Day 4. But the topic headings look like this:
- Language Features
- Basics
- Program Flow
- Creating Functions
- Scope
- Error Handling
- Reserved Variables and Constants
- Function Reference
- Object Oriented Coding
- Old vs. New
- Methods and Using
- Overloading Operators
- Copy Constructors
- Polymorphism
OK. So. None of those is on assigning an NPC to a path vector. And in case you can't tell, this is not how I learn things. I don't do well with things like "basics" and "principles" unless what I'm learning is something simple and limited, like playing cards, and I can immediately do a bunch of trial and error. You get two through ten, then these three "face" cards (King beats Queen beats Jack beats Ten, and so on), and an Ace which can be high or low or both depending on the game. That's it. That I can learn with basics an' shit. This is like nailing Jell-O to a wall: you tell me something and I listen, but it's boring, and when I finally understand the second boring thing then I've already forgotten all about the first boring thing. I can never learn exciting things this way, because I can't remember all those boring things all at once. I need to start with an exciting thing, pre-formed and ready for dissection, and just use it first. Then when whatever it does isn't good enough for me any more, I learn one boring piece of that exciting thing at a time, and tweak it into oblivion until I get what I want out of it (or at least have a more robust understanding of what I can/can't get out of it). That way I can do something exciting, even if I'm doing it poorly, but I have practical knowledge straight out the gate and a way to branch out. Then when I've amassed enough exciting things (or at least enough facets of the one exciting thing), that's when I'll grasp the basics in a broad-based way.
I want to be clear here that I'm not saying the guide is bad. It's actually very good, but it doesn't fit me. It's like a well-made tuxedo that's two sizes too small: I can't fit it on and it looks like crap if I force it, even though it's evident that serious craftsmanship went into its design and manufacture. What I'm saying is, this guide's start point is my end-point. This guide wants to go backwards through my learning curve. The cheek!
It's like I want the internet, but I have a textbook. Yes, I can use the textbook; but the internet would work so much faster! Whatever. If this were easy, there's be zillions more shitty games out there. There's nothing else really to do at this point, since I can't execute the other game features I want without learning everything about coding. I guess I ought to keep working on the first game, then. So fiiiiine, I'll reeeeead the tutooooorial, and probably like three others too. Even though they put me to sleep because they start with things I don't care about and work up, rather than starting with things I do care about and working out. Although I suppose it would be really hard to write a guide centered around "what I care about."
So that's what I've been doing today. Found another good tutorial by this guy Marz, so hopefully that should mean "game updates" and not "learning updates" tomorrow. I don't think you guys wanna hear about what variables and functions and arguments all are, anyway.
Subscribe to:
Posts (Atom)