My Cumulative Project – Technical Aspects

My cumulative project was a Trouble in Terrorist Town game. It’s a Mafia game that goes around any copyright that may be around the title of Mafia. Even though it can be a little slow and gets repetitive after a little bit, I still think it’s pretty fun to play.

In order to make this program be able to run smoother, I had to learn how to learn how to use a dictionary in Python. A dictionary is similar to a list, but it is unordered and rather than only using a single value element like most data types it has two values (key:value). Along with the dictionary, I had learn how to use the ‘keys’ function that runs with a dictionary. The keys function will only at the key of the elements in the dictionary rather than at both the key and the value together.

I learned how to use the dictionary function so that I would have an easy-to-store list of all the citizens for the randomizer to be able to choose from for both the terrorist and victim. The keys function was what made it possible for me to randomly choose a citizen from the dictionary.

 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
def start_game():
    """Set the logistics to get the game running here."""
    # 1=Rose, 2=Joe, 3=Mary, 4=Lucy, 5=Ray, 6=Scottie, 7=Junior, 8=Jen
    # 9=Kara, 10=Alyssa, 11=Nigel, 12=Rich, 13=Karma, 14=Sean, 15=Brian
    citizens = {'Rose':1, 'Joe':2, 'Mary':3, 'Lucy':4, 'Ray':5, 'Scottie':6,
                'Junior':7, 'Jen':8, 'Kara':9, 'Alyssa':10, 'Nigel':11,
                'Rich':12, 'Karma':13, 'Sean':14, 'Brian':15}
    #
    # Set a random citizen as the terrorist.
    #
    terrorist = random.choice(list(citizens.keys()))
    return terrorist, citizens

This is where I created the dictionary and had the program randomly choose the terrorist. The name of the dictionary is “citizens”, and everything inside of the curly brackets are the elements of the dictionary. In order to randomly choose a terrorist, I created a variable named ‘terrorist’ and set it to equal a random name from the list of the keys in the dictionary.

 

Also with this post I am supposed to include a piece of code that makes me cringe. So, I would like to place a cringe warning, because if it can get me, a relatively uncringing person, to cringe, it’ll almost certainly make you as well.

1
2
3
4
5
6
7
8
9
def congratulations():
    """Congratulate the user on guessing the terrorist."""
    sleep(1.7)
    print()
    print()
    #
    # Congrats, user, on making it through the repetitiveness of this game!
    #
    slow_print("Congratulations, Sheriff! You solved the mystery!")

This part really annoys me because I didn’t bother to try and make any sort of an interesting congratulatory message for the player when they win, rather I just went for the standard “print this congrats message” rather than trying to put in a little bit of creativity to make it seem much more interesting. I’m not so much cringing at the idea of congratulating the user as I am at the fact that I didn’t bother to put in any effort for such a simple task.

1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
def trial(terroristGuess, victim):
    """Run the trial here."""
    #
    # The repetetive text of the trials goes here.
    #
    terroristGuess = name_of_number(terroristGuess, citizens)
    slow_print(f"""

 Judge: Today, we are gathered here to discuss the death of {victim} last night.
        The Sheriff would like to bring up {terroristGuess} for questioning.

{terroristGuess} makes their way to the front, standing, ready to give their alibi.

   You: {terroristGuess}, last night {victim} was found dead. Where were you?
""")
    return terroristGuess

This part of my code was a bit frustrating. Yes, it is very simple right now. But while I was doing it, I tried to make it so that it wouldn’t be the exact same trial over and over again, but everything that I tried to make it do that failed. I was really frustrated, so I decided to just settle and have it be the same trial every time, although I wish I could have found a way to worked to have it be different every time.

Even though the whole code doesn’t work exactly how I wish that it would, I’m still pretty proud of it and I’m glad that I decided to make this game. I don’t think that I would have been as happy with myself if I hadn’t have chosen to make a Trouble in Terrorist Town game, because this challenged me just enough that I learned but was still within my ability. And I’m really happy with how it turned out and that I’m able to play and use it, even if it isn’t the best game in the world.

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Comments

  • Margie Main on Solar EclipseVery well done! So descriptive that I almost didnt need the pic!