Inspiration

The War in Iraq was not handled very well. I always wanted to envision we could have avoided some of the problems we ran into. Probably the biggest reason we failed is that we did not have a unified policy and dealt with people very haphazardly. While this game is not nearly as complex as the war, it is based on the discussions we had together.

What it does

Just a brief mental exercise in coordinating the logistics of allocating soldiers to different provinces. You will need to do damage control when things go bad and capitalize on the good events that knock the enemy off balance.

How I built it

Using the C programming language and regular intake of caffeine in its many, wonderful forms.

Challenges I ran into

Trying to narrow down the list of variables that could be used in-game and what functionalities to include

Accomplishments that I'm proud of

A game that appears simple, but requires a fair amount of long term planning to beat.

What I learned

Using a series of random number generators can create a primitive probability system that is actually quite robust.

What's next for Occupation Video Game

Adding in the other features that had to be cut due to time and a better user interface so it doesn't feel like a 90s Oregon Trail game.

Submission

include

include

include

include

int GarnangHappiness = 25, GarnangInfrastructure = 15; //scale is from 0 - 100 int GarnangInsurgency = 40; int GarnangTroopCount = 20, GarnangAid_Worker = 2, chance = 0;

int TaliaHappiness = 35, TaliaInfrastructure = 20; int TaliaInsurgency = 45; int TaliaTroopCount = 27, TaliaAid_Worker = 6;

int RalkangHappiness = 20, RalkangInfrastructure = 20; int RalkangInsurgency = 30; int RalkangTroopCount = 16, RalkangAid_Worker = 0;

int Approval = 90, Morale = 70, count_bombings = 0, count_sacrifice = 0;

