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

WIP: screens: add dice app #1199

Closed
wants to merge 1 commit into from
Closed

Conversation

w4tsn
Copy link

@w4tsn w4tsn commented Jun 24, 2022

Hey there!

An app to do simple multi-dice rolls for games like D&D. The app makes use of the motionController and "wake on shake" setting (multiplied by a fixed amount) to allow rolling by shake movement. It also uses the motion sensor as random seed source.

InfiniSim_2022-06-24_074042
InfiniSim_2022-06-24_074053
InfiniSim_2022-06-24_074057

Let's talk if this is useful for the upstream project ;)

Todos:

  • don't re-roll through shake movement, if a roll is currently displayed
  • show roll statistics, such as lowest / highest roll, no. of 1s and 20s, 3 lowest rolls

An app to do simple multi-dice rolls for games like D&D.
@w4tsn w4tsn changed the title screens: add dice app WIP: screens: add dice app Jun 24, 2022
@Riksu9000
Copy link
Contributor

There's another dice app PR as well #565

@w4tsn
Copy link
Author

w4tsn commented Jun 24, 2022

Ah, nice! Should have expected as much :D I'll have a look at it and get in touch, thanks!

@w4tsn w4tsn closed this Jun 24, 2022
yusufmte added a commit to yusufmte/InfiniTime that referenced this pull request Sep 19, 2022
… seed

