Comments (9)
I'm also enjoying the discussion.
$
and %
separation proposal
The idea was to make clear the distinction between the sum ($x
), and the dice list (%x
), when writing message. Technically, we could have the same distinction everywhere (in condition for example).
If proposal
You are totally right, my proposition is effectively a switch-case.
Keeping the current syntax working allows us to create logical "else if" on other value.
My proposition doesn't exclude being able to have logical else if
on other value.
- If
$x
could be used in expression (I guess it's the case, I can't test right know), then we can compare the value of a throw to the result of another. - If you can use
$x
or a dice operator (d
orl
) at the beginning of anif_else_bloc
to use another dice roll in the bloc.
1d10i:[>3]{"success"}[=0]{"fail"}
1d10;1d20;$1i:[>$2]{"You have a better 10 dice than your 20 dice"}{}
1d10;1d20;$1i:[>5]{%2i:[=20]{"critical success"}{"success"}}{"fail"}
Multiple string block proposal
The idea is to be able to factorize a map "Dice result" -> "Text value"
8d10;%1c[>6];%1c1;$2-$3;$4i:[>0]{"Success"}{i:[<0]{"Critical Fail"}{"Fail"}}" $4 [%1] [$0]" $4 [%1] [$0]"
Instead of (the bloc $4 [%1] [$0]
isn't repeated multiple time):
8d10;%1c[>6];%1c1;$2-$3;$4i:[>0]{"Success $4 [%1] [$0]"}{i:[<0]{"Critical Fail $4 [%1] [$0]"}{"Fail $4 [%1] [$0]"}}
It should make the writing of aliases more easier. Furthermore, you could have a display at the end of multiple command instead of just one if it's easier for you.
from diceparser.
All the % marks have been designed to allows user to select what he want to see.
It is really useful for instruction which works on the same dice.
8d10;$1c[>6];$1c1;$2-$3;$4i:[>0]{"Success %3 [%2] %1"}{i:[<0]{"Critical Fail %3 [%2]"}{"Fail %3 [%2]"}}
Result: Success 3 [3,3,9,3,8,5,7,6] 44,3,0,3,3
The command displays the result (success, fail or critical fail) and gives details about it.
$4 in this case is the number of success (can be negative).
%2 displays dice list and %1 displays all intermediate results.
The %1 is current display when there is no string result.
8d10;$1c[>6];$1c1;$2-$3
Result: 44,3,0,3,3
So Let me think about it:
It I want to do the same think with your proposal:
8d10;$1c[>6];$1c1;$2-$3;$4i:[>0]{"Success $4 [%1] [$1,$2,$3,$4]"}{i:[<0]{"Critical Fail $4 [%1] [$1,$2,$3,$4]"}{"Fail $4 [%1] [$1,$2,$3,$4]"}}
Am I right ?
I have one remark about it, your syntax is more position related than the current one.
It may be difficult to non-developper user but it gives a better granularity.
I think the gain worths the effort.
Don't hesitate to add several examples in the documentation and keep in mind those two ways of using instructions.
If you need help about implementing, do not hesitate to ask questions.
from diceparser.
So first of all, I didn't though (so I didn't tested either) that $x
could be used as a list of dice. I thought it was only replaced by the result of the expression x
. So for me 10d6;$1
was ill-formed, and it was needed to use (my new operator %
) %1
instead.
So for you example, it would have been (see the difference of use of $x
and %x
in the expressions):
8d10;%1c[>6];%1c1;$2-$3;$4i:[>0]{"Success $4 [%1] [$1,$2,$3,$4]"}{i:[<0]{"Critical Fail $4 [%1] [$1,$2,$3,$4]"}{"Fail $4 [%1] [$1,$2,$3,$4]"}}
Witch can be written in a much shorter way if $0
and %0
are implemented:
8d10;%1c[>6];%1c1;$2-$3;$4i:[>0]{"Success $4 [%1] [$0]"}{i:[<0]{"Critical Fail $4 [%1] [$0]"}{"Fail $4 [%1] [$0]"}}
But this example doesn't really show where my proposition shine. It's when you want to have multiple dice rolls, and intermediary results that you want to hide.
In the dice system, we roll characteristic
+ competences
dices with 6
faces. From pool of dices, some of them (the dragoon dices
) are rerolled (and the value is added) if the result is 6
. Then we sort the dices by value, we keep as much dices as our characteristic
and do the sum. It determine if the result is a success or a failure (it's compared to the difficulty of the test). The lower dices are summed and the result is divided by 3 witch is compared to a quality table (higher is better). In the end, we need to dispatch the dragoon dices, either by adding them in the quality
(and making the division by 3), or by replacing some who determine the success
(keeping the order of the dice and putting the lowest of the success
dices in the quality pool
). Yes it's crazy complicated, and I didn't even told you that you can brag before throwing your dices to move 1 or more dices from the success
to the quality
. Not my fault, it's capharnaum.
Let's say that I don't brag, I have 5
in characteristic
, 3
in competences and 1
point in dragoon
. I throw 5 + 3 = 8
dices, one of them being my dragoon dice
. I roll 8-1 = 7
dices. I sort them and keep the 5
best. I sum them to know if it's a success (the GM knows the difficulty). I take the 2
lower, divide the result by 3, and look at the quality
table. Then I take my dragon dice
and I decide if I prefer to replace one of the dices from the success
pool or add it to the quality.
Let's imagine that I have the following result:
- for the regular dices:
6 5 4 3 2 2 1
- for my dragoon dice:
5
I will keep6 + 5 + 4 + 3 + 2 = 20
as success, and `(2 + 1)/3 = 1 as quality.
Then I choose either to put my dragoon dice in the success
pool, or in the quality
pool. If I choose success
, I will have 6 + 5 + 5 + 4 + 3 = 23
in quality, and (2 + 2 + 1)/3 = 1.67
(rounded to 1) as quality. If I choose to put in in the success pool, I will have 6 + 5 + 4 + 3 + 2 = 20
as success and (5+2+1)/3 = 2.67
(rounded to 2) as quality.
7d6; # Normal dices: %1
1d6a[=6]; # Dragoon dices: %2
(%1m%2)k5;%1kl3/3; # first possibility: %3 and %4
%1k5;(%1m%2)kl3/3; # second possibility: %5 and %6
%1k5p[:green];%1kl5p[:blue]; # some colors to separates the potential success and quality without dragoon dices
"You can either have {$3 success, and $4 quality} or {$5 success and $6 quality } - Normal dices [%7 %8] - Dragoon dices [%2]"
I split it for readability, but obviously, it should be on one line, without the comments.
I assumed that you can concatenate two dices results with the m
operator being between the two lists (so %1m%2
, 1d3m%3
, 2L[sword,bow,knife,gun,shotgun]m%1
, (1d6m1d8)kl1
are all valid expressions).
It's not ideal because if you have more than 1 dragoon dice, it doesn't display all the possibility, but it would be possible to express it. For example, if you have up to two dragoon dices, the success will be, one of %1k5
, (%1+%2)k5
, (%1+(%2k1))k5 or (%1+(%2kl1))k5
. And then you create everything with nice aliases, and good use of the i
command! And obviously after that you convert the success to a string with the success table. Then you start to dominate the wold with your dice parser.
Now it's time for some additional remarks on the syntax.
It should be possible to have multiple "
blocks, that way we could do:
8d10;%1c[>6];%1c1;$2-$3;$4i:[>0]{"Success"}{i:[<0]{"Critical Fail"}{"Fail"}}" $4 [%1] [$0]" $4 [%1] [$1,$2,$3,$4]"
And finally the syntax of the i
operator should be modified to (without the parenthesis, it's just that the else_if bloc can be repeated):
i*[condition]{true_bloc}([condition]{else_if}...){else}
Witch remove the need of the second i
and the second sub {}
bloc. Obviously, the validator could still be :
, *
or +
, and the condition has the same syntax than currently (the square bracket aren't required if you want to test the equality).
That way we could finally write:
2d10;$1i[=2]{"Fail"}[=20]{"Critique"}{"Standard"}
instead of:
1d3;$1i[=1]{"Fail"}{i[=20]{"Critique"}{"Standard"}}
I may have missed some corrections in this comment, but it starts to be a bit late!
from diceparser.
Ok, we start to go somewhere.
I enjoy discussing with you about DiceParser.
Effectively capharnaum's system is a pain in the a**.
But it offers a good challenge and DiceParser already dominates the world but no one knows and it should stay that way :-p.
Some of problems you ran into are resulting of the history of modification.
I designed DiceParser with a certain amount of operator. But Some users came and asks about their games.
So I implemented new features and new operator.
First
someone asks to roll several kind of dice and apply some operator on them.
So I added the ';' and the merge operator.
Example:
1d6;1d8mk1 # Keep the best dice from both dice
Start Node -> NumberNode 1 -> rollDice (6 side) -> Separator node -> NumberNode 1 -> rollDice (8 side) -> mergeNode -> Keep 1.
At that time, the separator node prevents any node to read values/results from its parent.
The merge node removes the separator and reads all its parent nodes to create a diceResult with all dices.
Then, I added the notion of instruction and dynamic variable.
To manage that, I have a list of instructions. The previous command becomes that:
Instructions
1d6;1d8mk1 # Keep the best dice from both dice
Building exection tree
[NumberNode 1 -> rollDice (6 side),
NumberNode 1 -> rollDice (8 side) -> mergeNode -> Keep 1]
At the end of execution
[NumberNode 1 -> rollDice (6 side) -> NumberNode 1 -> rollDice (8 side) -> mergeNode -> Keep 1]
The merge node changes the whole execution tree. In fact, the operator could be rename to express that fact.
I think it becames less useful now with dynamic variables.
Dynamic Variables
2d6;$1c1;$1+4
The meaning of variable is not "list of dice or scalar result". It is the result of the instruction with all its types (string, scalar or list). Operator uses whatever they need.
first instruction we roll 2d6
then, we count how many 1 we got
then we add 4 at the result of the first instruction
Building exection tree
[Number 2 -> rollDice (6 side),
Dynamic Variable Node ($1) -> count node (if = 1),
Dynamic Variable Node ($1) -> Scalar operation node (+4)]
The node count and the scalar operation node works exactly they were behind the first instruction.
That is the semantic when you use $N.
I prefers $ because it is often used in script languages (php, bash and many more).
String Result
As some users ask for way to edit the final result and manage the text. I added some way to do it.
The replace operation between tag ($1 or %1..) inside the string result is performed by the client of DiceParser.
The cleverness about it has to be done inside client. Which is bad design.
I used %1...N inside String result because it is the default way in Qt to use argument in string.
QString msg("The document %1 can not be found");
qDebug() << msg.arg(filename);
So it makes the code easier in every client:
QString stringResult = parser->getLastStringResult();
qDebug() << stringResult.arg(AllFinalResults).arg(DiceResult).arg(LastSclaraResult);
About your proposal of the if syntax. It's a good idea but in fact is closer to a switch/case. Because condition always apply on the same value.
if(instruction1 == 1)
cout << "critical fail";
else if(instruction1 == 20)
cout << "Critical hit";
else
cout << "fail";
same things:
switch(instruction1)
{
case 1:
cout << "critical fail";
break;
case 20:
cout << "Critical hit";
break;
default:
cout << "fail";
break;
}
Keeping the current syntax working allows us to create logical "else if" on other value.
if(finalSuccessCount > 0)
cout << "Sucess";
else//fail
{
if(successCount == 0 )
cout << "critical fail";
else
count << "fail";
}
It could be really powerful to change validator to accept value to test.
[%1<5] or [$1<5]
But it can't break simple operator such as:
8d10c[>7]
Multiple string block proposal
I don't completely understood your need of additionnal string result.
from diceparser.
About $
and %
, I think that using !
instead of %
is better for multiples reasons. It doesn't break compatibility. And it doesn't clash wish a modulo operator neither. And finally it's the character used in a terminal to recall the previous command.
from diceparser.
I'm thinking about another way to make something similar.
My proposal it is just another way to make a switch/case and displaying some text.
My point is to use the L[] syntax and make it work as operator.
2d10k1+3L[Critical Fail[4],Fail[5-10],Success[11-20],Great Sucess[21-23]]
In this example, 2d10k1+3 is bound in [4:23]. So I split this set in some subset.
This probability are affected by the 2d10k1+3 and then, the translation in word is made.
About validator
To express the probability, I used range validator but any validator may be used.
About validator 2
I think it may be interesting to add a way to ask validator to compare the complete value of the dice; not the last generated. Otherwise, this command can't work:
dice "1d10e[>5]c[>10]"
Result: 0 - details:[1d10e[>5]c[>10] (34 [10,6,7,8,3])]
The e operator does its jobs. But the count does not see the 34. So the final result is 0.
My syntax proposal: put * just after the logical operator.
dice "1d10e[>5]c[>*10]"
from diceparser.
I like your ideas, but not the syntax you propose. IMHO you should use something similar to the i
operator.
For the switch operator, consider using a chain of [validator]comparator{expression}
, with the comparator (*
, .
and :
) being optionnal, like with i
. The last comparator could be empty to say "all the other results" (aka default
in C++). Like for i
, the square bracket in equality comparison (L[=x]
) could be ignored (you can use Lx
instead).
2d10k1+3L[4]{"Critical Fail"}[5-10]{"Fail"}[11-20]{"Success"}[21-23]{"Great Sucess"}
This syntax would allow some special effect, like rolling another dice if it's a critical success.
2d20L[=1]{"Critical Fail"}:[<5]{"Fail"}[=20]{"Critical Success";+1d6}[]{"Success"}
This mechanism could also be used to roll the damage dice automatically if you have a success with the number of faces determined by the result of the first roll.
EDIT: I re-read what I wrote and realized "Why did I use L
, i
would be better.", and then I realize it was the starting point!
For the e
operator, I also propose to unify the syntax by puting an optionnal comparator after the validator. The comparator could even be directly added to the syntax of the comparator.
1d10e[>5]e*[>10]
from diceparser.
The compare method must be associated with each condition.
We want to be able to write:
!2d100c[:>100 & >75]
We count one success if the sum is greater than 100 and for each dice greater than 75.
[76,76] => 2 successes
[76,1] => 0 successes
[76,50] => 1 success
In order to do that, we need to specify the method for each condition.
I agree with you, we must keep the if syntax: :
,*
,.
I created a branch to work on that but it is really complex to do. It will not be part of Rolisteam v1.9
The goal will be to be able to run:
2d6e[*=*]
In order to say: explode if all dice have the same value (are equals to each others).
from diceparser.
The syntax for placeholder completely change with the introduction of multiple-instruction command.
So, I think we can close this discussion.
Feel free to open a new tickets for new ideas and stuff.
Thanks!
from diceparser.
Related Issues (20)
- Problems with rerolling HOT 3
- Macros activated from comment (#) and sentence display ("") HOT 1
- Exploding Doubles HOT 1
- No valid value at index HOT 5
- Question re: Syntax for an IF statement based on an Entered Number and a Dice Roll. HOT 2
- Bot stopped working with Discord's latest version HOT 6
- Prefix not working HOT 3
- All dice prefix commands not working HOT 3
- Diceparser not working with webhook
- DiceParser not working September 2022 HOT 1
- /r works but ! does not HOT 5
- Help Noob please! Bot Setup steps for RPG HOT 2
- Weird handling of numbers in lists
- Bot frequently does not respond
- Bot Not Responding In Any Server
- bot does not allow users below the rank of admin to roll HOT 3
- Broken example in HelpMe.md HOT 1
- List weight doesn't seem to work
- Dice Parse offline? HOT 2
- Ambiguous licensing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diceparser.