Re: developing a singular verses plural grammar system in your game

2020-07-25 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector


  


Re: developing a singular verses plural grammar system in your game

OK, I've updated my library. There's examples on the repo, and I've put type hinting and all that good stuff in.Here's a basic example taken from the repo:"""Provides a basic example of how the library can be used."""

from typing import List, Tuple
from attr import attrs
from emote_utils import PopulatedSocialsFactory


@attrs(auto_attribs=True)
class PretendObject:
"""An object with a name."""

name: str
pronoun: str


f: PopulatedSocialsFactory = PopulatedSocialsFactory()


@f.suffix('name', 'n')
def get_name(obj: PretendObject, suffix: str) -> Tuple[str, str]:
"""Get the name of the object."""
return ('you', obj.name)


bill = PretendObject('Bill', 'his')
jane = PretendObject('Jane', 'her')


def main() -> None:
strings: List[str] = f.get_strings('%1N smile%1s at %2n.', [bill, jane])
print(f'Bill sees: {strings[0]}')
print(f'Jane sees: {strings[1]}')
print(f'Everyone else sees: {strings[-1]}')


if __name__ == '__main__':
main()

URL: https://forum.audiogames.net/post/01/#p01




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: developing a singular verses plural grammar system in your game

2020-07-25 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector


  


Re: developing a singular verses plural grammar system in your game

Hi,I have spent some time tackling this in both Python and Dart.I wrote it a while ago, and I've used both packages in my own projects.Looking at the Python version, it's code is fairly outdated, and massively under-documented, which I'm in the process of fixing.The general idea is you have a social factory, which you can add suffixes to. The PopulatedSocialsFactory class already has the common ones, and you can add others with the suffix decorator.Each suffix takes 2 arguments: The object being worked (which will depend on your use case), and the textual name of the suffix. This is because you could have "n" and "name" doing the same thing.It should return a tuple of 2 items: The first being the text that should be sent to the object which is running the social, and the second to everyone else.For example:"%1N %1has gained 14 gold from %2n."Assuming a n (lower case) suffix which returns the name of the object, and the has / have suffix which is already defined. Also, 2 objects (%1 and %2): "Bill" and "Jane".This would yield 3 strings: The string to send to Bill, the string to send to Jane, and the string to be sent to all other bystanders.I appreciate this isn't the most complete overview in the world, and I'm going to work to bring the project into the 21st century, but it does work, and I'm more than happy to receive emails asking for help while I write up documentation and the like.

URL: https://forum.audiogames.net/post/555401/#p555401




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: developing a singular verses plural grammar system in your game

2020-07-24 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: developing a singular verses plural grammar system in your game

Fair enough.

URL: https://forum.audiogames.net/post/555270/#p555270




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: developing a singular verses plural grammar system in your game

2020-07-24 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: developing a singular verses plural grammar system in your game

@7I think the better question is whether or not 20 or 30 lines to wrap a template rendering library is worth the gains, not whether or not the solution needs to scale.  It's also simpler than trying to concatenate strings and do the formatting every time.But one other thing it gets: you combine it with gettext or whatever and it also works with localization pretty well.I'd paste the boilerplate but I always have to work it out every time and don't have an online game ready version.  However if you poke around in either Libaudioverse or Synthizer you can find examples of me using it to generate entire source files with very little code that's not actually doing math to stick in those files to set it up.If you're going to be online, you need at least the second and third person, and if it's PVP you also need the second variation of second person for when someone else does something to you, so overall I'm not sure why it's debatable whether or not you'd want to learn to set this up, unless we're talking about someone so new that they can't work it out.  Given that most of the templating libraries in Python are aimed at people who don't know how to program and only need to write HTML using something someone else wrote, that's unlikely in my opinion.I should also point out that the most advanced ones have if statements and loops.  SO if you go really, really far with this you totally can do things like loop over all the contents of a room right there in the string.

URL: https://forum.audiogames.net/post/555267/#p555267




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: developing a singular verses plural grammar system in your game

2020-07-24 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: developing a singular verses plural grammar system in your game

Yes, but how versatile a system do we generally need? If we're writing a text adventure or a MUD, that's different from occasional, predictable messages and sentence structures. Basically, when is the most generalizable solution necessary? I just plain haven't encountered the problems you mentioned, even though you are correct that they're problems, because my use cases are sufficiently limited that imperfect solutions work.Rereading the OP, though, I'm not sure how relevant what I've said really is, especially since there's the implication that a solution should be both readable and expandable if the project continues to grow.

URL: https://forum.audiogames.net/post/555258/#p555258




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: developing a singular verses plural grammar system in your game

