Download fast lightweight expression evaluator
Author: c | 2025-04-24
Fast Lightweight Expression Evaluator listed as FLEE. Fast Lightweight Expression Evaluator - How is Fast Lightweight Expression Evaluator abbreviated? https FLEE - Fast Lightweight Expression Evaluator. Looking for abbreviations of FLEE? It is Fast Lightweight Expression Evaluator. Fast Lightweight Expression Evaluator listed as FLEE. Fast
Fast Lightweight Expression Evaluator - How is Fast Lightweight
Here are 63 public repositories matching this topic... Code Issues Pull requests Discussions A Json based Rules Engine with extensive Dynamic expression support Updated Mar 2, 2025 C# Code Issues Pull requests Discussions C# expressions interpreter Updated Mar 23, 2025 C# Code Issues Pull requests Fast Lightweight Expression Evaluator Updated Mar 22, 2022 C# Code Issues Pull requests A Simple Math and Pseudo C# Expression Evaluator in One C# File. Can also execute small C# like scripts Updated Sep 22, 2023 C# Code Issues Pull requests Discussions Editor for Microsoft RulesEngine - Blazor UI library intended for integration in Web or Desktop Updated Mar 6, 2025 C# Code Issues Pull requests C# Expression Parser for Unity3D Updated Mar 2, 2024 C# Code Issues Pull requests expression evaluator for .NET with built-in compiler Updated Sep 29, 2024 C# Code Issues Pull requests Discussions 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. Updated Oct 1, 2024 C# Code Issues Pull requests yet another csharp expression parser Updated Jul 15, 2022 C# Code Issues Pull requests Matheval is a mathematical expressions evaluator library written in C#. Allows to evaluate mathematical, boolean, string and datetime expressions Updated Aug 26, 2024 C# Code Issues Pull requests A C# library for parsing mathemitical expressions with support for parentheses and variables. Updated Sep 1, 2024 C# Code Issues Pull requests SQL Eval Function | Dynamically Evaluate Expression in SQL Server using C# Syntax. Updated Mar 11, 2025 C# Code Issues Pull requests Discussions Expressions Evaluator for .NET Updated Jul 9, 2024 C# Code Issues Pull requests Evaluates a math expression from a string. Supports variables and custom operators. Updated Apr 24, 2024 C# Code Issues Pull requests Discussions This .NET library allows you to evaluate and compile any mathematical expression from a string dynamically at runtime. It supports a wide range of operations and allows for the use of custom variables, operators, and functions. The evaluator can be configured for different contexts, such as scientific, programming, boolean math expressions. Updated Dec 21, 2024 C# Code Issues Pull requests Simple math expression parser library for Unity Updated May 29, 2023 C# Code Issues Pull requests Easy to use extensible calculator for .NET. Demonstrates Sprache toolkit grammar inheritance. Updated Mar 9, 2019 C# Code Issues Pull requests Evaluate C# Formulas at Runtime Updated Oct 10, 2020 C# Code Issues Pull requests A simple runtime C# Interpreter [ single script ] [ easy-to-use ] [ 0 GC & 0 boxing] [rich feature] Updated Oct 10, 2024 C# Code Issues Pull requests Efficient Processing, Compilation, and Execution of Expression Trees at Runtime Updated Mar 10, 2025 C# --> Improve this page Add a description, image, and links to the expression-evaluator topic page so that developers can more easily learn about it. Curate this topic Add this topic to your repo To associate your repository with the expression-evaluator topic, visit your repo's landing
Fast Lightweight Expression Evaluator - How is Fast
Skip to content Navigation Menu GitHub Copilot Write better code with AI Security Find and fix vulnerabilities Actions Automate any workflow Codespaces Instant dev environments Issues Plan and track work Code Review Manage code changes Discussions Collaborate outside of code Code Search Find more, search less Explore Learning Pathways Events & Webinars Ebooks & Whitepapers Customer Stories Partners Executive Insights GitHub Sponsors Fund open source developers The ReadME Project GitHub community articles Enterprise platform AI-powered developer platform Pricing Provide feedback Saved searches Use saved searches to filter your results more quickly Sign up # expression-evaluator Star Here are 7 public repositories matching this topic... Code Issues Pull requests Discussions Kotlin Multiplatform runtime infix expressions evaluator. Updated Dec 5, 2024 Kotlin Code Issues Pull requests A Kotlin/Java based mathematical expression solver. Supports custom operators, variables, and functions. Updated Apr 18, 2017 Kotlin Code Issues Pull requests A wrapper of the mathjs.org ( JavaScript library for Android to evaluate math expressions. Updated Jan 23, 2020 Kotlin Code Issues Pull requests Parse expressions like "Hi #name, #{user.isNew ? 'you're gonna like it' : 'welcome back'}!" within 5 microseconds! (0.005 ms) Updated Jun 16, 2022 Kotlin Code Issues Pull requests MEE Math Expression Evaluator Updated Sep 1, 2021 Kotlin Code Issues Pull requests A kotlin based extensible calculator Updated Apr 4, 2021 Kotlin Code Issues Pull requests Library written in Kotlin to help evaluate mathematical expressions that can be extended by custom operators and functions. Updated Nov 29, 2020 Kotlin Improve this page Add a description, image, and links to the expression-evaluator topic page so that developers can more easily learn about it. Curate this topic Add this topic to your repo To associate your repository with the expression-evaluator topic, visit your repo's landing page and select "manage topics." Learn moreFlee - Fast Lightweight Expression Evaluator
To reduce download time.The example images presented here were made available by Dr. C.H. Weischer of Biomedical Innovation.Download version 4.4 (dated 2011-11-20, size 296 kb)3D modelingThe 3D modeling plugin can produce models from either a depth map or a lathe profile, and a texture can be assigned to the model. Below are a few examples/tutorial pictures created with the plugin. Note that you can create these models yourself using only the images available from this page.Download the 3D modeling plugin version 1.07.2 (dated 2013-04-07 471 kb)Based on the six images of the copper coin above it is possible to produce a depth map. Using thisdepth map and the combined image as texture the following 3D model was constructed:3D model from lathe profile and texture:View 3D model (require VRML-enabled browser)Another way of creating a 3D model is to enter an expression for the lathe profile in the expression evaluator of Image Analyzer:The following is the expression for a semicircle:sqrt(1-y^2)Combined with a world map, this produces a globe. See also: Structure From Motion - an experimental method for creating 3D models from photographs of an object.3Shape - high precision 3D scanners.Feature-preserving resizeThis plugin can reduce the size of an image by removing "empty space" which means that instead of makingobjects smaller it just reduces the space between them. This can be practical if you want to reduce thewidth of an image without reducing the height. Normally such an operation would distort the image but this algorithm can in many cases do it without changing the height/width ratio of objects in the image.Note that it works by reducing empty space in the image so it works best for landscape photos where there are areas with few details.It can also be used to enlarge images. In that case it will try stretch empty space instead of objects. OriginalScaled to 80% width using standard algorithmScaled to 80% width using feature-preserving algorithm Download version 1.0 (226 kb)This .DLL file should be placed in the ProcessingPlugin folder below the program folder.Batch processingThe batch processing plugin can be used for automatic file format conversion,image processing/enhancement and HTML code. Fast Lightweight Expression Evaluator listed as FLEE. Fast Lightweight Expression Evaluator - How is Fast Lightweight Expression Evaluator abbreviated? httpsFast Lightweight Expression Evaluator .0
Obtain a description of the failure when the evaluation fails.Custom SymbolsBelow is an example that provides a custom unary function that returns the twice the value it receives. There is also acustom variable called foo which holds the constant 123.4.Double] = ["twice": {$0 + $0}]let parser = MathParser(variables: myVariables.producer, unaryFunctions: myFuncs.producer)let evaluator = parser.parse("power(twice(foo))")# Expression parsed and `twice(foo)` resolved to `246.8` but `power` is still unknownevaluator?.value // => nanevaluator?.unresolved.unaryFunctions // => ['power']'# Give evaluator way to resolve `power(246.8)`let myEvalFuncs: [String:(Double)->Double] = ["power": {$0 * $0}]evaluator?.eval(unaryFunctions: myEvalFuncs.producer) // => 60910.240000000005">let myVariables = ["foo": 123.4]let myFuncs: [String:(Double)->Double] = ["twice": {$0 + $0}]let parser = MathParser(variables: myVariables.producer, unaryFunctions: myFuncs.producer)let evaluator = parser.parse("power(twice(foo))")# Expression parsed and `twice(foo)` resolved to `246.8` but `power` is still unknownevaluator?.value // => nanevaluator?.unresolved.unaryFunctions // => ['power']'# Give evaluator way to resolve `power(246.8)`let myEvalFuncs: [String:(Double)->Double] = ["power": {$0 * $0}]evaluator?.eval(unaryFunctions: myEvalFuncs.producer) // => 60910.240000000005Instead of passing a closure to access the dictionary of symbols, you can pass the dictionary itself: 60910.240000000005">let parser = MathParser(variableDict: myVariables, unaryFunctionDict: myFuncs)evaluator?.eval(unaryFunctionDict: myEvalFuncs) // => 60910.240000000005PrecedenceThe usual math operations follow the traditional precedence hierarchy: multiplication and division is above additionand subtraction, so 1 + 2 * 3 - 4 / 5 + 6 evaluates the same as 1 + (2 * 3) - (4 / 5) + 6. There are threeadditional operators, one for exponentiations (^) which is higher than the previous ones, so 2 * 3 ^ 4 + 5 is thesame as 2 * (3 ^ 4) + 5. It is also right-associative, so 2 ^ 3 ^ 4 is evaluated as 2 ^ (3 ^ 4) instead of(2 ^ 3) ^ 4.There are two other operations that are even higher in precedence than exponentiation:negation (-) -- -3.4factorial (!) -- 12!Note that factorial of a negative number is undefined, so negation and factorial cannot be combined. In other words,parsing -3! returns nil. Also, factorial is only done on the integral portion of a number, so 12.3! will parse butthe resulting value will be the same as 12!. In effect, factorial always operates as floor(x)! or !(floor(x)).Implied MultiplicationOne of the original goals of this parser was to be able to accept a Wolfram Alpha math expression more or less as-is-- for instance the definition -- withoutany editing. Here is the start of the textual representation from the above link:x(t) = ((-2/9 sin(11/7 - 4 t) + 78/11 sin(t + 11/7) + 2/7 sin(2 tFLEE - Fast Lightweight Expression Evaluator
Swift-math-parserBasic math expression parser built with Point•Free'sswift-parsing package (v0.12.0). See the API documentation for developer info.NOTE: v3.1.0 uses swift-parsing v0.12 which requires Xcode 14 and ideally Swift 5.8(see their What's Changed doc for additional details).If you need to use an older version, use the tagged 3.0.1 release instead.Usage Example 0.0evaluator.eval("t", value: 0.25) // => 4.2426406871192848evaluator.eval("t", value: 0.5) // => 6evaluator.eval("t", value: 1.0) // => 0">let parser = MathParser()let evaluator = parser.parse("4 × sin(t × π) + 2 × sin(t × π)")evaluator.eval("t", value: 0.0) // => 0.0evaluator.eval("t", value: 0.25) // => 4.2426406871192848evaluator.eval("t", value: 0.5) // => 6evaluator.eval("t", value: 1.0) // => 0The parser will return nil if it is unable to completely parse the expression. Alternatively, you can call theparseResult to obtain a Swift Result enum that will have a MathParserError value when parsing fails. Thiswill contain a description of the parsing failure that comes from the swift-parsing library. input:1:81 | 4 × sin(t × π | ^ expected end of input)">let evaluator = parser.parseResult("4 × sin(t × π")print(evaluator)failure(error: unexpected input --> input:1:81 | 4 × sin(t × π | ^ expected end of input)By default, the expression parser and evaluator handle the following symbols and functions:Standard math operations: addition (+), subtraction (-), multiplication (*), division (/),and exponentiation (^)The factorial of a number (!) 1Constants: pi (π) and e1-argument functions: sin, asin, cos, acos, tan, atan, log10, ln (loge), log2, exp, ceil,floor, round, sqrt (√), cbrt (cube root), abs, sgn, and ! for factorial (see 1)2-argument functions: atan, hypot, pow 2alternative math operator symbols: × for multiplication and ÷ for division (see example above for use of ×)You can reference additional symbols or variables and functions by providing your own mapping functions. There are twoplaces where this can be done:MathParser.initEvaluator.evalIf a symbol or function does not exist during an eval call, the final result will be NaN. If a symbol is resolvedduring parsing, it will be replaced with the symbol's value. Otherwise, it will be resolved during a future eval call.Same for function calls -- if the function is known during parsing and all arguments have a known value, then it willbe replaced with the function result. Otherwise, the function call will take place during an eval call.You can get the unresolved symbol names from the Evaluator.unresolved attribute. It returns three collections forunresolved variables, unary functions, and binary function names. You can also use the evalResult to attempt anevaluation but alsoFast Lightweight Expression Evaluator .0 - Download
Tumult HyperEdit is a lightweight HTML editor with a preview pane that displays the web page live as you type. HyperEdit breaks the tedious cycle of writing html, saving the file, then reloading and viewing the page in the browser by combining the writing phase with the viewing phase. This clarifies the effects of your changes and speeds up the overall process of making a web page. W3C-based validation will red-underline any mistakes. It uses the same rendering engine found in Safari, so it is not only standards compliant, but also very fast.HyperEdit can be used for: Testing HTML to make sure it looks exactly as you want it.Testing and executing PHP code. Writing forum, blog, or journal entries. Interactively trying out CSS code. Running and debugging JavaScript. And creating whole websites. Main Features Preview pane quickly renders HTML, CSS, Javascript, or PHP as typed. Live HTML W3C-based validation with red underlines and an error drawer Code Snippets palette allows commonly used code and tags (open and close) to be saved and recalled using custom key stroke combinations Syntax highlighting for HTML, PHP, CSS, and Javascript with custom colors and fonts Files attached to the table in the Linked Filed drawer will cause a refresh of the web view when they are saved. Javascript code evaluator. View HTML source code generated by the PHP engine Color swatches palette allows inserting colors and saving favorites Regular expression find and replace (thanks to OgreKit) Option to not cache data, so externally changed files are reloaded every time. Style sheet menu allows pages to use different styles A delay timer, so the page will wait to render a specified amount of time after typing has stopped. Startup Items in advanced preferences allows HyperEdit to load documents on startupFixed some bugs.. Fast Lightweight Expression Evaluator listed as FLEE. Fast Lightweight Expression Evaluator - How is Fast Lightweight Expression Evaluator abbreviated? https FLEE - Fast Lightweight Expression Evaluator. Looking for abbreviations of FLEE? It is Fast Lightweight Expression Evaluator. Fast Lightweight Expression Evaluator listed as FLEE. FastComments
Here are 63 public repositories matching this topic... Code Issues Pull requests Discussions A Json based Rules Engine with extensive Dynamic expression support Updated Mar 2, 2025 C# Code Issues Pull requests Discussions C# expressions interpreter Updated Mar 23, 2025 C# Code Issues Pull requests Fast Lightweight Expression Evaluator Updated Mar 22, 2022 C# Code Issues Pull requests A Simple Math and Pseudo C# Expression Evaluator in One C# File. Can also execute small C# like scripts Updated Sep 22, 2023 C# Code Issues Pull requests Discussions Editor for Microsoft RulesEngine - Blazor UI library intended for integration in Web or Desktop Updated Mar 6, 2025 C# Code Issues Pull requests C# Expression Parser for Unity3D Updated Mar 2, 2024 C# Code Issues Pull requests expression evaluator for .NET with built-in compiler Updated Sep 29, 2024 C# Code Issues Pull requests Discussions 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. Updated Oct 1, 2024 C# Code Issues Pull requests yet another csharp expression parser Updated Jul 15, 2022 C# Code Issues Pull requests Matheval is a mathematical expressions evaluator library written in C#. Allows to evaluate mathematical, boolean, string and datetime expressions Updated Aug 26, 2024 C# Code Issues Pull requests A C# library for parsing mathemitical expressions with support for parentheses and variables. Updated Sep 1, 2024 C# Code Issues Pull requests SQL Eval Function | Dynamically Evaluate Expression in SQL Server using C# Syntax. Updated Mar 11, 2025 C# Code Issues Pull requests Discussions Expressions Evaluator for .NET Updated Jul 9, 2024 C# Code Issues Pull requests Evaluates a math expression from a string. Supports variables and custom operators. Updated Apr 24, 2024 C# Code Issues Pull requests Discussions This .NET library allows you to evaluate and compile any mathematical expression from a string dynamically at runtime. It supports a wide range of operations and allows for the use of custom variables, operators, and functions. The evaluator can be configured for different contexts, such as scientific, programming, boolean math expressions. Updated Dec 21, 2024 C# Code Issues Pull requests Simple math expression parser library for Unity Updated May 29, 2023 C# Code Issues Pull requests Easy to use extensible calculator for .NET. Demonstrates Sprache toolkit grammar inheritance. Updated Mar 9, 2019 C# Code Issues Pull requests Evaluate C# Formulas at Runtime Updated Oct 10, 2020 C# Code Issues Pull requests A simple runtime C# Interpreter [ single script ] [ easy-to-use ] [ 0 GC & 0 boxing] [rich feature] Updated Oct 10, 2024 C# Code Issues Pull requests Efficient Processing, Compilation, and Execution of Expression Trees at Runtime Updated Mar 10, 2025 C# --> Improve this page Add a description, image, and links to the expression-evaluator topic page so that developers can more easily learn about it. Curate this topic Add this topic to your repo To associate your repository with the expression-evaluator topic, visit your repo's landing
2025-04-09Skip to content Navigation Menu GitHub Copilot Write better code with AI Security Find and fix vulnerabilities Actions Automate any workflow Codespaces Instant dev environments Issues Plan and track work Code Review Manage code changes Discussions Collaborate outside of code Code Search Find more, search less Explore Learning Pathways Events & Webinars Ebooks & Whitepapers Customer Stories Partners Executive Insights GitHub Sponsors Fund open source developers The ReadME Project GitHub community articles Enterprise platform AI-powered developer platform Pricing Provide feedback Saved searches Use saved searches to filter your results more quickly Sign up # expression-evaluator Star Here are 7 public repositories matching this topic... Code Issues Pull requests Discussions Kotlin Multiplatform runtime infix expressions evaluator. Updated Dec 5, 2024 Kotlin Code Issues Pull requests A Kotlin/Java based mathematical expression solver. Supports custom operators, variables, and functions. Updated Apr 18, 2017 Kotlin Code Issues Pull requests A wrapper of the mathjs.org ( JavaScript library for Android to evaluate math expressions. Updated Jan 23, 2020 Kotlin Code Issues Pull requests Parse expressions like "Hi #name, #{user.isNew ? 'you're gonna like it' : 'welcome back'}!" within 5 microseconds! (0.005 ms) Updated Jun 16, 2022 Kotlin Code Issues Pull requests MEE Math Expression Evaluator Updated Sep 1, 2021 Kotlin Code Issues Pull requests A kotlin based extensible calculator Updated Apr 4, 2021 Kotlin Code Issues Pull requests Library written in Kotlin to help evaluate mathematical expressions that can be extended by custom operators and functions. Updated Nov 29, 2020 Kotlin Improve this page Add a description, image, and links to the expression-evaluator topic page so that developers can more easily learn about it. Curate this topic Add this topic to your repo To associate your repository with the expression-evaluator topic, visit your repo's landing page and select "manage topics." Learn more
2025-04-08Obtain a description of the failure when the evaluation fails.Custom SymbolsBelow is an example that provides a custom unary function that returns the twice the value it receives. There is also acustom variable called foo which holds the constant 123.4.Double] = ["twice": {$0 + $0}]let parser = MathParser(variables: myVariables.producer, unaryFunctions: myFuncs.producer)let evaluator = parser.parse("power(twice(foo))")# Expression parsed and `twice(foo)` resolved to `246.8` but `power` is still unknownevaluator?.value // => nanevaluator?.unresolved.unaryFunctions // => ['power']'# Give evaluator way to resolve `power(246.8)`let myEvalFuncs: [String:(Double)->Double] = ["power": {$0 * $0}]evaluator?.eval(unaryFunctions: myEvalFuncs.producer) // => 60910.240000000005">let myVariables = ["foo": 123.4]let myFuncs: [String:(Double)->Double] = ["twice": {$0 + $0}]let parser = MathParser(variables: myVariables.producer, unaryFunctions: myFuncs.producer)let evaluator = parser.parse("power(twice(foo))")# Expression parsed and `twice(foo)` resolved to `246.8` but `power` is still unknownevaluator?.value // => nanevaluator?.unresolved.unaryFunctions // => ['power']'# Give evaluator way to resolve `power(246.8)`let myEvalFuncs: [String:(Double)->Double] = ["power": {$0 * $0}]evaluator?.eval(unaryFunctions: myEvalFuncs.producer) // => 60910.240000000005Instead of passing a closure to access the dictionary of symbols, you can pass the dictionary itself: 60910.240000000005">let parser = MathParser(variableDict: myVariables, unaryFunctionDict: myFuncs)evaluator?.eval(unaryFunctionDict: myEvalFuncs) // => 60910.240000000005PrecedenceThe usual math operations follow the traditional precedence hierarchy: multiplication and division is above additionand subtraction, so 1 + 2 * 3 - 4 / 5 + 6 evaluates the same as 1 + (2 * 3) - (4 / 5) + 6. There are threeadditional operators, one for exponentiations (^) which is higher than the previous ones, so 2 * 3 ^ 4 + 5 is thesame as 2 * (3 ^ 4) + 5. It is also right-associative, so 2 ^ 3 ^ 4 is evaluated as 2 ^ (3 ^ 4) instead of(2 ^ 3) ^ 4.There are two other operations that are even higher in precedence than exponentiation:negation (-) -- -3.4factorial (!) -- 12!Note that factorial of a negative number is undefined, so negation and factorial cannot be combined. In other words,parsing -3! returns nil. Also, factorial is only done on the integral portion of a number, so 12.3! will parse butthe resulting value will be the same as 12!. In effect, factorial always operates as floor(x)! or !(floor(x)).Implied MultiplicationOne of the original goals of this parser was to be able to accept a Wolfram Alpha math expression more or less as-is-- for instance the definition -- withoutany editing. Here is the start of the textual representation from the above link:x(t) = ((-2/9 sin(11/7 - 4 t) + 78/11 sin(t + 11/7) + 2/7 sin(2 t
2025-03-29Swift-math-parserBasic math expression parser built with Point•Free'sswift-parsing package (v0.12.0). See the API documentation for developer info.NOTE: v3.1.0 uses swift-parsing v0.12 which requires Xcode 14 and ideally Swift 5.8(see their What's Changed doc for additional details).If you need to use an older version, use the tagged 3.0.1 release instead.Usage Example 0.0evaluator.eval("t", value: 0.25) // => 4.2426406871192848evaluator.eval("t", value: 0.5) // => 6evaluator.eval("t", value: 1.0) // => 0">let parser = MathParser()let evaluator = parser.parse("4 × sin(t × π) + 2 × sin(t × π)")evaluator.eval("t", value: 0.0) // => 0.0evaluator.eval("t", value: 0.25) // => 4.2426406871192848evaluator.eval("t", value: 0.5) // => 6evaluator.eval("t", value: 1.0) // => 0The parser will return nil if it is unable to completely parse the expression. Alternatively, you can call theparseResult to obtain a Swift Result enum that will have a MathParserError value when parsing fails. Thiswill contain a description of the parsing failure that comes from the swift-parsing library. input:1:81 | 4 × sin(t × π | ^ expected end of input)">let evaluator = parser.parseResult("4 × sin(t × π")print(evaluator)failure(error: unexpected input --> input:1:81 | 4 × sin(t × π | ^ expected end of input)By default, the expression parser and evaluator handle the following symbols and functions:Standard math operations: addition (+), subtraction (-), multiplication (*), division (/),and exponentiation (^)The factorial of a number (!) 1Constants: pi (π) and e1-argument functions: sin, asin, cos, acos, tan, atan, log10, ln (loge), log2, exp, ceil,floor, round, sqrt (√), cbrt (cube root), abs, sgn, and ! for factorial (see 1)2-argument functions: atan, hypot, pow 2alternative math operator symbols: × for multiplication and ÷ for division (see example above for use of ×)You can reference additional symbols or variables and functions by providing your own mapping functions. There are twoplaces where this can be done:MathParser.initEvaluator.evalIf a symbol or function does not exist during an eval call, the final result will be NaN. If a symbol is resolvedduring parsing, it will be replaced with the symbol's value. Otherwise, it will be resolved during a future eval call.Same for function calls -- if the function is known during parsing and all arguments have a known value, then it willbe replaced with the function result. Otherwise, the function call will take place during an eval call.You can get the unresolved symbol names from the Evaluator.unresolved attribute. It returns three collections forunresolved variables, unary functions, and binary function names. You can also use the evalResult to attempt anevaluation but also
2025-04-01DeucesA pure Python poker hand evaluation libraryInstallationImplementation notesDeuces, originally written for the MIT Pokerbots Competition, is lightweight and fast. All lookups are done with bit arithmetic and dictionary lookups. That said, Deuces won't beat a C implemenation (~250k eval/s) but it is useful for situations where Python is required or where bots are allocated reasonable thinking time (human time scale).Deuces handles 5, 6, and 7 card hand lookups. The 6 and 7 card lookups are done by combinatorially evaluating the 5 card choices, but later releases may have dedicated and faster algorithms for these.I also have lookup tables for 2 card rollouts, which is particularly handy in evaluating Texas Hold'em preflop pot equity, but they are forthcoming as well.See my blog for an explanation of how the library works and how the lookup table generation is done: (haven't posted yet)UsageDeuces is easy to set up and use.>> from deuces import Card>>> card = Card.new('Qh')">>>> from deuces import Card>>> card = Card.new('Qh')Card objects are represented as integers to keep Deuces performant and lightweight.Now let's create the board and an example Texas Hold'em hand:>> board = [>>> Card.new('Ah'),>>> Card.new('Kd'),>>> Card.new('Jc')>>> ]>>> hand = [>>> Card.new('Qs'),>>> Card.new('Th')>>> ]">>>> board = [>>> Card.new('Ah'),>>> Card.new('Kd'),>>> Card.new('Jc')>>> ]>>> hand = [>>> Card.new('Qs'),>>> Card.new('Th')>>> ]Pretty print card integers to the terminal:>> Card.print_pretty_cards(board + hand) [ A ❤ ] , [ K ♦ ] , [ J ♣ ] , [ Q ♠ ] , [ T ❤ ] ">>>> Card.print_pretty_cards(board + hand) [ A ❤ ] , [ K ♦ ] , [ J ♣ ] , [ Q ♠ ] , [ T ❤ ] If you have termacolor installed, they will be colored as well.Otherwise move straight to evaluating your hand strength:>> from deuces import Evaluator>>> evaluator = Evaluator()>>> print evaluator.evaluate(board, hand)1600">>>> from deuces import Evaluator>>> evaluator = Evaluator()>>> print evaluator.evaluate(board, hand)1600Hand strength is valued on a scale of 1 to 7462, where 1 is a Royal Flush and 7462 is unsuited 7-5-4-3-2, as there are only 7642 distinctly ranked hands in poker. Once again, refer to my blog post for a more mathematically complete explanation of why this is so.If you want to deal out cards randomly from a deck, you can also do that with Deuces:>> from deuces import Deck>>> deck = Deck()>>> board = deck.draw(5)>>> player1_hand = deck.draw(2)>>> player2_hand = deck.draw(2)">>>> from deuces import Deck>>> deck = Deck()>>> board = deck.draw(5)>>> player1_hand = deck.draw(2)>>> player2_hand = deck.draw(2)and print them:>> Card.print_pretty_cards(board) [ 4 ♣ ] , [ A ♠ ] , [ 5 ♦ ] , [ K ♣ ] , [ 2 ♠ ]>>> Card.print_pretty_cards(player1_hand) [ 6 ♣ ] , [ 7 ❤ ] >>> Card.print_pretty_cards(player2_hand) [ A ♣ ] , [ 3 ❤ ] ">>>> Card.print_pretty_cards(board) [ 4 ♣ ] , [ A ♠ ] , [ 5 ♦ ] , [ K ♣ ] , [ 2 ♠ ]>>> Card.print_pretty_cards(player1_hand) [ 6 ♣ ] , [ 7 ❤ ] >>> Card.print_pretty_cards(player2_hand) [ A ♣ ] , [ 3 ❤ ]
2025-03-28