double Bomb(Insurgency, TroopCount) { if (TroopCount < 10 && Insurgency > 5) return 100; //guarantee of bombing //printf("%d\n", Insurgency - (TroopCount * 0.1)); return Insurgency - (TroopCount * 0.1); }

int Sacrifice(Morale) { chance = (rand() % 100) + 60; //printf("%d\n", chance); if (Morale > chance) return 1; //event will occur else return 0; }

int Hideout(Insurgency, TroopCount) { return ((0.75 * TroopCount) + (0.25 * Insurgency)); }

void GarnangProvince(num_troop, num_aidworker) { int bombing_chance, sacrifice_chance, hideout_chance;

GarnangTroopCount = GarnangTroopCount + num_troop;
GarnangAid_Worker = GarnangAid_Worker + num_aidworker;
GarnangHappiness = GarnangHappiness - (GarnangTroopCount * 0.15) + (GarnangAid_Worker * 0.4);
GarnangInfrastructure = GarnangInfrastructure + (GarnangAid_Worker * 0.4) + 1.5;
Morale = Morale + (GarnangTroopCount / 50 * 0.1);
GarnangInsurgency = GarnangInsurgency + ((100 - GarnangHappiness) * 0.1) + ((100 - GarnangInfrastructure) * 0.175) - (GarnangTroopCount * 0.2);

bombing_chance = rand() % 100;
bombing_chance = bombing_chance + 25;
//printf("%d\n", bombing_chance);
if (Bomb(GarnangInsurgency, GarnangTroopCount) >= bombing_chance)
{
    count_bombings = count_bombings + 1;
    if (rand() % 10 > 5)
    {
        chance = rand() % 10;
        GarnangTroopCount = GarnangTroopCount - chance;
        printf("A bomb has exploded outside a Garnang Province military base!\n");
        printf("%d troops were injured or killed.\n", chance);
        Morale = Morale - 3;
        Approval = (Approval - 5) - (0.5 * count_bombings + 0.5);
        GarnangInsurgency = GarnangInsurgency + 3;
    }
    else
    {
        printf("A bomb has destroyed a Garnang Province cafe!\n");
        GarnangHappiness = GarnangHappiness - 2;
        GarnangInfrastructure = GarnangInfrastructure - 4;
        Approval = (Approval - 4) - (0.5 * count_bombings + 0.5);
    }
}
sacrifice_chance = Sacrifice(Morale);
if (sacrifice_chance == 1)
{
    printf("One of your soldiers sacrificed themself to save a civilian in Garnang.\n");
    GarnangTroopCount = GarnangTroopCount - 1;
    GarnangHappiness = GarnangHappiness + 6;
    Morale = Morale - 8;
}
hideout_chance = rand() % 100 + 40;
//printf("%d\n", hideout_chance);
if (Hideout(GarnangInsurgency, GarnangTroopCount) >= hideout_chance)
{
    chance = rand() % 10;
    GarnangInsurgency = GarnangInsurgency - chance;
    printf("Your soldiers have uncovered an Insurgency hideout in Garnang!\n");
    printf("%d enemies captured.\n", chance);
    Approval = Approval + 2;
}

}

void TaliaProvince(num_troop, num_aidworker) { int bombing_chance, sacrifice_chance, hideout_chance;

TaliaTroopCount = TaliaTroopCount + num_troop;
TaliaAid_Worker = TaliaAid_Worker + num_aidworker;
TaliaHappiness = TaliaHappiness - (TaliaTroopCount * 0.15) + (TaliaAid_Worker * 0.4);
TaliaInfrastructure = TaliaInfrastructure + (TaliaAid_Worker * 0.4) + 1.5;
Morale = Morale + (TaliaTroopCount / 50 * 0.1);
TaliaInsurgency = TaliaInsurgency + ((100 - TaliaHappiness) * 0.1) + ((100 - TaliaInfrastructure) * 0.175) - (TaliaTroopCount * 0.2);

bombing_chance = rand() % 100;
bombing_chance = bombing_chance + 25;
//printf("%d\n", bombing_chance);
if (Bomb(TaliaInsurgency, TaliaTroopCount) >= bombing_chance)
{
    count_bombings = count_bombings + 1;
    if (rand() % 10 > 5)
    {
        chance = rand() % 10;
        TaliaTroopCount = TaliaTroopCount - chance;
        printf("A bomb has exploded outside a Talia Province military base!\n");
        printf("%d troops were injured or killed.\n", chance);
        Morale = Morale - 3;
        Approval = (Approval - 5) - (0.5 * count_bombings + 0.5);
        TaliaInsurgency = TaliaInsurgency + 3;
    }
    else
    {
        printf("A bomb has destroyed a Talia Province bar!\n");
        TaliaHappiness = TaliaHappiness - 2;
        TaliaInfrastructure = TaliaInfrastructure - 4;
        Approval = (Approval - 4) - (0.5 * count_bombings + 0.5);
    }
}
sacrifice_chance = Sacrifice(Morale);
if (sacrifice_chance == 1)
{
    printf("One of your soldiers sacrificed themself to save a civilian in Talia.\n");
    TaliaTroopCount = TaliaTroopCount - 1;
    TaliaHappiness = TaliaHappiness + 6;
    Morale = Morale - 8;
}
hideout_chance = rand() % 100 + 40;
//printf("%d\n", hideout_chance);
if (Hideout(TaliaInsurgency, TaliaTroopCount) >= hideout_chance)
{
    chance = rand() % 10;
    TaliaInsurgency = TaliaInsurgency - chance;
    printf("Your soldiers have uncovered an Insurgency hideout in Talia!\n");
    printf("%d enemies captured.\n", chance);
    Approval = Approval + 2;
}

}

int RalkangProvince(num_troop, num_aidworker) { int bombing_chance, sacrifice_chance, hideout_chance;

RalkangTroopCount = RalkangTroopCount + num_troop;
RalkangAid_Worker = RalkangAid_Worker + num_aidworker;
RalkangHappiness = RalkangHappiness - (RalkangTroopCount * 0.15) + (RalkangAid_Worker * 0.4);
RalkangInfrastructure = RalkangInfrastructure + (RalkangAid_Worker * 0.4) + 1.5;
Morale = Morale + (RalkangTroopCount / 50 * 0.1);
RalkangInsurgency = RalkangInsurgency + ((100 - RalkangHappiness) * 0.1) + ((100 - RalkangInfrastructure) * 0.175) - (RalkangTroopCount * 0.2);

bombing_chance = rand() % 100;
bombing_chance = bombing_chance + 25;
//printf("%d\n", bombing_chance);
if (Bomb(RalkangInsurgency, RalkangTroopCount) >= bombing_chance)
{
    count_bombings = count_bombings + 1;
    if (rand() % 10 > 5)
    {
        chance = rand() % 10;
        RalkangTroopCount = RalkangTroopCount - chance;
        printf("A bomb has exploded outside a Ralkang Province military base!\n");
        printf("%d troops were injured or killed.\n", chance);
        Morale = Morale - 3;
        Approval = (Approval - 5) - (0.5 * count_bombings + 0.5);
        RalkangInsurgency = RalkangInsurgency + 3;
    }
    else
    {
        printf("A bomb has destroyed a Ralkang Province library!\n");
        RalkangHappiness = RalkangHappiness - 2;
        RalkangInfrastructure = RalkangInfrastructure - 4;
        Approval = (Approval - 4) - (0.5 * count_bombings + 0.5);
    }
}
sacrifice_chance = Sacrifice(Morale);
if (sacrifice_chance == 1)
{
    printf("One of your soldiers sacrificed themself to save a civilian in Ralkang.\n");
    RalkangTroopCount = RalkangTroopCount - 1;
    RalkangHappiness = RalkangHappiness + 6;
    Morale = Morale - 8;
}
hideout_chance = rand() % 100 + 40;
//printf("%d\n", hideout_chance);
if (Hideout(RalkangInsurgency, RalkangTroopCount) >= hideout_chance)
{
    chance = rand() % 10;
    RalkangInsurgency = RalkangInsurgency - chance;
    printf("Your soldiers have uncovered an Insurgency arsenal in Ralkang!\n");
    printf("%d enemies captured.\n", chance);
    Approval = Approval + 2;
}

}

int main() { printf("Nissinia was once feared as the greatest menace to civilization under their\n"); printf("Eternal Great Leader. However, they overstepped their boundaries and made\n"); printf("one threat too many against your country. One brief war later and your country\n"); printf("controls its broken remains. As the invading general, you are the\n"); printf("de facto leader and will determine the future of Nissinia.\n\n"); printf("However, rebuilding this land takes time and already there is talk of an\n"); printf("'Insurgency' against your country's control. At the same time, the Nissinians\n"); printf("are unhappy under foriegn occupation and your countrymen call for their sons to\n"); printf("return home. If Nissinia is to never threaten your people again, you must\n"); printf("rebuild this country, with the support of its people and crush the Insurgency.\n\n"); printf("Good luck general, you will need it.\n\n");

int count = 0;
int num_troop_garnang, num_aidworker_garnang;
int num_troop_talia, num_aidworker_talia;
int num_troop_ralkang, num_aidworker_ralkang;

//char select[30];
srand((unsigned)time(NULL));

/*printf("Select a region to view: \n");
printf("       Garnang\n");

scanf("%s", &select);

if (strcmp(select, "Garnang") == 0)*/

while (Approval > 25)
{
    printf("Garnang Status: \n");
    printf("   Happiness - %d%%\n", GarnangHappiness);
    printf("   Infrastructure - %d%%\n", GarnangInfrastructure);
    printf("   Troop Count - %d\n", GarnangTroopCount);
    printf("   Aid Worker Count - %d\n", GarnangAid_Worker);
    printf("   Insurgency - %d\n", GarnangInsurgency);

    printf("\nTalia Status: \n");
    printf("   Happiness - %d%%\n", TaliaHappiness);
    printf("   Infrastructure - %d%%\n", TaliaInfrastructure);
    printf("   Troop Count - %d\n", TaliaTroopCount);
    printf("   Aid Worker Count - %d\n", TaliaAid_Worker);
    printf("   Insurgency - %d\n", TaliaInsurgency);

    printf("\nRalkang Status: \n");
    printf("   Happiness - %d%%\n", RalkangHappiness);
    printf("   Infrastructure - %d%%\n", RalkangInfrastructure);
    printf("   Troop Count - %d\n", RalkangTroopCount);
    printf("   Aid Worker Count - %d\n", RalkangAid_Worker);
    printf("   Insurgency - %d\n", RalkangInsurgency);

    printf("\nOverall Troop Morale - %d%%\n", Morale);
    printf("Public Approval - %d%%\n", Approval);

    printf("\nTroop allocation for Garnang: ");
    scanf_s("%d", &num_troop_garnang);
    printf("Number of international aid workers to send to Garnang: ");
    scanf_s("%d", &num_aidworker_garnang);

    printf("\nTroop allocation for Talia: ");
    scanf_s("%d", &num_troop_talia);
    printf("Number of international aid workers to send to Talia: ");
    scanf_s("%d", &num_aidworker_talia);

    printf("\nTroop allocation for Ralkang: ");
    scanf_s("%d", &num_troop_ralkang);
    printf("Number of international aid workers to send to Ralkang: ");
    scanf_s("%d", &num_aidworker_ralkang);
    printf("\n");

    GarnangProvince(num_troop_garnang, num_aidworker_garnang);
    TaliaProvince(num_troop_talia, num_aidworker_talia);
    RalkangProvince(num_troop_ralkang, num_aidworker_ralkang);
    printf("\n");

    count++;
    if (count > 8) break;
}

printf("\n");
if (GarnangInsurgency + TaliaInsurgency + RalkangInsurgency >= 300)
{
    printf("Ending 1: \n");
    printf("  Nissinia is taken over by the insurgency who installs a new\n");
    printf("  oppressive government and kills everyone who disagrees with their doctrine. \n");
    printf("  It is the beginning of a long period of violence.\n");
}
else if (GarnangInfrastructure + TaliaInfrastructure + RalkangInfrastructure <= 150 && Morale < 50)
{
    printf("Ending 2: \n");
    printf("  Formerly occupied Nissinia is propped up by your aid and corruption flourishes. \n");
    printf("  When you finally stop supporting them, they will fall to the Insurgency.\n");
}
else if (GarnangHappiness + TaliaHappiness + RalkangHappiness <= 150)
{
    printf("Ending 3: \n");
    printf("  The Nissinian civil war rages with neither side able to \n");
    printf("  gain a decisive advantage over the other.  As with all wars, the ultimate \n");
    printf("  losers are the people of Nissinia.\n");
}
else
{
    printf("Ending 4: \n");
    printf("  Nissinia becomes a free democracy with an enlightened public and a ");
    printf("  faithful ally to your country.  You support each other for many, many years.\n");
}

printf("Congrats!  You survived for %d turns.\n", count);

}

Built With

Share this project:

Updates