Sunday, January 10, 2010

segfault, a pox on both your houses!

I spend the bulk of the productive part of my day wrestling with this segfault in my R program.
*** caught segfault *** address 0x0, cause 'memory not mapped' Traceback: 1: .C("Cbcp", PACKAGE = "bcp", data = as.double(x), mcmcreturn = as.integer(mcmcreturn), n = as.integer(n), burnin = as.integer(burnin), mcmc = as.integer(mcmc), rho = as.integer(rho), rhos = as.integer(rhos), blocks = as.integer(blocks), results = as.double(results), a = as.double(p0), c = as.double(w0), pmean = as.double(pmean), pvar = as.double(pvar), pchange = as.double(pchange)) 2: bcp(validData[validData$validGvkeys == k, "validIndicators"])

Oh! What wailing and gnashing of teeth! Turns out it was caused by too few data points. You'd think that'd be something the authors of the function would anticipate and error-trap. I'm tempted to contact them about it, but I suspect they would just laugh at me for attempting to do breakpoint analysis on three datapoints. The point is: I was running it in a loop over many different firms without awareness of how many points each firm has. Still my fault? Dammit, the function should return an error, not segfault.

Anyway, its working, and its an awesome package (bcp). I've got this awesome method under control less than a week after it was suggested to me. I feel capable. I suppose that balances out with having excitedly sending my adviser a graph that I totally misinterpreted under the obvious influence of confirmation bias; ignoring the generally accepted fact that probabilities cannot be negative.

Edit: a better title for this post would be "Pox, A segfault on both your houses!"

Capitan Forever

I succumbed to the quest for the perfect ship again. The goal was to build the smallest ship possible with instant-recharging shields, and I have three amusingly excessive ships to show you. Pardon me while I exhibit excessive geekyness.

The first one has translocators on the front. These also are accelerated by the chrono modules, so the ship effectively warps across the screen. The game AI can't maneuver the ship without running in to its own torpedoes, so the Kilo-copy ships can't attack at all. None of the other ships in the game have enough firepower to get through the shields. So this is effectively a game-ending ship; you could leave it running indefinately and nothing would destroy it.
I got bored of the kilo ships destroying themselves through poor navigation skills, so I took off the torpedo launchers. I wanted to see if any amount of fire power could bring down the shields, so I loaded up one side of the ship with prismatic lasers. These fire three beams of the same intensity as the normal ones. Thus, the energy delivered is tripled if you can get close enough to have all three beams hit the target. It does indeed work, but its impossible to keep from completely destroying the target once a shield goes down. I discovered in the process that lasers bounced off blurst shields go back through your own bubble shields. And thus, we have the ultimate peace ship:
Three of them in this picture, in fact. Both the other ships completely knocked out their own offensive capacity by bouncing their lasers of the t-shaped blurst shield arrangement on the front of my ship. I didn't even have to fire. At last, Captain Forever can relax: he's safe.

I'm pretty sure that doubling the bubble shields would also make the ship effectively invincible; there'd be no way to get enough firepower concentrated on it. Well, maybe accelerated torpedoes; but the AI can't use them effectively.

Edit: Ok one more. I had to make it more symmetrical (taking the game AI's persistent advice). You'll notice that just about every available space on the ship is filled, exept for along the right side (I later filled that up). This screenshot captures the demise of a kilo-copy ship; I had to maneuver the other copies to also fire on it to get enough energy concentrated in its shields.
I'm done now, really.