-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rely on tables to implement repetitions and improve use of math operations #1
base: master
Are you sure you want to change the base?
Conversation
…ns. Use a list of tables, one for each dice set, to store rolls and related information. Can be broken down into three parts: 1. Initial rolls. e.g., 3d6. 2. Modifications. e.g. exploding or keep highest. 3. Successes. Use an S3 class for the list of tables structure, storing other relevant information, like the command, in attributes. R6 might be better for this (particularly for the re-rolling of tables), but then we have to deal with the fact that R6 modifies in place, which is a bit counterintuitive for general R users. Successes could be pulled out as a method, but that would break the use of command as the primary way to set up the dice rolling parameters.
…e. Instead of storing a list, store a simple dataframe and use class methods to implement addition, subtraction, etc. The class dataframe will store all replications. Changed rolltable class and methods accordingly.
…assign the result)
…nitely long mathematical operations using anything from the Ops set of functions. Added documentation for roll_dice and rolltable.
…on where 1d6+1 results in tbls[[tbls[[2]]]]+1 instead of tbs[[1]]+tbls[[2]]
Adjust tests to account for changes in underlying functions regarding rolltables. Fix minor errors and simplify how matches for roll patterns are stored.
…tion of parameters; conform inherited methods.
😲😲😲 I did not expect any collaboration efforts on this ! I’m glad you were interested enough by the idea behind RollR to dig through my nooby code. I hope it wasn’t too much a pain to work with. Thank you for investing time in this. I will try your version and review your PR soon. It looks promising ! |
I finally got time to dive into your PR. It is indeed substantial ! I read almost all the code but I have troubles understanding some parts, especially since I never worked with classes in R. However the consistent documentation you wrote is helping me a lot. Anyway, I played around with it and I'm very happy to see that it works very well and in so many different ways, it is much powerful and got more potential than before. So thank you ! I just have concerns about user experience, ease of use, clarity of console feedback and tests but I think I will be able to work on it on my own once I understand correctly all your PR. Once again, thank you, I am learning a lot from your code. 💯 Ongoing Process:
|
This is a relatively substantial rethinking of how to handle rolling in order to accommodate repetitions. The structure is as follows:
print(rolltable("4d6!>6>=5", repetitions = 3), rolls = TRUE)
calculate(rolltable("4d6", repetitions = 100))
rolltable("4d6", repetitions = 5) + rolltable("20")
returns a rolltable_calculated class representing five repetitions of "4d6 + 20."The roll_dice function is modified to account for additional Ops, so that a user can enter an arbitrary formula such as
roll_dice("(4d6! + 20) * 3 - 1d4")
. A user can also do direct logical comparisons:roll_dice("2d20h1 > 10", repetitions = 100)
orroll_dice("2d20h1 > 2d20l1", repetitions = 100)
.Works with existing dice sets, and adds ability to handle:
print(rolltable("4d6h3", repetitions = 6), rolls = TRUE)
. Probably could use a user-friendly interface.