Skip to content

Commit

Permalink
move tetris to separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristian Rother committed Jan 21, 2024
1 parent acbb3e9 commit c8a1858
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
16 changes: 0 additions & 16 deletions functions/function_parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,3 @@ Here is a small illustration:
- keep functions small (below one screen page)
- If you have too many parameters, make a new class.
- Do not mix mutable types and return output.

Challenge: Refactor existing code into functions
------------------------------------------------

.. image:: tetris.png

In :download:`tetris.py`, you find a complete Tetris game.
It makes heavy use of the Numpy library.
The code almost has no structure.

Create functions with reasonable names to make the code cleaner.

.. note::

There is also a bug when dropping long bricks to the ground.
Maybe the refactoring makes this issue easier to debug.
15 changes: 15 additions & 0 deletions functions/refactor_tetris.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Refactor a Tetris game
======================

.. image:: tetris.png

In :download:`tetris.py`, you find a complete Tetris game.
It makes heavy use of the Numpy library.
The code almost has no structure.

Create functions with reasonable names to make the code cleaner.

.. note::

There is also a bug when dropping long bricks to the ground.
Maybe the refactoring makes this issue easier to debug.
8 changes: 8 additions & 0 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ Performance Optimization
performance/profiling.rst
concurrency/README.rst

Refactoring
-----------

.. toctree::
:maxdepth: 1

functions/refactor_tetris.rst

Challenges
----------

Expand Down

0 comments on commit c8a1858

Please sign in to comment.