I greatly fear disrupting the code of a stable program. A large number of decisions have gone into the current form of the program, and it’s all too easy to look at a section of code and figure out how to change it without realizing the extended implications of that change. I suppose that well-segregated code should be immune to this problem, but my years of working with simple procedural languages has imbued a deep-seated fear of the possible entanglements arising from any piece of code.
So I started off changing the way that Actors move around in Siboot, and this has led me to all sorts of modifications. I am currently struggling with the initialization process — which starts off by placing Actors on Stages — and wanted to look at the automatic assignment of pValues and cValues for Actor Traits. This all works well for emotional traits like pTruthful, pGood, and pPowerful, but it’s completely different when applied to the perceived aura counts. I want these to be actual information about objective truths (which, I suppose, applies equally well to all pValues), but I just now discovered that the adjustment (based on Accordance values) is made at all times. I had assumed that it is used only at initialization, but in fact it is used all the time.
This has devastating implications. It means that pValues can NEVER change based on experience. If pTrait(A, B) = 0.3, there’s no point in changing its value, because when the system needs to look up pTrait(A, B) again, it will simply regenerate it from its true value, the Accordance value, and the Stranger_Kin value.
Miser mea! What am I to do now? I suppose that I shall have to declare all those variables to be “not system-assigned”. But that in turn requires me to calculate them during initialization. Arg! I am already burdened with this absurd initialization system requiring some 56 Events to occur, during which time each Actor and each of that Actor’s relationships are initialized. I need something built into the engine that does this automatically at game initialization.
So what if there were an operator that initialized pValues and cValues based on — what? The only things that vary from game to game are 1) which Actor the human plays; and 2) the initial values of the aura counts. The operator would be something I custom-build in the Interpreter that handles all that crap. I just call it once from “once upon a time” and I’m done with it.
But it is not to be. It turns out that I cannot write a simple Java loop that initializes the values, because I can’t figure out how to burrow through the many layers of abstraction required to get to a single trait value. The value I want to reach is of class FloatTrait, which is an extension of class Trait, which is accessed through a PropertyMap which is private to the class Actor. The system accesses these traits through their specific Operators, which themselves are changeable and therefore accessed abstractly. If I took the time to figure out how the whole system worked, I could gain access to it, but just now it makes my head spin. So I’m looking for a simpler way of effecting the solution.
Afternoon:
Well, I cracked the basic problem, fighting my way through layers of indirection to get to the heart of the problem. Sheesh, modern programming operates with more subtle abstraction than I’m used to; I truly am a dinosaur. Anyway, I did manage to get through to a solution of sorts, so I’m back in business. Before I could proceed, however, I needed to solve another problem, and algorithmic one that proved to be much harder than I had expected. Perhaps I’m just getting stupid as I grow old. Anyway, here’s the problem:
You have six apples to distribute among 3 children. They must be distributed randomly, with the constraint that no child get more than 3 apples. It is perfectly acceptable for one child to receive no apples. I was able to solve the problem with three statements. How good a solution can you find?