That assassins game I was posting about recently ended, which means that the winner--my roommate, which is cool--gets to put the game together again. What a pain. You have to draw circles and put people in order and stuff. So I made an offhand remark to the guy who had been putting it all together before my roommate, "You know, it seems like this shouldn't be too hard to automate."
He looked at me, wanting to be sure of what I was asking. "Well," I said, not yet realizing what was happening, "a computer could pretty easily do it all. You just need to take each name, randomly assign a target, then move onto the target and randomly assign their target, etc. Maybe it could then automatically email everyone or something, so that every person would be able to participate, and nobody has to worry about knowing too much or sitting out." He replied, "Hey. Do you have a new project for today? Looks like it."
Now, I wouldn't be able to lay claim to the sort of geekdom I do without at least dabbling in programming. A few years back I was pretty into it. Actually, it started when I was twelve, and webpages (such as they were in those long ago days) somehow hooked me up with QBASIC. I wrote calculators and games and nothing useful, but it was fun. I bought a couple books on C and C++ but I never really stuck with it. So I had some vague idea of what I needed--I was going to need for loops, uh. I would need...a...compiler. Right. Anyway, nowadays we had Google, so I surely I could work out the rest of it. I mean, it's just a programming language. It's not like...you know...an entirely new field of study for me.
Turns out Ubuntu comes with a compiler! Or at least, I downloaded one to install programs previously. So that part was easy. Let's see if I can still get my Hello World on. Terminal output suggests I can, indeed, get my Hello World on.
Key to this project is file input. I want to be able to take a list of names and assemble that in the program into a pairing of names and targets. So I write a program that reads off a file's contents, to familiarize myself with that process.
I quickly get lots of errors from g++, but it wasn't helpful, and I quickly realized that I needed not a compiler but an IDE. Some googling later, I was in NetBeans, and successfully made file operations work. In an ominous bit of foreshadowing, I fixed a segfault issue, but I don't remember how.
At this point I decided I would go for broke. I wrote pretty much the entirety of the program in one go, deciding that the bits I didn't remember how to do I'd look up as I went along and fix when I tried to compile, rather than program-by-program learn all these techniques. By programmer standards, it's not very big. It's about a hundred lines, and that's with a fair number of comments, and I'm sure I declared variables in weird places and did a million weird things to it. Still, I was proud. Of course, it didn't compile the first time. It never compiles the first time, it rarely compiles the tenth. It did compile eventually, though, after I chased down rogue initializations and stray commas and the inevitable missing semicolon. And once that was done, I was inexpressibly proud. I ran my program, and it came up:
>>How many players, shithead?
4
>>Nice. What's the file name for this crap?
roster.txt
Segmentation fault. Bitch.
(Neither my actual program nor my CLI are this rude, but this isn't the most interesting topic so I spiced it up a bit.)
So yeah. That's what's happened the last few days. (It also snowed but dammit who cares about outside.) For now, the voyage continues. If I can solve my segfaults I'll be really happy, and then the most bare-bones version of the program will be complete. I'd really like to put together the email part of things, but I worry that's going to get beyond me pretty quickly. Still, I'll probably try.
Subscribe to:
Post Comments (Atom)
100011! Seems you have an amazing clarity of many languages.
ReplyDelete