freeCodeCamp / CurriculumExpansion

Creative Commons Attribution Share Alike 4.0 International
314 stars 105 forks source link

Learn Intermediate Algorithms by Building a Dice Game #217

Closed scissorsneedfoodtoo closed 2 years ago

vkWeb commented 5 years ago

If you (the one who's reading this 😃) is interested in helping us then I would encourage you to take a look at the problem spec: https://github.com/vkWeb/C-Yahtzee-Game/blob/master/Specs.pdf and the same repo has my implementation of the game in C language. It's not complete yet but 80% of the work has been done on it.

shynonagons commented 5 years ago

I have some time and inclination to work on this! I will try to bash out a prototype in the next few days.

vkWeb commented 5 years ago

@perezvon Amazing! I'll be looking forward to your prototype.

scissorsneedfoodtoo commented 5 years ago

Sounds great, @perezvon. Please feel free to reach out if you have any questions.

shynonagons commented 5 years ago

OK here's something just to see if I've got the right idea: https://codesandbox.io/s/broken-sea-3ixfn

I kept it vanilla because I'm not sure where along the curriculum it will fall, but it might make sense to do it in React if it's after the React lessons or what-have-you. The checkboxes are kinda unintuitive (you uncheck to keep the die value); I didn't want to spend too much time fiddling with UX in case we actually want it all in a command line interface or something.

Let me know your thoughts @vkWeb @scissorsneedfoodtoo!

scissorsneedfoodtoo commented 5 years ago

@perezvon, wow, that was fast! On first glance this is looking really good. The difficulty of parts of the code seems about on par with the challenges in the current Intermediate Algorithms section.

If you take a look at Quincy's post from earlier this year, this will fall between the Data Structures Shopping Cart and Functional Programming Spreadsheet projects. Though we wanted these to work without HTML and CSS originally, I don't think it's possible in vanilla JS, at least not easily. Seems fine to have a very minimal UI for players to interact with.

Will ask @beaucarnes and @QuincyLarson for their thoughts.

vkWeb commented 5 years ago

@perezvon It's a very quick start. 😄

We actually expect this to be a command-line application. The reason why we are insisting on a command-line app is that we want campers to solely focus on Algorithms. And just to clarify, we want to use 100% vanilla JS. No libraries.

Coming to your app here are some suggestions:

@perezvon I'm excited to see the next version with improvements as mentioned above.

@scissorsneedfoodtoo What do you think about my feedback?

vkWeb commented 5 years ago

@scissorsneedfoodtoo Looks like our comments fired up at the same time. 😄

Though we wanted these to work without HTML and CSS originally, I don't think it's possible in vanilla JS, at least not easily. Seems fine to have a very minimal UI for players to interact with.

@perezvon I realized just now that we can't accept inputs from command line in vanilla JS. Let there be a minimal UI. Please ignore my previous comment regarding the app being a command-line interface.

beaucarnes commented 5 years ago

This looks really good! A few additional recommendations:

shynonagons commented 5 years ago

Cool, thanks for all the feedback! I've made some changes based on your aggregated comments, take a look-see: https://codesandbox.io/s/broken-sea-3ixfn

@scissorsneedfoodtoo I had to do this one fast because last time (Tetris game) I kept dragging my feet until all my free time evaporated 😃

@vkWeb I realized as I'm typing this that I'm still using Array.sort() -- I'm a little torn on your feedback because I do recognize the value of understanding how to implement your own sorting, but also it's important to know what methods are available to you in the language of your choice, too. 🤷‍♂ Happy to continue to think it through, though.

@beaucarnes I think I handled all your feedback, thanks!

RandellDawson commented 5 years ago

@perezvon Since the whole purpose of this project is to learn algorithms, I agree with @vkWeb that the sort should be implemented by the user and not use the built-in method.

vkWeb commented 5 years ago

@perezvon This looks very nice! I'm sure we can make it much better and more challenging:

also it's important to know what methods are available to you in the language of your choice, too. 🤷‍♂ Happy to continue to think it through, though.

Yes, It's important. But not necessary. Understanding how sorting works, to know its implementation is necessary for a developer.

I have forked your work: https://codesandbox.io/s/yahtzee-game-dud4s and I am improving upon it. You should keep on improving your version. Later we can simply merge our versions or use any one.

By the way, @perezvon thanks for working so quickly on this ^_^.

shynonagons commented 5 years ago

OK, I need no further convincing 🙂 Working on this now. There are also a few .map() calls, perhaps we should be building that algo out by hand as well?

vkWeb commented 5 years ago

@perezvon Yes we should make algo of .map too. We should restrict campers from using .map in a challenge to allow them to come up with their own solution then in later challenges we can lift the restrictions and tell them there's an JS function that does this for us.

shynonagons commented 5 years ago

OK done -- let's see what we think about things now. (I myself have never built sort() from scratch before, so it might be an incomplete implementation!) https://codesandbox.io/s/broken-sea-3ixfn

[EDIT] @vkWeb I know I still need to work on the feature of selecting from possible scores per the spec, kinda forgot about that before I posted this update

vkWeb commented 5 years ago

@perezvon I think we should not confuse campers with indicator in the sort function. Let's just simply arrange it in ascending order. Also, the dice roll isn't working.

Btw, can you create a GitHub repository to host this game? I want to send you a pull request to help you with this :)

