It’s Party Time

Dear Tim,

Kalmany has been running for over a month and now I’m gearing up for a proper minor update – the Party Update. Soon, Kalman Politicans will be forming, joining, and working together in political parties in a random fashion alike the rest of their government. What will this mean for the coding? Well it’s going to mean a lot of modifications.

First off is our definitions of what a party is. I’ve got, in Kalmany fashion, an abstraction, and our parties will contribute in a couple of fashions:

  • A political party in Kalmany is a group of individuals who align in some political ideals, but agree to represent a certain demographic of Kalmany. These are defined by the party’s sympathies, a term given to a grouping based off citizen attributes. Each party will have five sympathies that define the specific group that the party will be trying to represent. Each group will include one zodiac sympathy, and then the rest could be any attribute in the citizen definitions – age, industry, religion, anything!
  • The party will have its own political platform consisting of ten policies that will display alongside their personal platform. These actually don’t mean anything to the citizens of Kalmany – being very short-sighted, they will instead look at the merit of the party in being their spokesperson. After all, they have my interests at heart, I’m sure they’ll speak to my opinion appropriately! In the same way someone may align to Labour in the UK if they’re leftist, without really looking at the individual that will represent them.
  • In an assembly, a member of parliament will be acting either on their own accord, or as a whip for the political party. This means, they will either bring their own personal policy to the assembly, or one of their party’s, and when voting they will either vote based off their own preference, or their party’s. To give it an edge, a discussion will have no impact on their decision if they are voting for their party’s preference. Because a party has goals and they will ignore any and all say-so to make sure it comes to fruition.

Now how does a party form? I struggled on this question for a few days. I originally had a script to form them based off frustrated members of parliament, grouping together, and forming a party together. Now I’ve rewrote it and simplified it to something that still makes sense.


stmt = sqlalchemy.sql.text("""SELECT c.citizen_attribute, \
c.attribute_value, \
SUM(c.pref_value) as pref_value_sum, \
RAND() as random_seed FROM ( \
	( \
    SELECT citizen_attribute, attribute_value, SUM(preference_value) as pref_value \
    FROM policies_preferences pp \
    WHERE pp.policy_id IN (%s) \
    GROUP BY citizen_attribute, attribute_value \
    )  \
	UNION  \
    ( \
    SELECT citizen_attribute, attribute_value, -SUM(preference_value) as pref_value \
    FROM policies_preferences pp \
    WHERE pp.policy_id IN (%s) \
    GROUP BY citizen_attribute, attribute_value
    ) \
) c \
GROUP BY citizen_attribute, attribute_value \
ORDER BY pref_value_sum DESC, random_seed""" % (','.join(forPolicies), ','.join(againstPolicies)))

I don’t like writing SQL in Python as it should be programmatically possibly with sqlalchemy, but this query got complicated. You see, what this does it considers the end result of an assembly and takes all policies that failed and all policies that passed. Then, for each failed policy, we take it as is, but reverse the foa value for the passed policies.

Why do I do this? Because then I get, basically, the reverse result of an assembly. What would have happened if everyone voted the other way (sort of – a passed policy wouldn’t have been passed, but it’s more like an extreme opposite. What would have happened if the “opposition” in every argument was successful.) And this is important because then this query performs a correlation on these to the policy preferences.

The policy preferences up until this point have always been used to determine how much a citizen agrees with a policy. But the awesome thing is it also works in reverse. It determines who agrees with a policy as well. If I sum over a few policies, I get who agrees with a selection of policies. And if I take the reverse of an assembly result and get who agrees with the reverse, I obtain a simplified idea of who is frustrated at the result of an assembly! What demographic is pissed at what was passed. Who didn’t want what has been passed. This is key – political parties in Kalmany will be born from frustration.

Using the result of the above query, I take the top five to make up a new party’s sympathies. I also double check to ensure that no existing party has anymore than four of the same sympathies. They can share up to three of the same sympathies with a party that exists, but any more and it becomes mute.

And then I form a party! What’s curious about this is that, in the logic, we’ve formed a party with no members. That’s okay, because this allows my loops logic to work a little easier.

When an election is being prepared, we’re looping through every candidate and deciding if they should stand for election. We’re also going through each citizen, and if they hate every candidate, they’ll run for themselves. And this is the perfect time for a citizen to determine whether they’ll join a party or not.

And as they are basing their logic off the party itself, I leave off the generation of a party’s political platform. Only after we’ve determined if anyone is actually part of the party do we generate their platform. If there’s less than three people, the party gets dissolved, so even if we generate a party at the end of an assembly, if they can’t get three people to join in the next election the party will dissolve and cease to be. If they can, the party gets a platform, and we see a new party join the foray.

So the politics are going to get more complicated now. I am in the process of writing the logic in the assembly to determine if a member of parliament acts a whip or not. After that, we’ll have our assembly grid update so it reflects the party colour. We’ll also look at the election graphs using the party colours too so they reflect them better. It’s going to be an interesting change and will surely change how policies pass or which ones pass. The frustrated voters will soon see themselves with more power and who knows! Maybe we’ll end up in a two party system shortly.

One concern I have with the logic is there’s no limitation on how many sympathies of an attribute can be accrued. There are four age groups. It could be very easy for a party to amass all the age groups. However, who knows what they’ll actually act like as a lot of policies are divisive among age groups.

Anyway, I hear you’re in the arctic now trying to stop something rising from the ice. I would suggest wrap up warmly but I can see from the GPS feed you’ve been making a lot of bonfires. I think I understand the message and I’ll be directing the Brazilian government to take action and send you the helicopter you need and the seventy-metres of iron chains. I hope you get there before it breaks loose and can capture it. If you do capture it, send me a selfie – it’s been a while since I’ve seen your face.

Yours,
Stan

Leave a comment