this post was submitted on 03 Oct 2023
1 points (66.7% liked)

Perchance - Create a Random Text Generator

448 readers
15 users here now

⚄︎ Perchance

This is a Lemmy Community for perchance.org, a platform for sharing and creating random text generators.

Feel free to ask for help, share your generators, and start friendly discussions at your leisure :)

This community is mainly for discussions between those who are building generators. For discussions about using generators, especially the popular AI ones, the community-led Casual Perchance forum is likely a more appropriate venue.

See this post for the Complete Guide to Posting Here on the Community!

Rules

1. Please follow the Lemmy.World instance rules.

2. Be kind and friendly.

  • Please be kind to others on this community (and also in general), and remember that for many people Perchance is their first experience with coding. We have members for whom English is not their first language, so please be take that into account too :)

3. Be thankful to those who try to help you.

  • If you ask a question and someone has made a effort to help you out, please remember to be thankful! Even if they don't manage to help you solve your problem - remember that they're spending time out of their day to try to help a stranger :)

4. Only post about stuff related to perchance.

  • Please only post about perchance related stuff like generators on it, bugs, and the site.

5. Refrain from requesting Prompts for the AI Tools.

  • We would like to ask to refrain from posting here needing help specifically with prompting/achieving certain results with the AI plugins (text-to-image-plugin and ai-text-plugin) e.g. "What is the good prompt for X?", "How to achieve X with Y generator?"
  • See Perchance AI FAQ for FAQ about the AI tools.
  • You can ask for help with prompting at the 'sister' community Casual Perchance, which is for more casual discussions.
  • We will still be helping/answering questions about the plugins as long as it is related to building generators with them.

6. Search through the Community Before Posting.

  • Please Search through the Community Posts here (and on Reddit) before posting to see if what you will post has similar post/already been posted.

founded 1 year ago
MODERATORS
 

I've come across a potential bug or unexpected behavior of .consumableList.

For example, we have the following lists:

animal
  pig
  cow
  chicken
  zebra
  crayfish
  jellyfish
  worm

output
  [x = animal.selectMany(5).consumableList, x.joinItems(", ")]

For example, x is a consumable list with 5 items like so: cow, cow, pig, chicken, zebra. The output will then output cow, cow, pig, chicken, zebra.

Then, to select the items from the consumable list, we can use x.selectOne. Outputting it:

output2
  [x.selectOne] [x.selectOne] [x.selectOne] [x.selectOne] [x.selectOne]

The expected output should be any combinations of 'cow, cow, pig, chicken, and zebra' e.g. cow pig cow zebra chicken.

However, it throws an error Looks like your consumableList ran out of items. This is the list in question: cow, cow, pig, chicken, zebra, and outputs an undefined.

I believe it is because consumable list takes 'unique' items. In which, the items in the list have only '4' unique items (cow, chicken, pig, zebra), but it has 5 items (cow, cow, chicken, pig, zebra).

I think the correct behavior of a 'consumable list' is to be able to deduct an item from a list and prevent it from being selected again (consuming it), instead of creating a 'unique list'.

Here is an example generator with the said problem.

top 2 comments
sorted by: hot top controversial new old
[–] perchance 2 points 1 year ago* (last edited 1 year ago) (1 children)

Thank you! Should be fixed now.

Technical details, if you're curious: The consumption code was relying on the "identity" of an item to know whether it has been consumed, which works for lists because each item has its own unique identity, but not with the JS array that is produced by selectMany because arrays can contain several instances of the exact same item. By "same item" and "identity", I mean not just that the text is the same, but the actual underlying data that they're pointing to in the computer's memory is the same. Like variables all pointing to the same list - e.g. [animalListAlias=animalList] will mean that animalListAlias refers to the exact same thing as animalList (rather than being a "copy" of animalList). So I've switched it so the "consumption tracking" uses "indices" of the array rather than the array items themselves. I think this should work fine, but let me know if you notice anything strange.

Thanks again for reporting this!

[–] VioneT 2 points 1 year ago

Thanks for updating it 🤗