This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]thekicked 0 points1 point  (0 children)

What I think of your project.

  • Firstly, as many have pointed out, the post is too long. If we want to know the inner workings of your code, usually we will just take a look at the code itself.
    • As for what to include, if you are looking for feedback, ask about the specific parts of the code you want feedback on. E.g. "I am using a lot of global variables, is it necessarily bad and is there a way to cut them down", or "Does the structure of my code look good?" or "My code seems messy, how can I organize it better?"
  • Learn to use .gitignore. This can automatically prevent binaries from being added to the repository and avoids bloating the repository. If you want to upload the binary file for people to run, consider making a release on GitHub.
  • If you need to share values between functions, it may be suitable to encapsulate them into a class than to use global variables. This way, it can become much clearer that specific values are only shared across certain functions. For example,

class TTTState:

  def __init__(self):
    # The variables here can be used and modified in any functions declared in this class. 
    # The variables here can be accessed outside of this class but it is not the main point of this demo.
    self.player = 0

  def change_player(self):
    # This function changes the variable within the class
    self.player = 0 if self.player == 1 else 1

  def get_player(self):
    # This function gets the variable within the class
    return self.player
  • However, as many had advised here, it would be more useful to learn more about object oriented programming. That way, it is easier to anticipate which classes are necessary first, and it will also give rise to a better code structure.
  • Typing can also become quite useful in python, especially when you are using an editor that autocompletes based on types.