Page 1 of 2 12 LastLast
Results 1 to 40 of 43

Thread: Contest 14 - DnD Dice Roller

  1. #1

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,725

    Contest 14 - DnD Dice Roller

    Programming Contest DnD Dice Roller

    For all those who haven't participated in the contest please read the FAQ

    Overview
    Given an input of dungeons and dragons dice commands, have the program execute the commands and show the user the results.

    For example, if I input 1D20 1d% then the program should output:
    Code:
    1D20 - 16
    1d% - 60


    Languages
    C#, F#, JavaScript (vanilla ES5), LUA, Python, Visual Basic 6, and VB.Net

    Deadline
    October 2nd, 2020

    Rules for Contest
    The rules followed will be specific to the contest and not the game.
    • You must submit the source code and include a fiddle(ideone, dotnetfiddle, codepen, etc.)
    • You are responsible for determining the syntax of the dice command
    • Allow for multiple dice commands
    • Include a help menu to assist the user
    • Acceptable dice types are:
      1. 4-sided
      2. 6-sided
      3. 8-sided
      4. 10-sided
      5. 12-sided
      6. 20-sided
      7. Percentage (percentages include increments of 10 from 0 - 90)



    Marking

    Each entry will be judged on the following things.
    • Accuracy - Does the program follow all of the rules?
    • Length - How concise is the submitted code?
    • Execution - How quick did the code execute?
    • Efficiency - How efficient is the algorithm(s) you chose?



    Prizes
    You will get to brag that you won a VBForums contest and I'll also include a special avatar!

    Please submit all entry's to the forum below with the title in the following format "Contest 14 - DnD Dice Roller - [User Name]"
    Contest Entries Forum
    Last edited by dday9; Sep 14th, 2020 at 10:32 AM.

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,222

    Re: Contest 14 - DnD Dice Roller

    So the format is

    <# of rolls>D<max value>?

    So like

    1D20 = 1 roll of 1-20
    4D5 = 4 rolls of 1-5
    2D% = 2 rolls of 1-100

    ?

  3. #3

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,725

    Re: Contest 14 - DnD Dice Roller

    I've updated my post to include the type types, but the format is correct (the output of 2D% would be different and 4D5 would be invalid because there isn't a 5 sided die).

  4. #4
    Junior Member wossy's Avatar
    Join Date
    Aug 2020
    Posts
    23

    Re: Contest 14 - DnD Dice Roller

    I'm starting to write my entry now. My entry will be in C# Core but I might do one in Ada as well just for fun

    Might be worth tweaking the rules a bit regarding percentage rolls. Standard percentage dice are numbered 00-90 and 0-9 (decades and units respectively), thus yielding values 0% through 99%.
    Last edited by wossy; Sep 13th, 2020 at 11:35 AM.
    On the bright side, I've still got pessimism and despair to fall back on.

  5. #5

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,725

    Re: Contest 14 - DnD Dice Roller

    Hmmm, I've always had a percentage die, which was 00-90 and then we rolled a D10 with it. So it would be 1D% + 1D10 to yield a percentage between 0-100.

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    33,019

    Re: Contest 14 - DnD Dice Roller

    IT depends on the die manufacturer.... I've got some that have the tens on them... others that have an odd colored 1d10 with just simple 0-9 on it... to be used as the tens... There is also a massive 1d100 out there.... so pick your poison and die carefully.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7
    Junior Member wossy's Avatar
    Join Date
    Aug 2020
    Posts
    23

    Re: Contest 14 - DnD Dice Roller

    I believe the D100 has been outlawed by international convention as an offensive weapon.

    I suppose it doesn't matter then as long as there are 100 distinct values available. In real life the DM would arbitrate any dispute and have final say no matter what.

    Any dissenting players can be handily eaten by a beholder.
    On the bright side, I've still got pessimism and despair to fall back on.

  8. #8

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,725

    Re: Contest 14 - DnD Dice Roller

    I shall be the DM of this competition and will thoroughly feed my beholders as I see fit.

  9. #9
    Junior Member wossy's Avatar
    Join Date
    Aug 2020
    Posts
    23

    Re: Contest 14 - DnD Dice Roller

    Ouch, looks like I need to roll a constitution save.
    On the bright side, I've still got pessimism and despair to fall back on.

  10. #10
    Junior Member wossy's Avatar
    Join Date
    Aug 2020
    Posts
    23

    Re: Contest 14 - DnD Dice Roller

    Submitted my lame attempt at an entry
    On the bright side, I've still got pessimism and despair to fall back on.

  11. #11

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,725

    Re: Contest 14 - DnD Dice Roller

    Got it!

  12. #12

  13. #13

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,725

    Re: Contest 14 - DnD Dice Roller

    Multiple dice can be rolled at once, the syntax would look something along the lines of: 1D8 1D% 6D4

    I'd expect, at minimum, for it show the results of each individual die roll (in this case 8 results).

  14. #14
    Junior Member wossy's Avatar
    Join Date
    Aug 2020
    Posts
    23

    Re: Contest 14 - DnD Dice Roller

    I suppose there's no harm in allowing additional features (as I have done in my entry) as long as they are not mandatory. It's nice to let people show off a bit, and might be useful in the event of a tie-break situation.
    On the bright side, I've still got pessimism and despair to fall back on.

  15. #15
    Hyperactive Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    374

    Re: Contest 14 - DnD Dice Roller

    What do you mean by
    "include a fiddle(ideone, dotnetfiddle, codepen, etc.)"
    and how do we do that ?
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  16. #16

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,725

    Re: Contest 14 - DnD Dice Roller

    In wossname's case, his program relied on command line arguments and so he wasn't able to submit a fiddle.

    However, the service I prefer for .NET console fiddles is dotnetfiddle.net. Follow these steps:
    1. Go to the website
    2. Specify the language: C#, VB.NET, or F#
    3. Copy/paste your code in the text editor
    4. Click on the Run button


    Once it runs, you can interact with the console via the split window at the bottom. In order to generate a link to your fiddle, click on the Share button.

    Here is an example: https://dotnetfiddle.net/PVKGWK

  17. #17
    Hyperactive Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    374

    Re: Contest 14 - DnD Dice Roller

    Hum and how do I pass the form, textbox, labels, help menu and other things in the fiddle?
    Last edited by Delaney; Sep 16th, 2020 at 04:50 PM.
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  18. #18

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,725

    Re: Contest 14 - DnD Dice Roller

    You can't, it is specifically for console applications. If you wanted to implement GUI then you wouldn't be able to submit a fiddle (which is fine).

  19. #19
    Hyperactive Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    374

    Re: Contest 14 - DnD Dice Roller

    An other question : it is not in the rules but do we have to check for input error and/or incorrect dice (1d7 for example) ?
    Last edited by Delaney; Sep 16th, 2020 at 04:54 PM.
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  20. #20
    Hyperactive Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    374

    Re: Contest 14 - DnD Dice Roller

    Ok, I submited my contribution. Thanks for the fun !

    regards
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  21. #21

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,725

    Re: Contest 14 - DnD Dice Roller

    Sorry for the late reply, error handling (including invalid syntax) is up to you but I'd appreciate if it were included.

  22. #22
    Hyperactive Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    374

    Re: Contest 14 - DnD Dice Roller

    Don't worry for the delay, it has been included anyway. Did you get my entry ? (as nothing appears, I don't know if it worked)
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  23. #23

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,725

    Re: Contest 14 - DnD Dice Roller

    Yes, the threads go into the moderator approval queue (similar to when new members post) and then from there we move it to a private moderator forum. Once the deadline is met, we move them back to the contest entries forum.

    This is so that other members can't see/study existing submissions until after the contest has ended.

  24. #24
    Junior Member wossy's Avatar
    Join Date
    Aug 2020
    Posts
    23

    Re: Contest 14 - DnD Dice Roller

    @dday9, how many entries so far?
    On the bright side, I've still got pessimism and despair to fall back on.

  25. #25

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,725

    Re: Contest 14 - DnD Dice Roller

    2

  26. #26
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    687

    Re: Contest 14 - DnD Dice Roller

    I wonder of those who have read these contest posts actually know what is required in terms of possible input and output? I know nothing about Dungeons Dragons and had an idea what the input will be (until I saw + !) but I don't what format of output is required eg post #5 1D% + 1D10 where does + come into this, how does rolling 2 die get one number etc. I'm not entering as this time C++ isn't an accepted language (fair enough) but if I was, I'd be asking for much more info.

    Has this put some off?
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2019 (16.7.6)

  27. #27
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,579

    Re: Contest 14 - DnD Dice Roller

    Quote Originally Posted by 2kaud View Post
    I wonder of those who have read these contest posts actually know what is required in terms of possible input and output? I know nothing about Dungeons Dragons and had an idea what the input will be (until I saw + !) but I don't what format of output is required eg post #5 1D% + 1D10 where does + come into this, how does rolling 2 die get one number etc. I'm not entering as this time C++ isn't an accepted language (fair enough) but if I was, I'd be asking for much more info.

    Has this put some off?
    Plus just means "and" in the colloquial sense, e.g. "1 and 1 is 2". Therefore "1D% + 1D10" means "one roll of the percentage die and one roll of the ten-sided die". As was explained earlier, the percentage die would yield a number in the range {0, 10, 20, ..., 90} and the ten-sided die would yield a number in the range 1-10 so adding those together yields a number on the range 1-100. As I have no experience with D&D, there's apparently none needed. That said, that doesn't seem to be part of this contest anyway, so it's a moot point.

  28. #28
    Hyperactive Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    374

    Re: Contest 14 - DnD Dice Roller

    I have seen only one time a dice with 100 faces and it is not practical.

    Name:  D--100-FACES__D100.JPG
