#include #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // 1. Define the initial game state uc.DefineVariable("p1_pos = 0"); uc.DefineVariable("p1_gold = 10"); uc.DefineVariable("p2_pos = 0"); uc.DefineVariable("p2_gold = 10"); // 2. Define the DSL rules auto t = uc.ExpressionTransformer(); t.FromTo("PLAYER {@Number:p} MOVES {@Number:n}", "p{p}_pos = p{p}_pos + {n}"); t.FromTo("PLAYER {@Number:p} GAINS {@Number:n} GOLD", "p{p}_gold = p{p}_gold + {n}"); // 3. Define the script for the turn auto game_turn_script = R"( PLAYER 1 MOVES 4 PLAYER 2 MOVES 2 PLAYER 1 GAINS 5 GOLD PLAYER 2 MOVES 3 )"; // 4. Execute the script uc.EvalStr(game_turn_script); // 5. Display the final state cout << "--- End of Turn State ---" << endl; cout << "Player 1 Position: " << uc.EvalStr("p1_pos") << endl; cout << "Player 1 Gold: " << uc.EvalStr("p1_gold") << endl; cout << "Player 2 Position: " << uc.EvalStr("p2_pos") << endl; cout << "Player 2 Gold: " << uc.EvalStr("p2_gold") << endl; }