Something is odd with the bonus adding (my code does not behave as I would expect)

tndp

Chieftain
Joined
Nov 1, 2005
Messages
16
Okay, I've tried two test impementations of addBonusType(argsList) - one of them does exactly what I expect, and one of them does not.

This one works like a charm:
Code:
def addBonusType(argsList):
	return None # The default handler is not to place any more of this type.

You guessed it: no bonuses (Archipelago has some later check that sprinkles them next to start locations - which threw me for a bit - but on other maps, no bonuses at all). An important control.

Now, what I would *expect* for this next one to do is : whatever bonus gets added first, it would get added *everywhere*. Note that the plot legality check is commented out. Instead, what you get is a more or less normal map, maybe with more bonuses on it, maybe not. It seems (I'm doing these experiments in Archipelago.pl) that the resource preferences of individual islands are somehow preserved - but I don't even know how those work yet, so obviously I can't be sure. It SEEMS that uncommenting the two lines with the canHaveBonus call has no effect whatsoever - but again, have only made a few random maps, can't be sure. Notably, no matter what I do, I never get bonuses next to eachother, but the fiddle with start locations is capable of adding adjacent bonuses. Anyone know what function the start location fiddler calls to add bonuses?

I should note that while I know python, I do not know it *well*, so if I've made a mistake there, please point it out.

Code:
def addBonusType(argsList):
	count = 0
	eligible = []
	for x in range(iW):
		for y in range(iH):
			# First check the plot for an existing bonus.
			pPlot = map.plot(x,y)
			if pPlot.getBonusType(-1) != -1: continue # to next plot.
			# Check plot type and features for eligibility.
			#if (pPlot.canHaveBonus(iBonusType, True)): pass
			#else: continue # to next plot.
			#
			# Finally we have run all the checks.
			# 1. The plot has no bonus.
			# 2. The plot has an eligible terrain and feature type.
			# 3. The plot is in one or more eligible regions.
			# Now we append this plot to the eligible list.
			eligible.append([x,y])
			count = count + 1

	# Now we assign the bonuses to eligible plots chosen completely at random.
	while count > 0:
		if eligible == []: break # No eligible plots left!
		index = dice.get(len(eligible), "Bonus Placement - Oasis PYTHON")
		[x,y] = eligible[index]
		map.plot(x,y).setBonusType(iBonusType)
		del eligible[index] # Remove this plot from the eligible list.
		count = count - 1  # Reduce number of bonuses left to place.
		# This bonus type is done.
	return None # The default handler is not to place any more of this type.
 
Back
Top Bottom