How would you code a settlement management game?

I’ve had an idea for a settlement management game, and was wondering how to approach some of the coding.

If you’ve written anything similar, or just happen to be awesome at coding, would you mind letting me know the best way of writing the following?

  1. You control a settlement of 100 people: 20 warriors, 20 hunters and 60 villagers. You can assign these people to activities each week. Once people have been assigned to an activity, they can’t be assigned to anything else that week.
  2. This week, there’s a mission to rescue some farmers who are under attack from goblins. If the player wants to do it, then they need to send between 10 and 40 people. For example, the player might choose to send 10 warriors, 5 hunters and 3 villagers. Those people won’t be available for any other activities this week.
  3. The player also has the option of leading the mission. If they do, then they can’t do anything else that week.
  4. If you send less than 20 people on the mission then the goblins attack them.
  5. You need a total combat strength of 40 to beat the goblins, or the mission fails. Each Warrior has a combat strength of 3, each Hunter has a combat strength of 2, and each Villager has a combat strength of 1. The player also adds their own Combat stat to their side’s combat strength of they led the mission.
  6. If you lose the combat, then each person you’ve sent has a 10% chance of dying. They’re removed from the settlement population, and aren’t available for future missions.
  7. If you win the combat then each person you’ve sent has a 5% chance of dying.
  8. If you win the combat then each Villager you’ve sent has a 10% chance of levelling up and becoming a Warrior instead.
  9. If the mission succeeds then you get another 10 Villagers, who are available to be deployed for missions from the next week onwards.

Why don’t you check out: Fief -- a manor-mangement sim

The great thing about code is that there is no one way to write it, you can do whatever suits your needs best. I appreciate how it hard it can be to find a starting point though, hence linking you to the game above, maybe that will help to inspire you.


Yep, there’s no best way to write a code.

I would say, there’re several “phases” when you’re coding for something. But I can see you passed the first phase; envisioning your program.

Take it slowly, do trials and errors, and make variables as you need it.
And if you think your code is too big to handle, you can make a flowchart diagram of it. I use, personally.


I wouldn’t say that exactly. There is often better ways to do things, whether that’s for performance (not massively important for CS) or organisation (very important for CS), but it tends to vary heavily on an individual projects needs and use-case.

Very good suggestion though! Visualizing tools are your friend :slight_smile:


Ey, that’s what I see as the “no best way”. :sushing_face:

1 Like

Sure, I didn’t mean to call you out, I just think it’s important to that we encourage people to take pride in their code quality. Well written code is easier to maintain (and for others to learn from, and help you with!).


My best advice to you. Both research how historically settlements were settled and also look at their mythological origins. Or something more contemporary I going back to the 17th or 18th century.

1 Like

…the question was how to code a settlement management game. :sweat_smile:



Nah, easy :raised_hand_with_fingers_splayed:t4:
It’s all good fun. No offense taken.

(although I admit I always jump on my seat when I see a notification of somebody mentioned me)

1 Like

Now going back to topic

1 - I think for the first one I will create three types of variables - base variable and work variables and left variables - here we are going to work with warriors

the base variables is the total number of warriors we have

work variables is the number of warriors that are unavailable because they are off to work.

And another variable named warriors left which shows number of warriors that we have left.

Total variables for warriors - Base_Warriors

At the starting of week every week -

`*set Base_Warriors ( Work_Warriors + Warriors_Left )

Note : work is total of all work variables subtract the casualties from the place they have taken place and from base to immediately show effect

Ex - if 20 Warriors left and 15 returned subtract 5 from work_warriors and from base_warriors

2 - use the system above

3 - use a goto command and woosh. End it where you want

4 - here when you ask them to send people in addition to adding and subtracting from work and left variables - you create some temp variables that hold the values of the number of people that are assigned to this job and later you add those variables

Note : choice script can handle only two variables at a time so you have to do it like this

*set total_people_off_to_village_rescue ((variable1 + variable2) + variable3)

5 - you have those temp variables that have the number of people we have sent - multiply them with the strength of that type and add all of them and put a stat check on the total strength. Set a variable true if the stat check passes and false if it fails (let’s call that variable - Check )

6, 7, 8 - they are done the same way and I am on phone and this is hard to do on phone so will post the solution tomorrow morning.

9 - remember that variable that we set true ( the one which was set true when the power was more than 40 )

Now if that variable is true

*set Villagers_Left +10

1 Like

Of you have problem reading the huge mess above - I swear it was way more organised in my head.

I suck at explaining :sweat:

Thank you for all for the advice.

@DUNGEON_MASTER That’s incredibly helpful, thanks! I’m sure you’ve saved me a lot of trial and error.

@Rogar Cheers - I’ve got a reasonably good idea of how Medieval societies worked, although community feedback can always be helpful. However, this one’s likely to be more of a fantasy game.


Raw!! Well the question is how are you working the high fantasy element in.


What you describe sounds almost exactly like the system Choice of Rebels uses for the Winter portion of the game. Maybe you should just get that and look how @Havenstone did it to glean some inspiration?

1 Like

@Rogar At the moment, I’ve got a couple of competing ideas for games. The first would be a merchant princes / frontier exploration sort of game, with an exiled noble and their retinue carving out a new domain in the borderlands. The second would be more dark fantasy, with a small community struggling for survival and mastery of their environment in a post-apocalyptic realm beset by demons and the unquiet dead.

@Spire That’s a good shout - I’ll admit that Choice of Rebels was definitely an inspiration. How would I view the game files now that it’s been published? I bought it through the Apple Store.

1 Like

Oregon Trail source code! (apparently)

1 Like

I got a good one take influence the Greek method of colonization. It’s a fusion of culture religion and mysticism along with some really is crazy stuff.

@Carlos.R l ways wanted to actually play as the Homesteader once you got there and go through the hard process of building a life in Oregon. They literally left the tale half finished.

I’m not sure but some searching on here might turn up an answer. An Android APK you can just pull to a computer and open like a JAR file, giving you all the relevant TXT files that contain the game code. I’d assume whatever Apple uses to pack their install files works similar.

1 Like

Naw bro, then they would have had to call it “Oregon Settlement” instead of “Oregon Trail” :wink:

1 Like