Skip to content
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

Conditional PROB with ELSE / new OP WTOSS (Weighted Toss) #277

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

djwglpuppy
Copy link

@djwglpuppy djwglpuppy commented Sep 22, 2021

What does this PR do?

Adds Functionality to the following

  • PRB is now an alias of PROB

Having the extra character helps when createing complex patches based on Probability

PROB can now use the ELSE statement

A common use case is to use a Bernoulli gate. What this means is that it either goes to A OR to B based on a weighted coin toss

example/. (60% chance of triggering 1, otherwise trigger 2)

PRB 60: TR.P 1
ELSE: TR.P 2

How should this be manually tested?

See example above

I have,

  • [ X] updated CHANGELOG.md and whats_new.md
  • [X ] updated the documentation
  • updated help_mode.c (if applicable)
  • [X ] run make format on each commit
  • [X ] run tests

- PRB Alias for PROB
@cristianvogel
Copy link

cristianvogel commented Sep 23, 2021

Branching off prob is a good idea. The example you give is easily done with TR.P + 1 TOSS for equal chance, but you’re right that with the conditional PROB is a simpler way to weight the choice.

@tehn
Copy link
Member

tehn commented Sep 23, 2021

this is a nice addition, thank you.

i'm a little concern that the IF / PROB pattern in the documentation makes things a little confusing for first time readers, and it'd be better to mention PROB as an addendum to the IF/ELSE section.

@djwglpuppy
Copy link
Author

djwglpuppy commented Sep 23, 2021

thanks for reviewing thus far. I agree with the docs, it felt correct putting the PROB along side the the other conditional, but it comes across a little clunky. I will adjust.

also @tehn I am going to add to this PR a new sibling operator to PROB called WTOSS (WTOSS x where x is the weight from 0 to 100 (alias WT)) which is a weighted toss. It runs in a similar fashion but instead returns a 1 or 0 instead of being a conditional. I have been doing it manually all the time and thought it would be easier to just do stuff like

DEL ? WTOSS 90 300 3000: TR.P 1

or cascading weighted tosses based on this PR

PRB 50: TR.P 1
ELIF WT 70: TR.P 2
ELSE: TR.P 3 

@djwglpuppy
Copy link
Author

@tehn I added a new OP previously mentioned to this. I typically try to keep my PRs to a singular case, but I decided to add on since they are so similar in nature for working with weighted probabilities. I just built and tested these and really hope it makes it in the next release because I already see myself using this new stuff a ton. Thankfully it was fairly easy to implement with my abysmal c knowledge. Please lemme know if anything can be done more efficiently.

Refer to the comment above for testing WTOSS / WT

@djwglpuppy djwglpuppy changed the title Making PROB slightly more useful Conditional PROB with ELSE / new OP WTOSS (Weighted Toss) Sep 23, 2021
@djwglpuppy
Copy link
Author

djwglpuppy commented Sep 24, 2021

I put the PR out in the forum and some people made some interesting points about PROB sitting between an IF / ELSE that works for their workflow. Would be be better to split this into a new [sub]OP like BPROB? (BPRB) (B is for Bernoulli) That way existing PROB does not hurt their workflow.

https://llllllll.co/t/a-draft-of-some-prob-tweaks-i-made-for-teletype/48956/5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants