How I Practice Programming: Five Dice

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ก.ย. 2024
  • In this unusual video, I describe how programming practice needn't be stale and boring if you take inspiration from everyday things you find interesting, and viewed through the eyes of a programmer. Specifically I look at the implementation of 5 Dice based games, like Yahtzee.
    Source: github.com/One...
    Patreon: / javidx9
    TH-cam: / javidx9
    / javidx9extra
    Discord: / discord
    Twitter: / javidx9
    Twitch: / javidx9
    GitHub: www.github.com...
    Homepage: www.onelonecod...

ความคิดเห็น • 258

  • @zachreitan3859
    @zachreitan3859 3 ปีที่แล้ว +321

    I REALLY appreciate these sorts of coding videos where someone explains the logic and thought process behind the code they write. I feel like this kind of thing is very sorely lacking in a lot of programming tutorials. It's not so important that you know WHAT code to write as much as WHY you would write it in the first place.

    • @javidx9
      @javidx9  3 ปีที่แล้ว +50

      There's a full video about containers and why/how to choose them prior to this one. The simple answer is, it genuinely doesn't matter in this instance.

    • @dutu000
      @dutu000 3 ปีที่แล้ว

      YES! Me too!!!

    • @Briglair
      @Briglair 3 ปีที่แล้ว +4

      Exactly! You don't learn anything by someone just saying "do this, do that." You learn how to copy from a screen, not how to apply logic on your own. I love this channel

    • @_miyu
      @_miyu 3 ปีที่แล้ว +1

      @@Briglair I feel very similar with music. I used to play the Trumpet when I was young and all we did was play exactly what was on the sheet. Later I tried to pick up Guitar. After awhile I noticed I was just memorizing chords and playing back exact songs that I happened to like. That never really worked for me. Now I really found what I am good at, I love to code and I have the ability to think problems through and generate my own real solutions. It is certainly a pleasure to see videos like this one, that show you how reason your way through problems.

    • @johnneighbor9866
      @johnneighbor9866 3 ปีที่แล้ว

      @@Briglair Yep, and then concluded with, "and that's how you do x" and any viewer is just left there sitting like what did I waste 4 minutes watching, because in those, "type this, then this" there's no learning really promoted at all.
      Where Javid on the other hand, goes quickly but explains details as well, and being video, backtracking 10s is 100% a doable task.

  • @kadensharpin2156
    @kadensharpin2156 3 ปีที่แล้ว +189

    "I don't like regular expressions because fundamentally I don't understand them"
    that hit close to home

    • @DFPercush
      @DFPercush 3 ปีที่แล้ว +38

      Regular expressions are like the vim text editor. Everyone who's devoted the time to learning it, swears by it. Everyone else is frustrated and annoyed by its existence.

    • @TotalImmort7l
      @TotalImmort7l 3 ปีที่แล้ว +4

      @@DFPercush Cannot agree more.

    • @zakkiedude132
      @zakkiedude132 3 ปีที่แล้ว +3

      @@DFPercush particularly accurate because to really get the best out of vim you've really gotta learn how to :%s/regex/replacement/g

    • @ShadowRadiance
      @ShadowRadiance 3 ปีที่แล้ว +10

      There's a saying that "if you have a problem and solve it using a regular expression, you now have two problems."

    • @DFPercush
      @DFPercush 3 ปีที่แล้ว +1

      @@ShadowRadiance lol... only if you have to understand it later

  • @salockingaming6246
    @salockingaming6246 2 ปีที่แล้ว +9

    i really hope you don't stop making videos because I really love your calming pace and voice and I love using your olc engine

    • @javidx9
      @javidx9  2 ปีที่แล้ว +4

      Thank you, no plans on stopping, will have a couple more this year I hope, but been on hiatus with my new family since summer.

  • @Nioub
    @Nioub 3 ปีที่แล้ว +25

    To detect the full house, you can encode it in "nnnmm" and "nnmmm", handling the m value exactly as the n value (but in a separate variable).

    • @whinebite
      @whinebite 3 ปีที่แล้ว +13

      Reading this under the effects of sleep depravation only made me imagine those as microwave sounds

  • @JanKjeldsen
    @JanKjeldsen 3 ปีที่แล้ว +17

    Yatzy was the third program I wrote in high school in 1981. Programming language was Comal, a Basic derivative. The program worked but lacked structure. Learned the need for subroutines the hard way :) Did I forget to mention it was written on punch cards for a RC-7000 computer? It had 326 lines with no blank lines, why waste a card? On par with this C++ program, but mine had the computer play against you!

  • @StuartLoria
    @StuartLoria 3 ปีที่แล้ว +42

    At college we used to say “Practice Only on the days you wake up”
    If you’re in a comma, bedridden or dead, you are excused.

  • @ziolkovy
    @ziolkovy 3 ปีที่แล้ว +23

    @javidx Great video! (as always)
    One thing I noted:
    Maybe I do not know rules of game, but for me small straight pattern looks wrong - for instance 12234 don't match. Also five of a kind can be treated as full house, which shouldn't be possible.
    I think it is a good idea to set few dices sets manually for testing and then use random.

  • @wolverine9632
    @wolverine9632 3 ปีที่แล้ว +1

    One of my proudest programming accomplishments was writing a full-featured single-player yahtzee game in BASIC on the Vtech PreComputer 1000.

  • @田淞煜
    @田淞煜 3 ปีที่แล้ว +4

    I have learned so many things through your videos. You are the kind of person I always wanted to be. Please continue to make more this kind of useful videos. I will be very, very grateful to you and hope you and your family will always be healthy!!!!

  • @zach_attakk
    @zach_attakk 3 ปีที่แล้ว

    As a pedantic board gamer and coder, you have no idea how happy I am to hear the proper plurals for die/dice

  • @piratux2860
    @piratux2860 3 ปีที่แล้ว +2

    What a lovely video. Simple, yet some parts have depth in it.

  • @d3r1n
    @d3r1n 3 ปีที่แล้ว +1

    Well I saw the discord status "Uploading a video" and came here. I love your videos so much as a kid who obsessed with computers and stuff you are my hero when it comes to programming

  • @trellend
    @trellend 3 ปีที่แล้ว +20

    You need a remove duplicates on your small/large straight before your test, and change your test pattern.

    • @joemaffei
      @joemaffei 3 ปีที่แล้ว +7

      I was just about to type this, as i noticed the 3 4 4 5 6 at the tail end of the video not registering as a small straight.

  • @utkugokalp3179
    @utkugokalp3179 3 ปีที่แล้ว +6

    Great idea to shoot a video about this, even the best need it sometimes

  • @tibfulv
    @tibfulv 3 ปีที่แล้ว +1

    Basic regexes are really quite simple. You can do really complex things with them, but that's common in programming.
    The concept is quite similar to globbing. All words match themselves, '.' matches any character, '?' means zero or once, and '*' and '+' means repeated zero or more and once or more. If you need more fine-grained control, curly brackets controls repetitions, square brackets pattern matching. Also, you can match the beginning or end of the line with '^' and '$'. Anything more is implementation-dependent.
    In C, you compile a regex with regcomp() and match it with regexec(). In C++, things seem different. But the relevant funtions for both are in regex.h.
    www.geeksforgeeks.org/write-regular-expressions/
    www.geeksforgeeks.org/regular-expressions-in-c/
    www.softwaretestinghelp.com/regex-in-cpp/

  • @Loleexer
    @Loleexer 3 ปีที่แล้ว

    You're a genius! I've got to learn how to optimise my code like that. It does happen sometimes that I write a neat little piece of code which does a lot, and I do get praised for it at work, but often times I rush to another tasks at hand without really thinking about what I wrote and of ways of making it better. Often times do I go back to my code only to realise how terrible it is at a first glance. Such inquisitive and robust optimisation will definitely take some time to learn, but the end result seems to be more than worth it! I'm glad I decided to watch this video.

  • @stephenelliott7071
    @stephenelliott7071 3 ปีที่แล้ว +1

    An excellent video! I love breaking down a tricky problem and getting the program just running bug free (I call it the first hurdle). Then look to refine and refine the algorithm to make it more and more efficient - also more concise. Something you did particularly well here. Great stuff.

  • @barellevy6030
    @barellevy6030 3 ปีที่แล้ว +6

    Hey, great seeing you upload!
    How's things with the new addition to the family?
    Hope you are all in good health and adjusted as much as it's possible to adjust :-)

  • @DavidBauer38
    @DavidBauer38 3 ปีที่แล้ว +1

    I was literally just thinking about doing a Yahtzee clone in Golang the other day! Looks like I need to get going! thanks for the inspiration, @javidx9!!!

  • @petacardi
    @petacardi 2 ปีที่แล้ว

    Really insightful video! It is really nice seeing smart people writing code. Thanks!

  • @megaxlrful
    @megaxlrful 3 ปีที่แล้ว

    I will probably never forget my first time playing yahtzee. I barely understood the rules, and my first roll was a yahtzee with fives. Talk about beginners luck.

  • @Surf_Cat
    @Surf_Cat 3 ปีที่แล้ว +1

    Yahtzee is a nice choice when learning programming farmeworks/languages, it has a nice range of tasks. If you manage to decouple the logic (maybe iteratively) you can use it as a library to test gui or other stuff. I used this to figure out listboxes etc.. in gui frameworks, some 3d stuff and a lot of other new stuff when learning.

  • @Bravo-oo9vd
    @Bravo-oo9vd 3 ปีที่แล้ว

    Really liked the the focus on expressing the logic as succinctly as possible. With this in mind, have you considered looking into some functional programming languages, eg. Haskell and maybe doing a video about them in the future? Imperative languages can be a bit verbose at times, and functional programming can be really "logic-dense", but things like monads, functors, applicatives, and all the other category theory jazz can be a little daunting at first. Would love to see something like this on your channel, even if it'd be only one or two videos.

  • @ErtosAcc
    @ErtosAcc 3 ปีที่แล้ว

    17 minutes in and I'm losing focus. Rewatching later. I can recognize a great video despite not knowing anything about C++, and this is one of them. Provides a refreshing view on programming.

  • @jaredbowen827
    @jaredbowen827 3 ปีที่แล้ว +2

    This is the simplest program you've done. I've done this to my TI-89 Calculator YEARS ago. It's a good way to learn how to code in SEVERAL coding Languages.

  • @prinnydadnope5768
    @prinnydadnope5768 3 ปีที่แล้ว

    The small straight isn't limited to 4 values :
    1234?, ?2345, 2345?, ?3456 would work if all dice had different values, but fails if a value is shared.
    The earliest example is 11234, the ? is in the first spot.
    Or even 12234, where the ? is the in second or third spot.
    Great video overall, thank you for making this.
    People often underestimate "little projets", but it's by doing projects of all sizes that you progress, not just big ones.

  • @JaycenGiga
    @JaycenGiga 3 ปีที่แล้ว

    As others pointed out, there was a bug regarding the small straight rule. I think this comes from using a vector, which is a suboptimal data structure for the problem. As I see it, the most appropriate one would be a multiset which is also part of the standard library and so would not only be a perfect fit for the problem but also you would likely learn something new. Then, you could simply define a multisets for all the rules and do matches by checking for subsets, without using patterns.

  • @bradp213
    @bradp213 3 ปีที่แล้ว

    I wish I knew about this channel when I was in college. Great video! Thanks

  • @danteculaciati1656
    @danteculaciati1656 3 ปีที่แล้ว

    Love your videos man! Thanks for all your advice and the enthusiasm you put into them.

  • @insoYT
    @insoYT 3 ปีที่แล้ว

    Probably ten out of ten times I'd have gone with RegExp and never looked back 😂 But I must admit that I liked to watch that little puzzling. RegExp sometimes feels annoyingly repetitive work without able to just copy&paste old solution. However I feel like with RegExp this logic would have been more readable. I believe I'd have also chosen "if(yyy && xx)" over "if((nnn?? && ???nn) || (nn??? && ??nnn))" for formatting. 👍 Programming would be boring without challenging our approaches 🤓 Great video, thanks!

  • @glizzdawiz
    @glizzdawiz 3 ปีที่แล้ว +6

    I've been wanting to do this with DnD scoring, dice and experience calculation.

    • @casperes0912
      @casperes0912 3 ปีที่แล้ว +1

      DnD Beyond has an API you can hook into to get character sheet info if you want :)

    • @glizzdawiz
      @glizzdawiz 2 ปีที่แล้ว

      @@casperes0912 cool thank you

  • @drummsnikk5073
    @drummsnikk5073 3 ปีที่แล้ว

    Always a pleasure to watch your videos ❤️

  • @Nuvhandra
    @Nuvhandra 3 ปีที่แล้ว

    Amazing, thank you again for a great video. "It's all about the journey rather than the end result", Cheers

  • @marcosdantas4258
    @marcosdantas4258 2 ปีที่แล้ว

    i really love your videos javidx, thanks for the great content, i can see how computers have strong love for know values at compile time and he hate loops hahaha, on the last minutes of video you improves code quality by using vector and loops for computers aspects and aspects of FP libs and your fps drop 385 to 345 times, is incredible how things can be wrong if we adopt bad solutions for some cases, for me games is the more significant area to learn and improve your knowledge about computers and programming language.

  • @blinded6502
    @blinded6502 3 ปีที่แล้ว

    That's one hell of a thumbnail, looks awesome!

  • @teucay7374
    @teucay7374 3 ปีที่แล้ว

    As inspiring as always. Thanks for all!

  • @erichamion
    @erichamion 3 ปีที่แล้ว

    I haven't gotten to the end, so this may be fixed before the end of the video. "11234" would be a valid small straight, but there's no "?1234" pattern to match it. The same happens if there are two sixes: "34566" needs a "3456?" pattern.

  • @nathanalgren288
    @nathanalgren288 2 ปีที่แล้ว

    Yahtzee kinda reminds me of a Video Poker program I did a while back (interestingly, also in C++). One way I understand the game is basically Poker with dice instead of cards!

  • @noblesavage149
    @noblesavage149 3 ปีที่แล้ว

    Wow... I need something to get my teeth into as I've been losing the plot as a front end developer. Going to implement this in first one language and then use it as a base to learning other languages. Thanks dude!

  • @justcallmenoah5743
    @justcallmenoah5743 3 ปีที่แล้ว +1

    Yeah, the pattern matching is cool, but the implementation here is prone to bugs. I once made Yahtzee in c++ in college and I found the best way to calculate score, was to have an array of six integers that contain the count of each die value you have. It's much easier to determine your scores that way!

    • @Roomsaver
      @Roomsaver 2 ปีที่แล้ว

      Good idea! I like that implementation

  • @zettelkastendev3760
    @zettelkastendev3760 3 ปีที่แล้ว

    thanks for this, I really struggle with coding right now

  • @nokiaa3337
    @nokiaa3337 3 ปีที่แล้ว

    I love you so much man , i dont know why really. You looks wonderful good and determined person maybe thats why RESPECT.

  • @GonziHere
    @GonziHere 3 ปีที่แล้ว

    Spot drawing - great insight into the development of an algorithm (and the value of not using the first and fastest solution) But the result is harder to expand to say 7,8 and 9 values (it uses "hacks" that work only inthis exact scenario, its the opposize of robust).
    But again, great video especially for junior programmers who dont understand these continuous improvements (or the prototyping value of the first code) That was just a nitpick :)

    • @DFPercush
      @DFPercush 3 ปีที่แล้ว

      My first thought beyond the "brute force" method was to use truth tables and Karnaugh maps, but that involves breaking the value into bits first. I wouldn't have noticed that symmetry the way he did it, and the code he ended up with is probably faster. But my way would have been branchless, sometimes that matters (not here tho). The only other dot-face thing I can think of that has more than 6 values would be dominos. I wonder what that would look like... but as you said, it's a very constrained problem here, and why solve problems that you don't have to. :P

  • @alexandrevolts7513
    @alexandrevolts7513 3 ปีที่แล้ว

    Wow that's crazy how we do not see the same thing facing the same problem. I coded a Yams last week (Typescript), yeah what a nice coincidence.
    Concerning the pattern part, I used something like a OOP-oriented way, which is a totally different approach. Basically I just had a class for every possible combination inheriting from a common class "AYamsCombination", and every child class has a common function that I overwrite and that contains the algorithm to "solve" one combination, taking an array of number (the dices) as parameter, and returning the score if it was a valid combination, or -1 if it was a wrong one.
    Then I store all my classes in an array and loop over them to compute the scores of a given combination.
    To don't have redundant code I created a "YamsTools" class which contains three functions: hasNDicesOrMore(int[ ] dices, int n), hasSequence(int[ ] dices, int sequenceSize), countDices(int[ ] dices, int dice), which makes that generally every function that is supposed to check a combination doesn't exceed three or four lines.

    • @Reintjuu
      @Reintjuu 3 ปีที่แล้ว

      That's what I was thinking. Why is he not taking an OOP approach?

  • @justinlangley8972
    @justinlangley8972 3 ปีที่แล้ว

    I like regular expressions, but only for things where it's implementation stays simple, which is rare. If you can solve it algorithmically, do that instead because other people who read your code will thank you for sparing them if they struggle with regex. Regex is also hard to debug, and requires you to diagram it as a finite state machine (it's how regex works) to figure out where the issue lies. So anyhow, if you want to learn regex you'll want to study finite state machines, and when you build regex yourself you'll want to use a website like regexr (not a fan of it being actions riot based) or some other website. There also exists websites that turn regex into a graph of the finite state machine they represent. Hope this information is helpful for someone who would like to learn regex, but ultimately I don't think it's a critical skill to learn. However, if you come across it in your line of work, you'll at least know what it is and possibly how to dissect it, and then implement a better solution. There are circumstances where a good regex implementation can have a time complexity as good as an algorithmic implementation, and sometimes better if the implementation is poor. I really like the lambda implementation in this video, it's an elegant way to do it.

  • @julienderiviere4907
    @julienderiviere4907 3 ปีที่แล้ว

    Yahtzee was the first game I implemented 20 years ago... in Basic :p I should do it again in C++

  • @tomvito
    @tomvito 3 ปีที่แล้ว

    Great video 👌🏻Thank you!

  • @jsflood
    @jsflood 3 ปีที่แล้ว

    One word. Awesome!

  • @Cesar-ey7wu
    @Cesar-ey7wu 3 ปีที่แล้ว

    Yahtzee's core gameplay is evaluating probabilities (which can be surprisingly counter intuitive).

  • @puncherinokripperino2500
    @puncherinokripperino2500 3 ปีที่แล้ว +1

    11234 is also a small straight, as well as 34566

    • @lguilh
      @lguilh 3 ปีที่แล้ว

      noticed the same

  • @stevefalcigno2092
    @stevefalcigno2092 3 ปีที่แล้ว +2

    Very nice! One thing, at 33:39 the values 3,4,4,5,6 should give us a small straight (I think).

  • @DarkVigoole
    @DarkVigoole 3 ปีที่แล้ว +1

    Nice video. Do ?1234 pattern will be matched for small straight ?

  • @39Kohm
    @39Kohm 3 ปีที่แล้ว

    spotted the Vimto immediately :D

  • @THE16THPHANTOM
    @THE16THPHANTOM 3 ปีที่แล้ว +1

    mkay, this is the way of my thought process as well, so i'm on a good track. minus the clever pattern recognition in code, i can never get all of that in one session. i only get to that point by repeated re-reading my code and discovering the efficient way by accident.

  • @framegrace1
    @framegrace1 3 ปีที่แล้ว

    I use the same approach. Start with most trivial implementations and the algorithm patterns appear like magic...

  • @mikael5743
    @mikael5743 3 ปีที่แล้ว

    Thanks

  • @jake_runs_the_world
    @jake_runs_the_world 3 ปีที่แล้ว

    Really useful video

  • @sigmundfreud4472
    @sigmundfreud4472 3 ปีที่แล้ว

    Thanks for the video! It reminds me of when I was just starting out, I wrote some code to simulate the game “Left Right Center”. It’s completely a game of chance, except if you can choose your place in turn order. We had been playing it a lot (for money!) and I wanted to guess what the best place to start would be.
    Long story short, it seems the odds of winning increase the further in turn order you are, with great effect the fewer players there are. (With two players, Player 2 has a 70% win rate!)

  • @gpiforgoo
    @gpiforgoo 3 ปีที่แล้ว

    There are some Problems with your Pattern. For Example a Full House, when all dice have the same value, it will pass. I check if n==m is needed. And as other mention, for straight - 12334 would be a valid "small straight".
    My idea to solve the double-dice would be, to handle the "?" complete diffrent. instead of check for "1234?" i would only pass "1234" as pattern, since we need 5, the match-function knows, there is an "error" allowed. so when it checks 12334 -with "1234" the first three digits pass, after that, it will compare the dice with "3" with pattern "4" - it fails, but there is a error allowed, we skip this dice and the next check will pass.
    for the full house problem: a pattern "nnnnmm" would be possible, since there are no "?" in the pattern. It must only store the m-value in its first appearence.
    finaly a small optimization: Nearly all patterns are double, normal-way and mirrored-way. The match routine could test the pattern and when it fails, mirror the pattern und try again.

  • @tommytomtomtomestini3894
    @tommytomtomtomestini3894 3 ปีที่แล้ว +3

    I've had a headache all day, I challenge you to turn that into a programming exercise.

    • @aednil
      @aednil 3 ปีที่แล้ว +5

      are you staying hydrated well enough? you could write some code to remind you to drink some water every now and then.

    • @kevin5475845
      @kevin5475845 3 ปีที่แล้ว

      just implement regex in brainfuck language and you're gonna get some lovely migraines

  • @thelastofCaesars
    @thelastofCaesars 3 ปีที่แล้ว

    xD, I've actually written rolling function in Unity for my board game... few minutes on yt and hello, here is the source of all information.

  • @alexstone691
    @alexstone691 3 ปีที่แล้ว +1

    24:00 why don't you just return false if any of the conditions don't match? Aren't you looping unnecessarily if first dice don't match a rule

  • @BernhardBB8
    @BernhardBB8 3 ปีที่แล้ว

    actually i found a mistake - at least i think so: for the 4 in a row i need to check for following combinations: {"1234?","?2345","2?345","23?45","234?5","2345?","?3456"}. Every thing else were just some rule differences.

  • @brianwaltse281
    @brianwaltse281 3 ปีที่แล้ว +1

    OMG i forgot a vector is a list, and was wondering how he was using a 2d vector to store the data of five dice

  • @TheMrDemonized
    @TheMrDemonized ปีที่แล้ว

    Tfw the 'bruteforce' switch way will be the fastest to perform

  • @classiccroissant3231
    @classiccroissant3231 3 ปีที่แล้ว

    Thanks for all your updates. How is the family situation?
    Wondering: there is a "onelonecoder" reddit, is it you?

    • @ShadowRadiance
      @ShadowRadiance 3 ปีที่แล้ว

      That reddit is him, yes - one look at that pretty mug, and you cannot doubt it!

  • @urbaniuscee3657
    @urbaniuscee3657 3 ปีที่แล้ว

    Nice video. Always good to see std::algorithm and std::numeric used in a creative fasion.
    One remark though:
    Wouldn't it be beneficial to immediately return false if one step of the pattern matching fails, instead of using a bool to save to current matching status. That would reduce the amount of variables on the stack, and the algorithm would terminate faster, if the pattern is not matched, which will be the most frequent case?

  • @Snylt
    @Snylt 3 ปีที่แล้ว

    Odd seeing other rules for small and big straights. I'm used to small being 12345 and big being 23456 andd giving 15 and 20 points. Fun to learn that other rules even exist.

  • @em_the_bee
    @em_the_bee 3 ปีที่แล้ว

    10:22
    >even though it's syntactically elegant
    Things C coders say sometimes...

  • @inspisiavideos8542
    @inspisiavideos8542 3 ปีที่แล้ว

    Hi! I have a question but I think it's more like an advise. I got a paid internship at a company that protects data for hospitals. The internship first day introduction day (last week) I was told by HR and some senior employees that I will be rotating first doing QA Engineering job (testing apps from the developers, watching out for bugs, zoom meetings and scrum). Then I'll be rotating to write code in Java. HR later gave me a Powerpoint presentation and one of the slides had info about all the job positions people can apply to and get a bonus by bringing in a new recruit. But the HR lady said it does not apply to interns. During my first week I have done nothing but trainings and explanations of the platforms. I feel like it's a lot for a team. So, the question is if with all this, do you think if I ask them if I could stay permanently there or to have my stay there extended. If so, at what point I should ask? My full time internship ends ending August. My concern is that I did the decision of quitting my previous job as an Assistant for nurses in order to have this opportunity. Just in case I signed up for algoexpert and train coding problems so I can be prepare and start applying to jobs at other companies. But, I'm concerned about this because I have 3 months before my income ends. Please let me know.

  • @AliParlakci
    @AliParlakci 3 ปีที่แล้ว

    I think the pattern matching for full house incorrect. You are not checking if every "?" is the same for full house. The pattern would be mmnnn instead of ??nnn given the meaning of ?.

  • @XxyehezkelxX
    @XxyehezkelxX 3 ปีที่แล้ว

    How crazy can you go with the olc library? Say I wanted to make a visually pleasing poker app

    • @javidx9
      @javidx9  3 ปีที่แล้ว +1

      Its hardware accelerated 2d, you can see it's potential in the introducing PixelGameEngine 2.0 video.

  • @kevnar
    @kevnar 3 ปีที่แล้ว

    FYI, the spots on a die are known as pips.

  • @fabiogaluppo2635
    @fabiogaluppo2635 3 ปีที่แล้ว

    Nice video! Let me ask you: Why not implements set contains in terms of find instead of count?

  • @fplancke3336
    @fplancke3336 3 ปีที่แล้ว

    Have you thought of adding a letter m to patterns that works like n but independently? This way the full house pattern set would be simplified to nnmmm | nnnmm.

  • @orbisanimation6150
    @orbisanimation6150 3 ปีที่แล้ว

    I really love your videos I wish i can write c++ as you :D

  • @MrFlashPash
    @MrFlashPash 3 ปีที่แล้ว

    How can you write this clean with a graphic tablet

  • @averbuchalex7
    @averbuchalex7 2 ปีที่แล้ว

    very nice and informative video, learned a lot, thanks

  • @mnl1986
    @mnl1986 3 ปีที่แล้ว

    Isnt 3456? and ?1234 also a small straight?

  • @Jkauppa
    @Jkauppa 3 ปีที่แล้ว

    who said you have to have die with dots in the standard locations, or even dots at all, instead numbers

    • @Jkauppa
      @Jkauppa 3 ปีที่แล้ว

      who said they have to be generated by code, instead an image, civ 2 game, sprite

  • @manfrombritain6816
    @manfrombritain6816 3 ปีที่แล้ว

    9:44 why the hell not? surely that is one of the most fundamentally useful features of a set, to know whether it contains something or not? stuff like this in standard libraries bugs the hell out of me

    • @michelealessandrini3421
      @michelealessandrini3421 3 ปีที่แล้ว

      Actually the "find" function is for that, it has the same interface in all the containers.

  • @TankorSmash
    @TankorSmash 3 ปีที่แล้ว

    Isn't a lambda capture the same, whether it's [&vRolled](){ ... }; or [&vRolled = vRolled](){ ... };? The aliasing doesn't make sense, does it?
    And the original PatternMatch definition already captured everything by reference anyway, so nothing was actually changed by by-ref capturing only [&vRolled] vs by-ref capturing everything [&] (including vRolled), right? You can do lambdas without capturing at all, [](){} too, which would have made sense for the original PatternMatch, maybe.

  • @vbachris
    @vbachris 3 ปีที่แล้ว

    really interesting video but also consider this. the game of Yahtzee is well established and unlikely to change (i mean the game has been around in the same form for 65+ years?) this is VERY unlike business rules which change ALL the time and in unexpected ways. The more terse you write code the HARDER it becomes to change. Just F4T.

  • @cw3dv
    @cw3dv 3 ปีที่แล้ว

    JUST to ask do use cmake or just simple g++

  • @MrRyanroberson1
    @MrRyanroberson1 3 ปีที่แล้ว

    Better program for small straight: twos >0 && threes > 0 && fours > 0 && (ones > 0 || sixes > 0)

  • @superfunfactory8893
    @superfunfactory8893 3 ปีที่แล้ว

    9:30 I'm learning C++. What is the reason you are using cpp17 instead of cpp20, since you say cpp20 would have the 'contains' function you need? Thanks for any help

    • @javidx9
      @javidx9  3 ปีที่แล้ว +2

      At the moment all my software targets 17, over the next few years ill start using newer features but I never rush to use them. Often they need to mature a bit first.

    • @superfunfactory8893
      @superfunfactory8893 3 ปีที่แล้ว

      @@javidx9 ah i see. Thank you

  • @GNARGNARHEAD
    @GNARGNARHEAD 3 ปีที่แล้ว

    Farkle!

  • @2012knp
    @2012knp 3 ปีที่แล้ว

    Gotta implement D&D in code as a practice

  • @khenryx86
    @khenryx86 3 ปีที่แล้ว

    The random method seems pretty fishy since it seems to keep on generating the same thing the first time you run it. Not that it matters. I just found that interesting

    • @javidx9
      @javidx9  3 ปีที่แล้ว +1

      It is fishy, but really essential! In fact I discuss randomness and pseudo randomness quite a bit in my programming the universe video.

    • @khenryx86
      @khenryx86 3 ปีที่แล้ว

      @@javidx9 Oh ok. I'll have to go give that a watch. I'm used to just doing what you did for your first random solution. It's good to know that there are simpler ways than the first tactic you think of😅

  • @TheTopHatCat
    @TheTopHatCat 3 ปีที่แล้ว

    Is there a particular reason you stay with C++17 vs any newer versions? Are you most familiar with v17?

    • @antoruby
      @antoruby 3 ปีที่แล้ว

      I believe it's because the next version, C++20, "just" came out and some features are not even fully implemented. en.cppreference.com/w/cpp/compiler_support/20

  • @killermonkey1392
    @killermonkey1392 3 ปีที่แล้ว

    Concerning the part about capturing member variables in the Lambda function: Why not just capture ˋthisˋ by value?

    • @tommytomtomtomestini3894
      @tommytomtomtomestini3894 3 ปีที่แล้ว

      In this small program it does not really matter, but a good habit is to only capture what you need. The capture does a bunch of voodoo behind the scenes, no need to do that on every member of "this".

    • @killermonkey1392
      @killermonkey1392 3 ปีที่แล้ว

      @@tommytomtomtomestini3894 But wouldn't capturing "this" only capture the pointer and add an implicit "this->" before every member that is accessed in the Lambda?

    • @tommytomtomtomestini3894
      @tommytomtomtomestini3894 3 ปีที่แล้ว +1

      @@killermonkey1392 I stand corrected, I guess it boils down to coding style.I prefer to be as explicit as I can,this gives me documentation and focus on what I'm doing :-)

  • @thepatrickcrab
    @thepatrickcrab 2 ปีที่แล้ว

    ctrl + f "small straight"
    Alright cool other people caught it too

  • @doniukz5823
    @doniukz5823 2 ปีที่แล้ว

    Gui ?

  • @tmbarral664
    @tmbarral664 3 ปีที่แล้ว

    !!SPOIL!! Next video Title:
    How I practice Programming: RegExp Engine
    where Dave tackles the writing of a RegExp Engine from scratch.
    ;)
    seriously.... it could be quite entertaining, don't you think ?

  • @33ordie
    @33ordie 3 ปีที่แล้ว

    Are you still coding in C99 ?

  • @Xtreme360boy
    @Xtreme360boy 3 ปีที่แล้ว +5

    First view, first comment. Mission passed.

  • @mohit6847
    @mohit6847 3 ปีที่แล้ว

    Sir please make a video series for making a NOSQL database like redis.

  • @devhonk1722
    @devhonk1722 3 ปีที่แล้ว

    Oh so the chips were for that!
    (also if you see this can i be on #scrapbook)

  • @nathanaelchannings7810
    @nathanaelchannings7810 3 ปีที่แล้ว

    Vimto.

  • @IgnoreMyChan
    @IgnoreMyChan 3 ปีที่แล้ว

    I really love your video's but the microphone popping is unbearable. Maybe filter the peaks or limit the bass frequencies, if you can't find a good mic filter or positioning.