Views: 91
Size:  53.9 KB


    In game to have a % we use two 10-faced dices (with different colors), one for the tenth and one for the unity and assemble them. Sometime, the dice for the tenth is written with 10 , 20, 30, etc instead of 1, 2, 3, ...


    Name:  de-10-faces-en-acrylique-pour-jouer.jpg
Views: 90
Size:  9.6 KBName:  de-10-faces-dizaine-en-acrylique-de-00-a-90.jpg
Views: 88
Size:  15.9 KB

    example : throw 2 dices, one blue and one red, decide that the blue is the tenth, the blue give 5 and the red give 8, the result is 58
    Last edited by Delaney; Oct 1st, 2020 at 09:58 AM.
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  29. #29
    Junior Member wossy's Avatar
    Join Date
    Aug 2020
    Posts
    23

    Re: Contest 14 - DnD Dice Roller

    Quote Originally Posted by dday9 View Post
    2
    Heh, at least we both get a guaranteed podium finish Sweet.
    On the bright side, I've still got pessimism and despair to fall back on.

  30. #30
    Junior Member wossy's Avatar
    Join Date
    Aug 2020
    Posts
    23

    Re: Contest 14 - DnD Dice Roller

    Quote Originally Posted by 2kaud
    Has this put some off?
    It's just a bit of fun. Just get the job done in any way you like. My own C# entry doesn't even conform to the rules as they are given (the 3rd party hosting sites do not offer commandline argument features).

    If you want to do a C++ version then go for it. We'll get it built and run it so it can be fairly judged against the other entries.
    On the bright side, I've still got pessimism and despair to fall back on.

  31. #31

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,725

    Re: Contest 14 - DnD Dice Roller

    Yeah, my C++ isn't the sharpest, but I could certainly judge it if you wanted to submit an entry.

  32. #32
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    687

    Re: Contest 14 - DnD Dice Roller

    Quote Originally Posted by jmcilhinney View Post
    Plus just means "and" in the colloquial sense, e.g. "1 and 1 is 2". Therefore "1D% + 1D10" means "one roll of the percentage die and one roll of the ten-sided die". As was explained earlier, the percentage die would yield a number in the range {0, 10, 20, ..., 90} and the ten-sided die would yield a number in the range 1-10 so adding those together yields a number on the range 1-100. As I have no experience with D&D, there's apparently none needed. That said, that doesn't seem to be part of this contest anyway, so it's a moot point.
    It means that if + (and - and x[*] and / and brackets) are allowed as per Wikipedia definition https://en.wikipedia.org/wiki/Dice_notation then you're got a different ballgame than just treating each roll as separate. An example given is 3x(2d6+4) which produces one number. This is what I meant when I said that the problem wasn't well defined.

    In the original overview in post #1, 1D% + 1D10 is an invalid input. 1D% 1D10 would give an output like:

    1D% - 60
    1D10 - 7

    but if arithmetic operators are required, then if the die rolled the same then 1D% + D10 is a valid input and would give the single number 67.

    ?????????????????????
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2019 (16.7.6)

  33. #33

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,725

    Re: Contest 14 - DnD Dice Roller

    I think replies 12 and 13 might clear it up a bit for you.

  34. #34
    Junior Member wossy's Avatar
    Join Date
    Aug 2020
    Posts
    23

    Re: Contest 14 - DnD Dice Roller

    Quote Originally Posted by 2kaud View Post
    if the die rolled the same then 1D% + D10 is a valid input and would give the single number 67.

    ?????????????????????
    Does it make any coherent sense to add a 1% resolution value to a 10% resolution value?
    On the bright side, I've still got pessimism and despair to fall back on.

  35. #35
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    687

    Re: Contest 14 - DnD Dice Roller

    According to the actual dice rules for DnD - yes. See posts #5, #12 and the wikipedia link.

    Although as dday9 points out in post #13 this isn't expected for this contest.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2019 (16.7.6)

  36. #36
    Junior Member wossy's Avatar
    Join Date
    Aug 2020
    Posts
    23

    Re: Contest 14 - DnD Dice Roller

    Quote Originally Posted by 2kaud View Post
    According to the actual dice rules for DnD - yes. See posts #5, #12 and the wikipedia link.

    Although as dday9 points out in post #13 this isn't expected for this contest.
    What an odd game.
    On the bright side, I've still got pessimism and despair to fall back on.

  37. #37
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    687

    Re: Contest 14 - DnD Dice Roller

    Quote Originally Posted by dday9 View Post
    Yeah, my C++ isn't the sharpest, but I could certainly judge it if you wanted to submit an entry.
    Humble effort submitted.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2019 (16.7.6)

  38. #38
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    33,019

    Re: Contest 14 - DnD Dice Roller

    Quote Originally Posted by wossy View Post
    What an odd game.
    How else should it work?You have two d10 dice.... one is for the tens, the other the ones.... you roll one, get the tens place, roll the other, get the ones place... add them together. The 1d% is simply the d10 that's designated as the tens place.

    So yeah, you need to roll both and add them. That's how you get a value from 0-99... depending on the situation the double naught is ends up being 100% so you go from 1-100.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  39. #39
    Junior Member wossy's Avatar
    Join Date
    Aug 2020
    Posts
    23

    Re: Contest 14 - DnD Dice Roller

    I misunderstood 1d% and thought it to be equivalent to the pair of percentage dice considered together as an atomic roll 0-99. Adding d10 to that would give values between 1-109.
    On the bright side, I've still got pessimism and despair to fall back on.

  40. #40
    Junior Member wossy's Avatar
    Join Date
    Aug 2020
    Posts
    23

    Re: Contest 14 - DnD Dice Roller

    Since the momentous occasion of the deadline for this illustrious struggle of wits has now elapsed, has the dedicated team of expert judges had enough time to reach a conclusion?
    I've yet to see any white smoke coming from dday9's chimney

    I'm not desperate to know or anything, it's just that this contest is the only thing that can save 2020 from being an unmitigated disaster for everyone.
    On the bright side, I've still got pessimism and despair to fall back on.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width