2020-07-24 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: developing a singular verses plural grammar system in your game

@5For BGT or something that's probably the best you can do, but Python makes my string templating example 20 or 30 lines of boilerplate, then you can put anything in the string in any order, it's named, and you get object properties.  Also reading them from a file isn't an issue.Pronouns in a class doesn't scale because English is too irregular.  %-formatted strings doesn't scale because you have to format them at the call site, or always build messages of exactly the same form.  I.e. you can't easily do paragraphs.  Building the strings in code doesn't scale because you can't put them in your level files.

URL: https://forum.audiogames.net/post/555167/#p555167




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: developing a singular verses plural grammar system in your game

2020-07-24 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: developing a singular verses plural grammar system in your game

My approach has been to give the character class a method for getting pronouns / copula / have/has. I tend to construct messages directly, rather than use a template, so this tends to look like msg = them.name + " " + them.getHas() + " dropped " + them.getPossessive + " " + them.inv.name + "!"; A template with string_replace or format also works. Ex, "%n1 %h1 dropped %p1 %i1.", then have a function that takes the string and an array of characters, and have it replace the valid %whatevers based on the character's properties.

URL: https://forum.audiogames.net/post/555093/#p555093




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: developing a singular verses plural grammar system in your game

2020-07-23 Thread AudioGames . net Forum — Developers room : visualstudio via Audiogames-reflector


  


Re: developing a singular verses plural grammar system in your game

beside post 3 I'd like to point out that you can use format() of string functionanother thing is to use string library and use templates there (checkout it's documentation in python's standard library).

URL: https://forum.audiogames.net/post/555084/#p555084




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: developing a singular verses plural grammar system in your game

2020-07-23 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: developing a singular verses plural grammar system in your game

You can do this with something like jinja2 or any of the simpler templated languages, which offer a way to embed variables, etc, into strings.But in practice, how most of the mud codebases I've looked at solve this is by having you define 3 strings: "You cast magic missile on other", "Player casts magic missile on you", "Player a casts magic missile on player b".  You give these to a function that dispatches to everyone in the room plus the source and target and/or targets of the action, and it figures out which variant to show.  You're not going to do much better than this, because if you try to work it out with variables and flags you're going to discover that it's not so easy.  If you integrated with Jinja2 or another templating library, the function could just be:send_to(room, source, target,
"You cast magic missile on {{target}}",
"{{source}} casts magic missile on you",
"{{source}} casts magic missile on {{target}}")Where the variables are provided by the templating engine, and in fact are even able to be objects, i.e. you'd also have source.hp, etc, for free.

URL: https://forum.audiogames.net/post/555082/#p555082




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: developing a singular verses plural grammar system in your game

2020-07-23 Thread AudioGames . net Forum — Developers room : redfox via Audiogames-reflector


  


Re: developing a singular verses plural grammar system in your game

I'm a bit confused. Your title talks about a plural system, which can just be solved with a function, but from your post,  I think you're talking about pronouns?

URL: https://forum.audiogames.net/post/555079/#p555079




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


developing a singular verses plural grammar system in your game

2020-07-23 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


developing a singular verses plural grammar system in your game

Hi. My game does not have online support yet, but I would still like to make a clean system for if or when that time does come. When the user is given a message, it will either say:you have found this, or, they/character name has found this.It could also say:you are going to, or, they/character name is going to.In the bgt version, I solved this by creating a variable such as is_are, has_have, and depending on certain conditions it would set that variable value. Each time a player took their turn, it would look for, is this an online game, and is it your turn. It then gave the appropriate values for the next round. This system worked, but it was hard to read, and it had to be reset each round. Is there a better way I can do this? Like with a dictionary or something? Also could I make compounds such as you are, and they are, or you are, and character name is.

URL: https://forum.audiogames.net/post/555077/#p555077




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


developing a singular verses plural grammar system in your game

2020-07-23 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


developing a singular verses plural grammar system in your game

Hi. My game does not have online support yet, but I would still like to make a clean system for if or when that time does come. When the user is given a message, it will either say:you have found this, or, they/character name has found this.It could also say:you are going to, or, they/character name is going to.In the bgt version, I solved this by creating a variable such as is_are, has_have, and depending on certain conditions it would set that variable value. Each time a player took their turn, it would look for, is this an online game, and is it your turn. It then gave the appropriate values for the next round. This system worked, but it was hard to read, and it had to be reset each round. Is there a better way I can do this? Like with a dictionary or something?

URL: https://forum.audiogames.net/post/555077/#p555077




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector