bijington / expressive

Expressive is a cross-platform expression parsing and evaluation framework. The cross-platform nature is achieved through compiling for .NET Standard so it will run on practically any platform.
MIT License
165 stars 26 forks source link

Record usages of the library #25

Closed bijington closed 3 years ago

bijington commented 6 years ago

It would be great to know a little about what people have used this library for and why :).

At the very minimum it would be great to know the technologies that you are using this within. I would love to update the library to make use of things like Span but I am wary of impacting anyone that currently uses the product.

I will go first :).

bijington commented 6 years ago

We use this library in a product that spans both a server side component and 2 client side components.

Each platform/component is broken down below:

Server side

.NET Version: ASP.NET v4.6.1 Usage: it used inside a custom form designer to define custom validation/calculations on values entered in to the forms. It is also used when consuming and filling in the forms.

Client side (WPF)

.NET Version: WPF & .NET v4.0 Usage: the client consumes the designs created in the Server side component and evaluates them as forms are filled in. Notes: this client is hopefully going to be made obsolete soon. It was compiled down to v4.0 to allow support for XP which has now been declared no longer required.

Client side (Xamarin Forms)

.NET Version: Xamarin Forms & .NET Standard v2.0 Usage: the client consumes the designs created in the Server side component and evaluates them as forms are filled in.

bijington commented 6 years ago

Another product this is used within is a document data extraction tool.

Data extraction tool

.NET Version: C# .NET 4.5.2 Usage: templates are designed to allow certain parts of PDF or XML files to be extracted and stored in a database. Expressive is used to define and perform validation on the data extracted.

ghauan commented 6 years ago

Hi

Haven't really gone over to this version yet, still using NCALC, but following this since NCALC has been "closed". I am using it in a windows service, using C# and .Net Framework 4.

The service is performing simple calculations on some data based on formulas that users has stored in a database. The formulas will contain variables/unknowns that are filled with some data at runtime and a result is returned.

bijington commented 6 years ago

@ghauan that's great thank you for sharing this. I hope that the library can replace NCalc without any issues for you.

TyelorD commented 5 years ago

I'm using Expressive in a Unity 3D project I'm working on, and I'm using it in order to allow systems to be loaded at startup.

Using Expressive allows me to store an expression in an XML file, and then I can load the XML at the start of the game during the initial loading, and use the expression throughout the game for various systems. Ultimately the goal being to have all the systems, including the equations that they use, to be modifiable by modders, and to allow much easier and quicker tweaking and balancing of systems (without recompiling the project).

For example I am loading an XML file full of "StatDefs", and then loading the mod XML files which may over-write and/or add to StatDefs.xml. Then with the modified StatDefs I generate the stats for the actual game entities, using Expressive to calculate the value of the stats at any given point in time.

For example:

    <Variable ID="st_maxhp" Name="Max HP" Type="ARRAY">
      <Value xsi:type="VariableArray">
        <Variable ID="st_maxhp.base" Name="Base Value" Type="INT">
          <Value xsi:type="xsd:int">100</Value>
        </Variable>
        <Variable ID="st_maxhp.bonus" Name="Bonus Value" Type="INT">
          <Value xsi:type="xsd:int">0</Value>
        </Variable>
        <Variable ID="st_maxhp.factor" Name="Factor" Type="FLOAT">
          <Value xsi:type="xsd:float">1</Value>
        </Variable>
        <Variable ID="st_maxhp.value" Name="Value" Type="EXPRESSION">
          <Value xsi:type="Expression">
            <ExpressionString>Round( ( [st_maxhp.base] + [st_maxhp.bonus] + 5 * [st_hull.value] * Pow( 1.005, [st_hull.value] ) ) * [st_maxhp.factor] , 0)</ExpressionString>
          </Value>
        </Variable>
      </Value>
    </Variable>
    <Variable ID="st_hull" Name="Hull" Type="ARRAY">
      <Value xsi:type="VariableArray">
        <Variable ID="st_hull.base" Name="Base Value" Type="INT">
          <Value xsi:type="xsd:int">0</Value>
        </Variable>
        <Variable ID="st_hull.bonus" Name="Bonus Value" Type="INT">
          <Value xsi:type="xsd:int">0</Value>
        </Variable>
        <Variable ID="st_hull.factor" Name="Factor" Type="FLOAT">
          <Value xsi:type="xsd:float">1</Value>
        </Variable>
        <Variable ID="st_hull.value" Name="Value" Type="EXPRESSION">
          <Value xsi:type="Expression">
            <ExpressionString>Max( Min( Round( ( [st_hull.base] + [st_hull.bonus] ) * [st_hull.factor] , 0), 512 ), -128 )</ExpressionString>
          </Value>
        </Variable>
      </Value>
    </Variable>

