I made a 🐍Snake AI 💻
DynamicSquid (5029)

[ currently broken :D ]


I made Snake. You can control it using WASD, or the arrow keys. Eat the red apples, and don't crash into the walls or yourself!


When you press space, it uh... helps you out a little :)


You are viewing a single comment. View All
fuzzyastrocat (1867)

@DynamicSquid You could add:

  • Some kind of interesting memory management paradigm. Perhaps ownership-style?
  • A type system like Haskell's, where you can pass types to functions as if they were normal values. Basically, making types "first-class citizens".
  • Multiple dispatch. This one is neat, I'd highly suggest it. Basically, in most OO langs you have single dispatch — when I call my_var.some_function, the some_function I'm calling depends on the type of my_var. Well, what if the function depended on the types of all arguments? So, instead of doing:
def my_function(x, y, z):
  if type(x) is int and type(y) is str and type(z) is int:
    # stuff 1
  elif type(x) is str and type(y) is int and type(z) is str:
    # stuff 2
  # etc etc

You do something like:

def my_function (x: int, y: str, z: int):
  # stuff 1

def my_function (x: str, y: int, z: str):
  # stuff 1    

# etc etc

And obviously, you don't have to give a type — doing def x(y): would apply to y of any type.

More info on multiple dispatch can be found here.