there are known problems with rand() and srand() (see https://en.cppreference.com/w/cpp/numeric/random/rand) and the <random> library is preferred for this reason. the function used from <random> also avoids a very rare bias that would occur using rand() and modulo, when RAND_MAX is not a multiple of d and the initially generated number falls in the last "short" segment. this commit also updates the seed to derive entropy (via seed_seq) from a mix of the system tick count and the x,y,z components of the pinetime motion controller-- taking inspiration from and with credit to @w4tsn (InfiniTimeOrg#1199)
FintasticMan added a commit to FintasticMan/InfiniTime that referenced this pull request Feb 3, 2023
Squashed commit of the following:

commit 4d37e1c
Merge: 159e73c 81bc16f
Author: Riku Isokoski <[email protected]>
Date:   Tue Jan 31 22:42:40 2023 +0200

    Merge branch 'develop' into dice

commit 159e73c
Merge: 7131e3c 09db67e
Author: Yusuf Ebrahim <[email protected]>
Date:   Sat Jan 7 19:51:07 2023 -0500

    Merge branch 'InfiniTimeOrg:develop' into dice

commit 7131e3c
Merge: feb8d14 afea7ca
Author: Yusuf Ebrahim <[email protected]>
Date:   Mon Dec 19 11:51:31 2022 -0500

    Merge branch 'InfiniTimeOrg:develop' into dice

commit feb8d14
Merge: 2f079de 081cc60
Author: Yusuf Ebrahim <[email protected]>
Date:   Sat Dec 17 13:39:47 2022 -0500

    Merge branch 'InfiniTimeOrg:develop' into dice

commit 2f079de
Merge: ee1f39b 361e381
Author: Yusuf Ebrahim <[email protected]>
Date:   Sun Dec 11 15:44:46 2022 -0500

    Merge branch 'InfiniTimeOrg:develop' into dice

commit ee1f39b
Author: yusuf ebrahim <[email protected]>
Date:   Sat Nov 5 18:31:05 2022 -0400

    in Dice, when rolling 1d2, also show "HEADS" or "TAILS" -- suggestion by @medeyko

commit cb940bf
Author: yusuf ebrahim <[email protected]>
Date:   Wed Nov 2 14:37:15 2022 -0400

    fix formatting

commit 5953c55
Author: yusuf ebrahim <[email protected]>
Date:   Mon Oct 31 10:45:44 2022 -0400

    in Dice, only show individual results if there are multiple dice

commit 257a593
Merge: b47b13a b56c5f2
Author: Yusuf Ebrahim <[email protected]>
Date:   Sun Oct 16 12:28:13 2022 -0400

    Merge branch 'InfiniTimeOrg:develop' into dice

commit b47b13a
Author: yusuf ebrahim <[email protected]>
Date:   Sat Oct 15 23:40:01 2022 -0400

    make Dice vibrate on roll

commit e789622
Merge: 8020132 d3ba184
Author: Yusuf Ebrahim <[email protected]>
Date:   Sat Oct 15 23:40:25 2022 -0400

    Merge branch 'InfiniTimeOrg:develop' into dice

commit 8020132
Merge: 11067bc 37155ec
Author: Yusuf Ebrahim <[email protected]>
Date:   Tue Oct 4 18:41:50 2022 -0400

    Merge branch 'InfiniTimeOrg:develop' into dice

commit 11067bc
Merge: 349e63a 7b115fe
Author: Yusuf Ebrahim <[email protected]>
Date:   Sun Oct 2 12:22:59 2022 -0400

    Merge branch 'InfiniTimeOrg:develop' into dice

commit 349e63a
Author: yusuf ebrahim <[email protected]>
Date:   Fri Sep 30 12:20:35 2022 -0400

    fix Dice.cpp formatting according to clang-format

commit f7bd3d6
Merge: 9d332c7 7972873
Author: Yusuf Ebrahim <[email protected]>
Date:   Fri Sep 30 03:22:33 2022 -0400

    Merge branch 'InfiniTimeOrg:develop' into dice

commit 9d332c7
Author: Yusuf Ebrahim <[email protected]>
Date:   Tue Sep 20 07:54:05 2022 -0400

    fix Dice.h code formatting

    Co-authored-by: NeroBurner <[email protected]>

commit 4647f8a
Author: yusuf ebrahim <[email protected]>
Date:   Tue Sep 20 07:40:13 2022 -0400

    fix formatting in Dice.h

commit 3923522
Author: yusuf ebrahim <[email protected]>
Date:   Mon Sep 19 17:32:57 2022 -0400

    fix code formatting in Dice.h

commit d64f926
Author: yusuf ebrahim <[email protected]>
Date:   Mon Sep 19 17:01:36 2022 -0400

    make typecasting within sseq uniform

commit 20e3023
Author: yusuf ebrahim <[email protected]>
Date:   Mon Sep 19 16:31:40 2022 -0400

    in Dice use <random> for initial color picking as well

commit c1b435b
Author: yusuf ebrahim <[email protected]>
Date:   Mon Sep 19 16:13:29 2022 -0400

    use <random> library for RNG in Dice and include motion controller in seed

    there are known problems with rand() and srand() (see https://en.cppreference.com/w/cpp/numeric/random/rand) and the <random> library is preferred for this reason. the function used from <random> also avoids a very rare bias that would occur using rand() and modulo, when RAND_MAX is not a multiple of d and the initially generated number falls in the last "short" segment. this commit also updates the seed to derive entropy (via seed_seq) from a mix of the system tick count and the x,y,z components of the pinetime motion controller-- taking inspiration from and with credit to @w4tsn (InfiniTimeOrg#1199)

commit f0cc97c
Author: yusuf ebrahim <[email protected]>
Date:   Sat Sep 17 22:19:39 2022 -0400

    clean up labels in Dice.cpp and remove duplicate code

commit ffb67d4
Merge: 13758ad 30e8353
Author: Yusuf Ebrahim <[email protected]>
Date:   Sat Sep 17 22:01:27 2022 -0400

    Merge branch 'InfiniTimeOrg:develop' into dice

commit 13758ad
Author: yusuf ebrahim <[email protected]>
Date:   Sat Sep 17 21:58:17 2022 -0400

    change starting die to d6

commit adc97a0
Author: yusuf ebrahim <[email protected]>
Date:   Fri Sep 16 16:19:42 2022 -0400

    removed unnecessary reference to SystemTask

commit 52e4af5
Author: yusuf ebrahim <[email protected]>
Date:   Thu Sep 15 14:44:50 2022 -0400

    implement rolling multiple dice in Dice

commit 6d23a14
Author: yusuf ebrahim <[email protected]>
Date:   Thu Sep 15 12:20:31 2022 -0400

    fix Dice seed to use system tick count

commit 616413d
Author: yusuf ebrahim <[email protected]>
Date:   Wed Sep 14 17:20:16 2022 -0400

    fix unchanging seed

commit 8ecfb49
Author: yusuf ebrahim <[email protected]>
Date:   Wed Sep 14 16:48:35 2022 -0400

    modify seed to avoid overflow error

commit b1e522f
Author: yusuf ebrahim <[email protected]>
Date:   Tue Sep 13 17:04:54 2022 -0400

    move NextColor() into private namespace of Dice

commit 21e5ec1
Author: yusuf ebrahim <[email protected]>
Date:   Tue Sep 13 17:03:18 2022 -0400

    remove unnecessary member variable in Dice.h

commit 3bd3d81
Author: yusuf ebrahim <[email protected]>
Date:   Tue Sep 13 17:00:56 2022 -0400

    use std::array to reduce unnecessary variables

commit 6c7d8c2
Author: yusuf ebrahim <[email protected]>
Date:   Tue Sep 13 16:56:21 2022 -0400

    remove unnecessary stored reference to dateTime in Dice.cpp

commit 1edfddd
Author: yusuf ebrahim <[email protected]>
Date:   Tue Sep 13 16:47:10 2022 -0400

    remove unnecessary stored reference to dateTime in Dice.h

commit b073b48
Author: yusuf ebrahim <[email protected]>
Date:   Tue Sep 13 16:29:29 2022 -0400

    apply clang-format to Dice.h

commit 7c011d6
Merge: f00d779 c853681
Author: Yusuf Ebrahim <[email protected]>
Date:   Mon Sep 12 10:11:08 2022 -0400

    Merge branch 'InfiniTimeOrg:develop' into dice

commit f00d779
Author: yusuf ebrahim <[email protected]>
Date:   Sun Sep 11 22:55:11 2022 -0400

    modify dice seed to use epoch time

commit 1996113
Author: yusuf ebrahim <[email protected]>
Date:   Sun Sep 11 22:54:13 2022 -0400

    increase number of app screens to 3

commit 172f20d
Merge: b37781a c9a5c3f
Author: Yusuf Ebrahim <[email protected]>
Date:   Sun Sep 11 09:02:38 2022 -0400

    Merge branch 'InfiniTimeOrg:develop' into dice

commit b37781a
Author: yusuf ebrahim <[email protected]>
Date:   Sun Sep 11 00:25:16 2022 -0400

    add dice app to app launcher

commit 12a565a
Author: yusuf ebrahim <[email protected]>
Date:   Sun Sep 11 00:16:46 2022 -0400

    add dice symbol

commit 6278008
Author: yusuf ebrahim <[email protected]>
Date:   Sun Sep 11 00:09:16 2022 -0400

    add "d" (0x64) to the range in jetbrains_mono_42 in fonts.json

commit b238d06
Author: yusuf ebrahim <[email protected]>
Date:   Sun Sep 11 00:07:37 2022 -0400

    include Dice.h and Dice.cpp into compilation in CMakeLists.txt

commit 4cc6776
Author: yusuf ebrahim <[email protected]>
Date:   Sun Sep 11 00:05:27 2022 -0400

    initial commit for Dice.h and Dice.cpp
NeroBurner added a commit that referenced this pull request Jan 23, 2024
Add new App `Dice.h` to randomly roll the dice(s).
The number of dice can range from 1-9 (default 1), and the sides can
range from d2-d99 (default d2).

To have a haptic feedback we make Dice vibrate on roll.

Regarding the use of C++ `<random>` library:
There are known problems with `rand()` and `srand()` (see https://en.cppreference.com/w/cpp/numeric/random/rand)
and the `<random>` library is preferred for this reason. The function used from
`<random>` also avoids a very rare bias that would occur using `rand()` and modulo,
when `RAND_MAX` is not a multiple of `d` and the initially generated number falls in
the last "short" segment. This commit also updates the seed to derive entropy
(via `seed_seq`) from a mix of the system tick count and the x,y,z components of the
PineTime motion controller -- taking inspiration from and with credit to @w4tsn
(#1199)

Thanks for suggestions:
* in Dice, when rolling 1d2, also show "HEADS" or "TAILS" -- suggestion by @medeyko
* ui adjustments and result realignment -- suggestion by @Boteium

---------

Co-authored-by: NeroBurner <[email protected]>
Co-authored-by: Riku Isokoski <[email protected]>
Co-authored-by: Paul Weiß <[email protected]>
Co-authored-by: FintasticMan <[email protected]>
lasnikr pushed a commit to lasnikr/LasnikrInfiniTime that referenced this pull request Mar 5, 2024
Add new App `Dice.h` to randomly roll the dice(s).
The number of dice can range from 1-9 (default 1), and the sides can
range from d2-d99 (default d2).

To have a haptic feedback we make Dice vibrate on roll.

Regarding the use of C++ `<random>` library:
There are known problems with `rand()` and `srand()` (see https://en.cppreference.com/w/cpp/numeric/random/rand)
and the `<random>` library is preferred for this reason. The function used from
`<random>` also avoids a very rare bias that would occur using `rand()` and modulo,
when `RAND_MAX` is not a multiple of `d` and the initially generated number falls in
the last "short" segment. This commit also updates the seed to derive entropy
(via `seed_seq`) from a mix of the system tick count and the x,y,z components of the
PineTime motion controller -- taking inspiration from and with credit to @w4tsn
(InfiniTimeOrg#1199)

Thanks for suggestions:
* in Dice, when rolling 1d2, also show "HEADS" or "TAILS" -- suggestion by @medeyko
* ui adjustments and result realignment -- suggestion by @Boteium

---------

Co-authored-by: NeroBurner <[email protected]>
Co-authored-by: Riku Isokoski <[email protected]>
Co-authored-by: Paul Weiß <[email protected]>
Co-authored-by: FintasticMan <[email protected]>
tmaklin pushed a commit to tmaklin/InfiniTime that referenced this pull request Jul 30, 2024
Add new App `Dice.h` to randomly roll the dice(s).
The number of dice can range from 1-9 (default 1), and the sides can
range from d2-d99 (default d2).

To have a haptic feedback we make Dice vibrate on roll.

Regarding the use of C++ `<random>` library:
There are known problems with `rand()` and `srand()` (see https://en.cppreference.com/w/cpp/numeric/random/rand)
and the `<random>` library is preferred for this reason. The function used from
`<random>` also avoids a very rare bias that would occur using `rand()` and modulo,
when `RAND_MAX` is not a multiple of `d` and the initially generated number falls in
the last "short" segment. This commit also updates the seed to derive entropy
(via `seed_seq`) from a mix of the system tick count and the x,y,z components of the
PineTime motion controller -- taking inspiration from and with credit to @w4tsn
(InfiniTimeOrg#1199)

Thanks for suggestions:
* in Dice, when rolling 1d2, also show "HEADS" or "TAILS" -- suggestion by @medeyko
* ui adjustments and result realignment -- suggestion by @Boteium

---------

Co-authored-by: NeroBurner <[email protected]>
Co-authored-by: Riku Isokoski <[email protected]>
Co-authored-by: Paul Weiß <[email protected]>
Co-authored-by: FintasticMan <[email protected]>
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.

2 participants