SLE: ruminations on alternate constructors for selectors.

Nov 22, 2012 02:34

For the boy's eyes alone, perhaps. This is supposed to be a journal of sorts, after all. But if it makes any damn sense to you whatsoever, go ahead and comment. I'm not gonna go to a lot of trouble to supply context at the moment, but I might do so later.

Anyway, I just scratched an alternate constructor I had for WeightedSelector to allow subversion of the usual weighting mechanism, the classes' sweight fields. Instead, all selectors have an alternate constructor interacting with the CollectibleMeta metaclass to create same-type selectors from the collected trees. I might make the revisions to delegate all that mumbo-jumbo to the selectors and let the metaclass mellow out.

Ad hoc reweightings of classes for weighted selectors can be achieved without some dumbass ad hoc subversive alternate constructor. As I've thought about it, the best way to do so would be to construct it with the standard constructor, but after temporarily changing the sweight fields of the desired classes. This can be trivialized by a context manager which automatically restores the original sweight values upon exit. If I feel this is actually of any use, I should provide such a context manager in the API. The implementation might be inelegant, but this whole enterprise of ad hoc weighting is inherently inelegant anyway, so I shouldn't worry so much about it.

Derrr…

soulthieves labyrinth engine

Previous post Next post
Up