Skip to main content
deleted 1 character in body
Source Link
toolic
  • 15.7k
  • 5
  • 29
  • 216

UX

When I run the code, it launches a GUI, but it is not clear to me what I should do to play the game. Typically, 2048 uses the 4 arrow keys on the keyboard, but that did not work. It seems like it is necessary to click and drag with the mouse.

It would be helpful to add instructions to the GUI.

Naming

The variable named n is not very descriptive:

def __init__(self, n):

I think it is the number of squares on a side in the game board. The variable should be named something like num_of_squares.

In CellObject, ec and fc could be more descriptive as well.

In App2048, you should describe the purpose of the cells_2 array. You could add some comments that distinguish it from the cell array.

Documentation

The PEP 8 style guide recommends adding docstrings for classes and functions to describe their purpose.

Tools

ruff finds several instances of this:

E702 Multiple statements on one line (semicolon)

 |         self.axes.set_xlim(0, n+1); self.axes.set_ylim(0, n+1)
 |                                   ^ E702

The black program can be used to automatically separate those into individual lines. It can also help you see the structure of those dense go_up, go_down, etc., functions which seem to share some commmoncommon code. Perhaps some of that code can be factored out.

UX

When I run the code, it launches a GUI, but it is not clear to me what I should do to play the game. Typically, 2048 uses the 4 arrow keys on the keyboard, but that did not work. It seems like it is necessary to click and drag with the mouse.

It would be helpful to add instructions to the GUI.

Naming

The variable named n is not very descriptive:

def __init__(self, n):

I think it is the number of squares on a side in the game board. The variable should be named something like num_of_squares.

In CellObject, ec and fc could be more descriptive as well.

In App2048, you should describe the purpose of the cells_2 array. You could add some comments that distinguish it from the cell array.

Documentation

The PEP 8 style guide recommends adding docstrings for classes and functions to describe their purpose.

Tools

ruff finds several instances of this:

E702 Multiple statements on one line (semicolon)

 |         self.axes.set_xlim(0, n+1); self.axes.set_ylim(0, n+1)
 |                                   ^ E702

The black program can be used to automatically separate those into individual lines. It can also help you see the structure of those dense go_up, go_down, etc., functions which seem to share some commmon code. Perhaps some of that code can be factored out.

UX

When I run the code, it launches a GUI, but it is not clear to me what I should do to play the game. Typically, 2048 uses the 4 arrow keys on the keyboard, but that did not work. It seems like it is necessary to click and drag with the mouse.

It would be helpful to add instructions to the GUI.

Naming

The variable named n is not very descriptive:

def __init__(self, n):

I think it is the number of squares on a side in the game board. The variable should be named something like num_of_squares.

In CellObject, ec and fc could be more descriptive as well.

In App2048, you should describe the purpose of the cells_2 array. You could add some comments that distinguish it from the cell array.

Documentation

The PEP 8 style guide recommends adding docstrings for classes and functions to describe their purpose.

Tools

ruff finds several instances of this:

E702 Multiple statements on one line (semicolon)

 |         self.axes.set_xlim(0, n+1); self.axes.set_ylim(0, n+1)
 |                                   ^ E702

The black program can be used to automatically separate those into individual lines. It can also help you see the structure of those dense go_up, go_down, etc., functions which seem to share some common code. Perhaps some of that code can be factored out.

Source Link
toolic
  • 15.7k
  • 5
  • 29
  • 216

UX

When I run the code, it launches a GUI, but it is not clear to me what I should do to play the game. Typically, 2048 uses the 4 arrow keys on the keyboard, but that did not work. It seems like it is necessary to click and drag with the mouse.

It would be helpful to add instructions to the GUI.

Naming

The variable named n is not very descriptive:

def __init__(self, n):

I think it is the number of squares on a side in the game board. The variable should be named something like num_of_squares.

In CellObject, ec and fc could be more descriptive as well.

In App2048, you should describe the purpose of the cells_2 array. You could add some comments that distinguish it from the cell array.

Documentation

The PEP 8 style guide recommends adding docstrings for classes and functions to describe their purpose.

Tools

ruff finds several instances of this:

E702 Multiple statements on one line (semicolon)

 |         self.axes.set_xlim(0, n+1); self.axes.set_ylim(0, n+1)
 |                                   ^ E702

The black program can be used to automatically separate those into individual lines. It can also help you see the structure of those dense go_up, go_down, etc., functions which seem to share some commmon code. Perhaps some of that code can be factored out.