Oh, hey! I’m an aspiring programmer

Hello all,

In this post I’m sharing with you the first game I ever programmed using Python. It is quite simple and there’s unfortunately no graphical user interface (I’ve been too lazy to built it…). What this means is that if you want to run the program , there’ll be no executable (.exe) file to do so. I’ll explain it better further ahead. The game consists of a tiny set of rules:

• Each player adopts the role of a protein activator or inhibitor
• Activated proteins are RED and inactivated proteins are GREEN
• Proteins can reverse the state of different-colored proteins, if the latter are framed by the former
• The goal of the game is to get the highest possible number of active or inactive proteins, i.e, to reverse the color/state of the highest amount of proteins of the opponent. This gives the final scoring points.
• The game ends when there are no more possible moves for a player.

I thought about sharing this with you, because I believe some of you might be interested in this sort of things and because I’m pretty proud of this tiny accomplishment. Also, it’s a pretty nice game to play if you’re really really bored. Below I will share a link to a google drive containing two files: 1) a python (.py) file and 2) a pdf file containing an explanation on how to run the game.

If you’re interested in playing the game this is how you do it: first, make sure you have a unix operating system available (e.g., ubuntu, debian). If not, I think I may be able to change it to run on Windows, but I’m a bit lazy to do so and I loathe Windows at the moment. After this step, create a folder and place the python file inside it > Open a command line terminal  (in ubuntu you press ctrl + alt + t, for example) > write cd [path to file] (e.g., cd /home/Documents/python_game. Please, take into account this is a relative path and it will depend on how YOU have named the folder!).

Now you should be inside the folder containing the file. To run the game you must have Python 2.7 installed (don’t install newer versions, because they changed some useless things and it probably won’t run). After you’ve installed Python just write in the command prompt python moriarty_final.py. Don’t forget you need to be inside the folder that contains the file!

Now you can enjoy the game, by playing against the computer (I coded it to be pretty smart and I have a hard time beating it myself even though I know what the algorithm is doing so, good luck ahah) or against another player in the same computer =)

I hope you’re able to set it up, but if not and if you’re interested in this, please write me and I’ll try to help you out ^_^

Here is the link: https://drive.google.com/open?id=0B2szTQBTbCutZ0tYX0dkdVI4NkE

Cheers!

Marta

6 Replies to “Oh, hey! I’m an aspiring programmer”

  1. omg a protein game, that’s so cool. When I run it the lay-out seems to get fucked up, instead of printing ‘RED’ or ‘GREEN on the game grid it print something like [91mR[0m which then messes up the rest of the grid because the string is too long so stuff is no longer alligned :'(

    Any ideas on how I could fix this? I’m running it on 2.7

    1. Yep, that’s what I said before, I coded the game to run on Unix and I know there are some issues when “translating” the code to Windows. I added some lines of code to moriarty_final.py, so you can try downloading it again. You just have to install the library first by writing this command, if I’m not mistaken: pip install colorama. If pip doesn’t work you’ll probably have to download the get-pip.py file (here: https://bootstrap.pypa.io/get-pip.py) and then run the command python get-pip.py (remember that to run the scripts you need to be in the same location where the file is located or provide their relative path)… But I’m sure this game isn’t worth all this effort! XD

Leave a Reply

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