Git Product home page Git Product logo

the-witness-puzzle-maker's Introduction

The Witness puzzle maker

Algorithms and data structures student project

Images from the original game

Mazes with squares Maze with tetris pieces

Documentation

Notes for code reviewers

Nim is quite similar to Python in many ways, but some parts are very different. For example Nim functions can use generic types, function calls can use weird syntax sometimes and everything is statically typed. If you don't know Nim you should start by looking at the graph library graphs.nim, vector/math library geometry.nim and level format levels.nim. In those files I have lots of comments to help you understand the Nim code in this project. These comments start with NIMNOTE. Feel free to skip them if you understand my code (very likely if you know both Python and a language with generics and static typing).

the-witness-puzzle-maker's People

Contributors

cloudperry avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

the-witness-puzzle-maker's Issues

Peer review #1

Peer review

Hi! Fun idea for a project. I unfortunately could not test the code, because following the instructions got me this error:

Error (click to expand)
kbjakex:~$ choosenim devel
Downloading Nim latest-devel from GitHub
[##################################################] 100.0% 0kb/s
 Extracting linux_x64.tar.xz
 Extracting linux_x64.tar
    Setting up git repository
   Building Nim #devel
  Compiler: Already built
   Switched to Nim #devel
kbjakex:~$ cd temp
kbjakex:~/temp$ nimble install https://github.com/Cloudperry/the-witness-puzzle-maker

Downloading https://github.com/Cloudperry/the-witness-puzzle-maker using git
  Verifying dependencies for [email protected]
    Prompt: No local packages.json found, download it from internet? [y/N]
    Answer:  Installing [email protected]
    Prompt: cligen not found in any local packages.json, check internet for updated packages? [y/N]
y
    Answer: Downloading Official package list
    Success Package list downloaded.
       Tip: 6 messages have been suppressed, use --verbose to show them.
     Error: Package not found.

(This was on the fuksilaptop, which at the time of writing I no longer have access to due to forgetting my charger to the campus yesterday. I'm now on a Mac, and now the choosenim installer fails, seemingly because of C compilation errors, which is probably because the Mac is outdated in every way imaginable (13 years old). Sorry I wasn't able to test this.)

Having browsed the code, it's pretty clear you've programmed before. Not a whole lot to say.

  • Code coverage is great!
  • Code is certainly readable (at least with my Rust/C/C++/Java background), but also,
  • I appreciate the comments for the more obscure syntactical features, such as * exporting to other modules. in retrospect I wish I'd done this as well. I'd still perhaps appreciate more comments on fields such as those in Level (pointGraph/cellGraph/pointData/cellData?) though, to get the basic idea
  • Code has been split up appropriately to multiple files
  • If there's one thing I'm a bit uncertain it's the Graph structure.
    • The genericity itself isn't an issue, but it's being parameterized with float, Point2D and even seq, and the generic type is used as a key to a hash table. Floats are typically a poor choice for a hash map key because of floating-point imprecision (e.g. the typical 0.1 + 0.2 != 0.3 example), and seq as an array is heavy to hash / compare for equality (and in this case it's even a seq of Point2Ds). If at all possible, consider if you can find a way to use integers as keys (sometimes you can generate unique ids for objects and use those as keys, but in this case, since the problem as I understand it is largely on a grid, can you use a grid index?)
    • If keys were indeed to be flattened to ints, you could try to reduce the heavy nested hash collection structure to seq[seq[N]] or similar, assuming your keys are dense. I admit my understanding of the codebase is not good enough to be able to tell if this is viable, though.
  • For fast insertions / removals when order doesn't matter, instead of a hash set, consider using a "bag"? Bag as in basically seq, but instead of an order-preserving remove(), you instead remove by swapping the to-be-removed element with the last element, and then remove the last element, which is a trivial O(1) operation. Hash sets are memory-heavy and are a poor fit for iteration over the data, and it seems a fast contains() isn't necessarily needed here? Bags are dense in memory (good iteration performance), have no memory overhead and have O(1) insert/remove
  • Raylib ๐Ÿ‘

I had only heard of Nim until now, and I certainly enjoyed peeking into this world. The syntax is quite elegant in many ways, very concise without sacrificing legibility. It's unfortunate my codebase leaves such a bad impression of Rust, in contrast.

Last up: you've done a lot, but seems like you have a fair amount to do still, especially on the editor front. Not too many weeks left, so best of luck. Certainly more ambitious a project than mine.

(Project was downloaded on Fri, October 7th at 1:30 PM)

Peer review #2

Hello @Cloudperry!

I was excited to open your project since I've played The Witness before.
This was a cool opportunity to see some Nim, since I've only heard of it previously!

Environment

I am using Zorin OS (Ubuntu clone) and the latest Nim installation according to your guide.
It seems to be working!

I downloaded the project on the 13th of October at 11:18.

I used the latest git commit 9be1573.

Usability

What did I do?

  • Read through the docs
  • Go through Linux installation
  • Build project
  • Run game
    • When not setting the level as a cli argument it doesn't seem to open with testLevel / testLevel.bin -> seems that it needs a full path to the file
    • Also the program screws a bit with my screen settings: it set my resolution at 1280x720 at the lowest refresh rate possible ๐Ÿ˜‚
  • Run editor
  • Start going through code

Experience

Setup was really smooth and running the program went quite well.

The main problem right now (even though you've done a lot) is that there isn't much functionality.

Personally, to avoid a crunch, I would cut some stuff out to focus on the most important features in terms of the course for now:

  • leave the editor in the shadow and focus on the game and checking algorithms
  • implement the most interesting tiles like Squares and Blocks, but forget about stuff like Jacks

Code

I was unable to find parts which to criticise taking into consideration the previous peer review.

  • I liked the NIMNOTE stuff to get more into Nim
  • Project structure is good
  • Code is really well commented and readable
  • Consistent with Nim style guide
  • Test coverage is good
  • Unit tests are good

Summary

The code is really good! However, the current state of the app is really unfinished: I hope that you can get at least some functionality done before the end of the course. Good luck!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.