vkWeb commented 5 years ago

@scissorsneedfoodtoo I think object-oriented programming is missing in the new curriculum. Is it intentional?

scissorsneedfoodtoo commented 5 years ago

Wow, lots of great discussion here. I especially like the idea of walking learners through implementing their own simple sorting algorithm. It might be discouraging if we walk them through all that, then have them refactor just to use .sort, so we could probably just mention the method in the test descriptions. Let's just try to keep things as simple as possible, since implementing quick or merger sort is more appropriate in the Coding Interview Prep section.

@vkWeb, right now we're thinking that we'll focus on object oriented programming more in the upcoming Python projects. Still, this project and the Data Structures Shopping Cart are more object oriented, and we can teach some of those concepts in both projects.

shynonagons commented 5 years ago

@vkWeb https://github.com/perezvon/fcc-dice-game/

Updated the die-rolling behavior to make more sense and refactored the sort. (Though now there are two different sorting functions for two different types of sorts needed, one simple ascending and one based on object properties) https://codesandbox.io/s/parcel-sandbox-ngqot

vkWeb commented 5 years ago

It might be discouraging if we walk them through all that, then have them refactor just to use .sort, so we could probably just mention the method in the test descriptions.

Yeah, that's fine.

Let's just try to keep things as simple as possible, since implementing quick or merger sort is more appropriate in the Coding Interview Prep section.

@scissorsneedfoodtoo Yes. Our solution will be selection sort. We can tell campers about its theory and will leave implementation to them. We can also mention that they will learn more sorting algorithms in the interview prep section.

vkWeb commented 5 years ago

I just want to update you all about the progress.

I am changing the logic of the game to make it interesting for a single player. I'm also learning about JS OOPs concepts. I will soon send a PR to @perezvon and it will get things moving.

vkWeb commented 5 years ago

@scissorsneedfoodtoo I have created a PR on @perezvon's repository: https://github.com/perezvon/fcc-dice-game/pull/1

After cleaning and optimizing things, we'll merge it and send a PR to this repo.

I have been working on this for around a week and I still think the old challenge-based approach will be better :) I don't know why but I am not satisfied with the challenges we gonna offer. Maybe I am thinking too much. Any thoughts @scissorsneedfoodtoo on this?

scissorsneedfoodtoo commented 4 years ago

Hi @vkWeb and @perezvon, thank you for your patience and your continued efforts with this project. I took a look at the PR posted above and everything is looking great! Can't wait to play the finished prototype.

About whether or not the old challenge based approach is better, it's hard to say. While there are certainly benefits to the way these concepts are taught in the current curriculum, being able to walk learners through building projects from start to finish will also present many opportunities to teach many of the same concepts. Our thinking is that these projects will also ease the transition from the optional curriculum to the required projects, where many learners have difficulty building something from the ground up.

That said, we're always open to feedback from contributors and the community at large.

vkWeb commented 4 years ago

@scissorsneedfoodtoo we have discussed this in the past and we reached a consensus that we will build multiple projects. So instead of stalling this more I think let's get this rolling :) we can add an advanced project if we think this isn't enough.

Here's the full working prototype: https://perezvon.github.io/fcc-dice-game/

We just need to add some generic functions and we'll send a PR to this repo. You can track our progress through our project board: https://github.com/perezvon/fcc-dice-game/projects/1

scissorsneedfoodtoo commented 4 years ago

@vkWeb, very true. We can always make changes or additions down the road as we get more feedback from the community.

Great idea creating a project board for this project. Looking forward to seeing how this turns out.