Skip to main content

Knights - 2.0

A puzzle game where you fill a board with colors using only knight movements. It's a clone of the game troyis.


Smart Viking
(smartviking)
A puzzle game where you fill a board with colors using only knight movements. It's a clone of the game troyis.

Changes

A lot of changes, most significant are the design aspects of the game.

Links

Home Page
https://github.com/SmartViking/Knights

Releases

Knights 1.0 — 22 Nov, 2012

Knights 2.0 — 1 Dec, 2012

Pygame.org account Comments

  • Mekire 2012-11-23 02:56

    Interesting game. Perhaps you should investigate knight tours if you haven't already. I noticed in your game file you have an insane amount of 'from' imports. You basically took all your modules and collapsed them into a single namespace, which is considered bad form, and also makes code harder to follow. The way you have done it you might as well have just saved yourself some time and said things like:

    from settings import *

    The only reason to import specific elements with 'from' is if you don't want them all (which you appear to). Using all of those 'from' imports makes them global within the namespace so (at least in the case of your settings file) if you really want to do it this way you should at least make the variable names CAPITAL. This convention clues the reader that they are global constants (supposedly) and perhaps from another module.

    Basically you should just use regular imports and preface the values and functions you want to access within them as one normally would. General rule of thumb is it may be acceptable to use one * import (although from pygame.locals import * is pretty brutal on the namespace even alone) but beyond that use regular imports.

    Anyway, nice work, runs quite well. I have a Knight Tour program up on here if you would like to take a look (although reviewing the code would probably disgust myself as I wrote it awhile ago).

    Cheers,
    -Mek

    SmartViking 2012-11-23 05:17

    Thanks for the feedback! I haven't heard about knight tours before - that's awesome. I might make that a game mode in the future. Yeah the code isn't perfectly readable :) I also barely have any comments in it, I'll try to improve readability in the future. Now I just found out that I can get rid of "from pygame.locals import *" By changing 2 lines of code I'll do that. And I'll change the settings stuff to capital, and maybe remove the _settings at the end as it then might be clear that they are settings. Thanks!

    Mekire 2012-11-24 17:37

    Here is a link to my Knight's Tour program if you are interested:

    http://pygame.org/project-Knig...

    Wrote it about a year ago so my style has change/improved since then.

    -Mek

    Mekire 2012-11-23 12:48

    Here is a link to my pygame knight tour program if you'd like to take a look:

    http://pygame.org/project-Knig...

    I wrote it almost a year ago now though so my coding has changed a bit but it might amuse you. It would actually be fairly easy to create an AI solver for your game using these methods.

    -Mek

  • Mekire 2012-12-02 12:35

    Definitely looking a lot more professional after this update (although I kinda liked the derpy knight). Still not Py3 compatible if you care about that. I actually made an earlier version of your game compatible with both Py2 and Py3 but it required packaging 2 versions of yaml with your project (I actually suggest that you package yaml with your project regardless as it is such a small module. Then you don't have to worry about that dependency anymore.)

    -Mek

    SmartViking 2012-12-03 00:38

    Thanks! I took your advice and packaged PyYAML with the game. I also made it compitable with Py3, I didn't think about it previously because I thought it would be hard. Thanks again! :)

  • Iftekhar Hyder 2012-12-04 05:29

    Python Rocks!
    Good Game Dude! =)

    SmartViking 2012-12-04 16:00

    Thanks! :)

  • krishna 2016-01-19 14:31

    Would u help me to execute the game

    SmartViking 2016-01-28 19:33

    You need to download the files, and then run the file `run_game.py`. You need to have pygame installed, as well as python (version 2 is the safest bet). If you're using a debian derived system like ubuntu then you can install pygame with the command `sudo apt-get install python-pygame`