The system is still very much work in progress, but Expressive made the Expression evaluation very quick and painless, and it definitely saved me a ton of time from writing my own infix calculator (which I've written a very simple version of in Java previously, but it only handles operands, no functions, variables, or conditionals). So having the extra power provided by Expressive will likewise give any modders a huge amount of power to play around with the game's systems!

Thanks so much for this awesome open source project!

bijington commented 5 years ago

@TyelorD that is really cool! Even cooler that it is being used in an environment that I hadn’t originally intended. Once the game is live please do let me know 🙂

Thank you for sharing.

TyelorD commented 5 years ago

@bijington thank you so much! I thought it was super cool that your Expressive library worked in Unity almost right out of the box!

Unity recently started supporting .NET 4.x and so with that addition it now fully supports Expressive (at least as far as I can tell, but I use Windows).

I'll later test the multi-platform compilation of Expressive and make sure it works on Unity builds for Linux and MacOS. Since Unity compiles all code down to Mono however regardless of platform (minus mobile/web), the fact that it works on a Windows build is evidence it works across any Unity build :crossed_fingers: I could definitely let you know the my findings too, if you're interested in them.

As for the release of the game, I do have an infrequently updated Twitter account and YouTube channel, where I sometimes post updates on the development of my games. I'm also a solo developer (and currently still a CS student), I've only published 3 very small games so far, and I haven't worked in the industry professionally, so I wouldn't expect too much out of the game when it's live :wink:

bijington commented 5 years ago

@TyelorD it has been some time since I have used Unity but it is great that it is all working.

I would hope that you don't have any compilation issues on the other platforms. We have been using this were I work with Xamarin and have been compiling it on MacOS too. Do let me know if there are any issues!

The videos for the game look pretty cool man! You should be proud of that! It's also cool you are doing this early on in your career, I really wish I had started to look at things sooner in life. I will definitely keep an eye on the status of the game, I keep going over some game ideas but never manage to find the time to get it into any testable form.

TyelorD commented 5 years ago

@bijington I think if you have no problems with running it on Xamarin and MacOS I'm confident it will work on all platforms on Unity as well. I'll definitely let you know if there are any issues though!

Thanks so much for your kind words too! It really means a lot to me, and I'm really glad you think the game looks pretty cool too! I've always had a passion for making games, so I never really thought of it as starting early or anything but more of just me having some in my free time. But I definitely agree that finding the time to work on your game ideas is by far the hardest part for me too...

Larry57 commented 5 years ago

Hi, I am using Expressive instead of NCalc to convert input data units from a historian to inputs a calculation model for a blast furnace energy balance. It works just great, and it is a joy to use. I particularly enjoy the fact there is a way to retrieve variable used in an expression, because their values are usually provided by external sources which needs to be populated prior evaluation. Thank you very much for this library !

bijington commented 5 years ago

@Larry57 thank you for sharing the detail of your implementation and most importantly for using it 🙂.

I am glad it is working well for you.

ninocamdzic commented 5 years ago

Hi, I'm using Expressive in a dialog system which I'm creating for an Unity project. The player and npc responses can have conditions. Sometimes the user must meet certain criteria before an response is visible. The npc can also react differently if certain criteria is met. Thanks a lot for this great library!

bijington commented 5 years ago

@ninocamdzic that is great, thank you for sharing!

Out of interest would you be willing to share any of the details of the game when it gets released (if of course it hasn't already)?

ninocamdzic commented 5 years ago

@bijington Sure. Something in particular that you are interested in? We are making a CRPG and the full game isn't released yet and I don't expect it to be any time soon. However we are working on a demo which will have all the systems needed and will have the first region with a couple of quests. I have a lot of systems implemented but some are partially implemented and some are almost finished:

These are just a couple that I have recently worked on. Let me know what you are interested in and I'll see what I can share.

bijington commented 5 years ago

@ninocamdzic that is looking great!

Please don’t go to any extra effort to get something ready for me. I’ll happily wait until something is playable and I am more than happy to be a beta tester, etc. 🙂

ninocamdzic commented 5 years ago

@bijington No problem. When I have something I'll let you know. :)