Monday, November 24, 2014

Writing a computer game

Alpha Centauri (SMAC) is one of my favorites. Been playing it since it came out, in 1999. Brilliant game. Complex in a lot of ways. Not perfect, there are some small flaws, but they're small. PC Gamer gave it their highest-ever score ranking (98, not matched by Skyrim, HL2, etc).

Been out of print for years. GOG carries it for Win/Mac, which is great. But eventually even that won't be good enough.

So I'm writing a clone of sorts.

A better-looking clone. Probably a simpler clone--there are a lot of things in SMAC that I have never had to use or understand. Granted, I have never played online against others, and maybe those things are more important in that case.

The level of detail that went into the tech/research-tree, and all the other little details about what can/can't be done when/where by what, just marvelous.

Customizable in so many ways. Largely irrelevant was my experience. I don't know how many times I've played through. This is a really long game (like playing Monopoly all the way through to the solo end), it can take 100-200 hours each time, so my play-through count isn't huge, probably a dozen or so.

I'm going to snarf most of the details, leave out some things that seem like unnecessary complexity.

Already I have a better-looking opening screen/menu sequence, and I've begun creating the classes in Java for it. As Java, it has to be OO, which I suspect the original was not...I have a terrain generator of sorts, but I'm not happy with it yet. Still thinking about how-to details for various aspects.

As Java, it will run on just about any platform that runs a complete Java JSE+Swing, incl Linux, but probably NOT any JME.

I'll try to do some 3D GUI stuff. That's a retirement project, to create such a thing.

I hate Java

I've been programming in Java for over 15 years.

I'm very good at it.

And I still hate it. (Writing below refers to Java 6; newer Java may have solved part of this issue)

Cases in point:

1) Iteration. The inconsistencies about how you do this are endlessly aggravating. There should be ONE SINGLE WAY to iterate. And that means ONE SINGLE WAY to create something to iterate over, when it's not something that already has an obvious iteration sequence.

Sometimes you have a List-behaving group. Sometimes you don't. Either way, I should NOT have to be remembering "ah, for *this* particular thing I have to loop over a Vector, for this one it's an array, this time I get an enumeration, this one is an iterator, etc"

Code examples:

File[] files = new File("some-folder/").listFiles();

Enumeration keys = new Hashtable().keys();

Collection values = new Hashtable().values();
Iterator iter = values.iterator();

Vector xx = new Vector();
for (String yy:xx) { whatever(yy); } //this works fine

for (String fname:new File("some-folder").listFiles()) { something(fname); } // nope, can't do this

2) Lengths of various things.

new File("some-folder/").length

new Vector().size();

Enumeration keys = new Hashtable().keys(); //what? there IS NO WAY to get the length? GGGGAAAAHHHH!!!!


3) Apply a function/method to the elements of a sequence. No such animal.

I'd like to be able to do something like this:

 for (String fname:Apply(FindMethodNamed("xyz"), new File("some-folder").listFiles(), Vector) { something(fname); }

-----------------------------------

I used to program in Lisp, starting 30 years ago. Lisp is beautiful. So clean in comparison. I was twice as good.

need the length of something that could be a list/sequence? (size X

need to do that "Apply" thing above?

(map #'(lambda(obj) (filename-name obj)) (list-files "some-folder/"))

Well, really, you would probably not even do that anyway. There wouldn't be a reason, if you were just going to iterate over the list of files.

(dolist (file (list-files "some-folder/")) (do-something (filename-name file)))

Hmm. Was that that function called list-directory? Been long enough that I misremember.

Rumor is that Java 8 finally has something like this. 8. Rumor was that Java 7 was going to have it. But most of it is a foreign concept for Java. Functions? Functions not tied to a class? Anonymous functions? "Lambda" functions? I haven't been to look, as I have a restriction at work to using Java 6 still (not that I wouldn't like to move forward, but I don't control the circumstances; it was supposed to have changed by now, but personnel turnover in IT have not helped).


Java is a language hacked together by a committee that never met to discuss things like consistency. Damn amateurs.


Granted, when I started with Lisp, it was almost 30 years old, and these issues were long gone, and the formal standard of Common Lisp had just hit the streets. And that was designed by a committee. A committee that "met" many times over some years, and had themselves many years, or decades, of background in various dialects of Lisp. And even then version one isn't quite perfect...for one thing, the Object System isn't included (not because the reference implementation didn't exist, it did, I knew of it, but I hadn't touched it yet). Version two had that, and it was/is better than Java's. Did the Java creators learn from it? Not hardly. Java is C++ minus the really stupid things about C++ from the 80s (another amateur hack that didn't learn from others).

And here I am, I am now full-time a Java programmer. And after this many years, parts of it are still just as stupid as 20 years ago, and will not ever be getting better. And I won't be getting any better at it either.

Fortunately retirement is not that far off...and I still have a huge amount of personal programming to do after that.

Friday, November 14, 2014

The "Friend Zone" :)

This is an amusing read:

Top 10 reasons why...

My reaction (by the reason numbers):

1) Of course it's real. It's been around a long time, and now it formally has a name. (I think it used to be called "LJBF", but "FZ is better".)

OK, what IS the friend zone? It's when a woman you have some romantic interest in tells you "I've always thought of you as [just] a friend" -- which means that she DOES NOT and CANNOT see you as a romantic interest. When they say that to you, it is time to walk away. Take the ego hit and go. Permanently.Getting pushed into the "FZ" is a one-way trip.

2) You have only just so much time to spend on "the pursuit". You cannot afford to spend any on a woman who has "FZ'd" you. Not any. Move on. Be courteous if you bump into her, but you will never be seen as a romantic partner. (Alright, maybe it's not a statistical impossibility, but the probability is vanishingly small, don't waste time on it.)

3) Actually, it's a very subtle attack: what it really means is "please go away and don't be a stalker". She did not give you "the truth", because part of the truth involves words she doesn't want to say.

4) True enough, but since they can't say the words it really means, it's another self-deception on their part. You acted like one of her female friends, so that's how you got classified. Don't allow it.

5) What is a "nice guy" ? One who isn't going to hit her? Remember that they want some measure of excitement. Don't hit her, ever, but don't let her think you're a doormat. Either act like she's a romantic target or do not interact with her at all.

6) Have never done this. Well, not that I am aware of...I remember, well, let's go ahead and say "dumping" two girlfriends, but they were actual girlfriends I'd had sex with, not women who'd been interested but I ignored. That sort of thing could not happen to me. Why? I am not a guy who attracts women. At all. So there is no possible occurrence where I would FZ one, because there wouldn't be a circumstance where there would be one who had a romantic interest in me and she made the initial approach. So of course you can describe the hypothetical of "well what if one did?" but since that can't happen to me, I would be 100% incapable of recognizing it, and would be certain that there was some other meaning to the initial contact and would react accordingly. (My superpower was and still is being invisible to women :) )

7) Women don't complain about it because they are running a master class in self-deception, and that includes careful code-phrases like "It just didn't work out", which is much gentler on one's self than "he thought I was boring/unattractive".

8) As I am not any woman's "type" this doesn't even mean anything to me. It is true as written. (fwiw, I'd go with Zooey, (unless she was blond at the time, that just does not work for Zooey) but since nothing of the kind could happen, it still doesn't mean anything)

9) Correct as written. Move on. Immediately. Do not give her a second glance. It ain't happening.

10) Mostly right. You got rejected, in a way that allows her to pretend to herself that she didn't "reject" you. She still doesn't want to see you ever again, since what it means is that she doesn't think you are exciting or attractive.

------

The Friend Zone is a female thing. Women put you in it so as not to think about you as a romantic partner, and to avoid saying "I don't think you're attractive".

(Repeating from a recent prior blog wherein Ben Affleck was mentioned:)

Scenario: you're female, single, 27. You live by yourself (or with female roommates), in an apartment. There's a knock at the door. You answer, a guy is there, you've not met before. He says "come have dinner with me". What are the first words out of your mouth?

1) Get out of here you creep! (followed by slamming the door and locking it)
2) I've always thought of you as a friend.
3) Give me five minutes to change clothes. How dressed up should I look?

The answer to this is 100% based on how good-looking he is. If it's one of those dorks from Dumb and Dumber, you say #1. If it's Harold from the Accounting dept, you say #2. If it's (your pick) Ben Affleck or Benedict Cumberbatch, you say #3, after you pick your jaw up off the floor.


Variation: flip the sexes. You're male, single, 27. You live alone, of course. At the apartment, a knock comes on the door. You answer, it's a female, she says "come have dinner with me". What do you say?

1) Buzz off slut!
2) I'm unfortunately busy this evening.
3) Let me get my jacket.
4) Am I on Candid Camera?

The answer to this is 100% based on how good-looking she is. If she looks like Mama June, you either say #1 or just close the door and think wtf (followed by holding that beer bottle up to the light and wondering if there are some hallucinogenics in it and why you didn't hallucinate Lynda Carter)? If she looks like Amy from BBT you likely say #2 (unless it looks like she has good-sized tits, or it's Mayim and she looks like this). If she looks like Deepika, you say #3, regardless of whatever the hell else other circumstances exist (even if you're getting married tomorrow), you don't even need to change clothes, because no one is even going to see you other than to wonder who's that guy with Deepika?

No guy is going to say "I've always thought of you as just a friend".

(If you're me, there are only two phrases: "I'm sorry" and you close the door, or "I'm sorry, you've confused me with someone else" (and that is even if it's Deepika) because of course there's absolutely no way a female is going to come knock on my door).


So, another anecdote. (Anecdotes are not data.) Long ago, there was an exchange with an ex-gf:

(I forget the precise timing, it was after the break-up, but perhaps not long after)

Her: can we still be friends? Oh, wait, I forgot, you don't have female "friends".

Me: Your sarcasm is wasted. [I'll be polite, but I won't go any farther than that, if our paths cross again]

I don't know what she meant by "friends", as there weren't any circumstances that would cause us to be within a mile of each other again after that, and we wouldn't be talking on the phone (and this was long before email).

The amount of time I have to spend interacting with women must be focused on the romantic angle, I do not have time to be "friends". What does that even mean?



Another anecdote  (we'll see if I can even remember this completely, I think it was 1988):

Female cousin (age ~26) says to me: I'm in this singles group at church, it's a big group, and I never get asked out. (which I is guess basically the raison d'etre for a church singles group)

Me:Why don't YOU ask one of THEM? Can't hurt...

Weeks or months later...

Cousin: well, I tried that. I got told he didn't want to damage his friendship with {her ex-boyfriend} [so I hadn't known about that at all] [as though an ex-boyfriend would care even slightly].

Me: [probably something like:] Huh. wow. Well...

What was I going to tell her? The reality of that was: He didn't find you attractive enough. [True enough; at the time she was a bit overweight] Simple as that. I guarantee you that if she had looked like (let's pick a well-known actress at that specific time) Kathleen Turner in Body Heat (~same age as cousin in that movie) or Romancing the Stone, the guy she asked would have been more than willing to ignore anything else for her. (Of course this ignores the fact that if she looked like KT in Body Heat she'd have had to fight guys off with a stick just to get out to her car)

So that was a lie he told her to dodge giving the real answer: I don't find you attractive. (And of course I didn't say it either, wimping out to an extent, I couldn't see a good reason to do so.) Also note that he didn't say "I've always thought of you as a friend".

The other important lesson in that episode is that she learns just how hard it is for most of us to ask them out, the insecurity, the second-guessing in advance, the agonizing over whether today is the right day. I sure don't want to have to think about that again.