top of page
Search

Module_13

  • Writer: Angela Porcelli
    Angela Porcelli
  • Apr 11, 2021
  • 3 min read

Updated: Apr 11, 2021

Original data: Compare the two sets of codes, and evaluate the contribution of Pickles to run the game in python.


Pickling serializes Python objects into byte streams that can be converted back into the original Python object by unpickling. This process allows for easy transfer of code between servers and systems. With this being my first exposure to pickling, I'm unsure of its benefits versus just saving the file. From what I can gather through online blogs and tutorials if you pickle game code and then terminate Python, when you restart Python and unpickle the code, the game will begin exactly where you left off. Pickling would prevent the user from returning to the game's beginning to get back to the stopping point. If you save the game without pickling and Python is terminated, the player would return to the game's starting point instead of the pausing point upon Python's reboot.


Does this 'pause' feature provide a benefit for users? Maybe. Pickling can be extremely useful in gaming. In other scenarios, I'm not sure the benefits are as pronounced. I did notice that almost every blog and tutorial I reviewed on pickling mentioned never unpickling an object from a source you do not know since the pickled material may contain malicious code. Due to the repetition of this warning from various authors, I assume this is a commonly used method of transferring viruses which makes me wonder if pickling is as beneficial as game coders make it sound.


I used Jupyter Notebook run through Anaconda Navigator to evaluate both game codes.


The first code I looked at was Dr. Alon Friedman's Triangle Peg Game code which utilizes Pickles to run the game.


I was able to run the game using Dr. Friedman's code, but I'm not sure the game was running correctly. I was unable to drag the pegs over one another to imitate a 'jump' used to remove pegs in the physical game. Instead, I was only able to click on the pegs to make them disappear. Clicking on the peg was not a substitute for the jumping action in a physical game since every peg was clickable regardless of the peg's ability to be jumped. I am assuming that this issue is related to the 'Dead Kernel' message I received whenever I click on a peg. It looks like the error has to do with the pickling of the code's rows and columns of the game board.


Next, I tried the game code in chapter 2 of Al Sweigart's book Making Games with Python & Pygames. This attempt didn't go well. I used the following code, but Jupyter keeps throwing a Model Not Found error for Pygame.


conda install -c cogsci pygame

Since I can't get the first line of code to run on Jupyter, I switched over to Visual Studio Code to attempt to run the code. First, I installed Pygame using the code below.


C:\Users\SE.Student\Desktop\LM> python -m pip install pygame

The following message was returned, making me believe Pygame had installed correctly.


Collecting pygame
  Downloading pygame-2.0.1-cp38-cp38-win32.whl (4.8 MB)
     |████████████████████████████████| 4.8 MB 1.3 MB/s
Installing collected packages: pygame
Successfully installed pygame-2.0.1

Even though I received a successful installation message, the same model error message was thrown, as when I tried running Sweigart's code in Jupyter.


ModuleNotFoundError: No module named 'pygames'

Without being able to run Sweigart's code, I cannot compare the two codes for preference. Even if I could run both codes, it would be difficult to say which code was more efficient since these are two different games containing different features.

 
 
 

Recent Posts

See All
Final_Project

Problem description: The goal of graduating with a college degree is to have the ability to choose an employer that will provide an...

 
 
 

Comments


Post: Blog2_Post
  • Facebook
  • Twitter
  • LinkedIn

©2021 by LIS 5937 - Python for Data Science Professions. Proudly created with Wix.com

bottom of page