{"id":22169745,"url":"https://github.com/thegenius/logicweaver","last_synced_at":"2025-03-24T17:23:42.269Z","repository":{"id":57726341,"uuid":"90338697","full_name":"thegenius/LogicWeaver","owner":"thegenius","description":null,"archived":false,"fork":false,"pushed_at":"2017-05-18T11:47:25.000Z","size":2673,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-29T22:18:14.019Z","etag":null,"topics":["behavior","behavior-tree","logic","logic-design","logic-programming"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thegenius.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-05T05:04:33.000Z","updated_at":"2017-05-18T10:07:13.000Z","dependencies_parsed_at":"2022-09-17T14:31:32.965Z","dependency_job_id":null,"html_url":"https://github.com/thegenius/LogicWeaver","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thegenius%2FLogicWeaver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thegenius%2FLogicWeaver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thegenius%2FLogicWeaver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thegenius%2FLogicWeaver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thegenius","download_url":"https://codeload.github.com/thegenius/LogicWeaver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245316135,"owners_count":20595389,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["behavior","behavior-tree","logic","logic-design","logic-programming"],"created_at":"2024-12-02T06:34:44.561Z","updated_at":"2025-03-24T17:23:42.235Z","avatar_url":"https://github.com/thegenius.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LogicWeaver\n[![travis-ci](https://travis-ci.org/thegenius/LogicWeaver.svg?branch=master)](https://travis-ci.org/thegenius/LogicWeaver)\n[![codecov](https://codecov.io/gh/thegenius/LogicWeaver/branch/master/graph/badge.svg)](https://codecov.io/gh/thegenius/LogicWeaver)\n[![maven-central](https://img.shields.io/badge/maven-1.0.0-green.svg)](http://search.maven.org/#search%7Cga%7C1%7Clogicweaver)\n[![apache-license](https://img.shields.io/badge/license-Apache--2.0-green.svg)](https://www.apache.org/licenses/LICENSE-2.0)\n\n## Inspiration\nINSPIRED BY   BEHAVIOR  TREE.  \nUSED     AS   BEHAVIOR  TREE.  \nMORE     THAN BEHAVIOR  TREE.  \nAND      MAKE EVERYBODY HAPPY.  \n\n  \nThe most tedious part of software development must be the implementation of bussiness logic. Engineers used to waste a lot of time on those if-else logic. There must be a new way to accomplish those task. This framework aims at providing a visual and editable way to write those logic code. I call it \"logic weaver\".\n\n## Setup with maven\n```xml\n\u003cdependencies\u003e\n\t\u003cdependency\u003e\n\t\t\u003cgroupId\u003ecom.lvonce\u003c/groupId\u003e\n\t\t\u003cartifactId\u003elogicweaver\u003c/artifactId\u003e\n\t\t\u003cversion\u003e1.0.0\u003c/version\u003e\n\t\u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n## Examples\n#### config -\u003e action -\u003e logic -\u003e executor\n\n```java\nimport com.lvonce.logicweaver.LogicDebug;\nimport com.lvonce.logicweaver.concepts.LogicResult;\nimport com.lvonce.logicweaver.interfaces.ILogicNode;\nimport com.lvonce.logicweaver.interfaces.ILogicAction;\nimport com.lvonce.logicweaver.interfaces.ILogicExecutor;\nimport com.lvonce.logicweaver.executors.LogicExecutor;\nimport com.lvonce.logicweaver.annotations.LogicActionNode;\nimport static com.lvonce.logicweaver.builders.LogicWeaver.*;\n\npublic class App {\n\n\tstatic class PersonConfig {\n\t\tpublic final int x;\n\t\tpublic final String y;\n\t\tpublic PersonConfig(int x, String y) {\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\t\t}\n\t}\n\n\tstatic class Person {\n\n\t\t@LogicAction(index=1)\n\t\tpublic static ILogicAction\u003cPerson, PersonConfig\u003e action1;\n\n\t\t@LogicAction(index=2)\n\t\tpublic static ILogicAction\u003cPerson, PersonConfig\u003e action2;\n\n\t\tstatic {\n\t\t\taction1 = (Person person, ILogicExecutor e, PersonConfig config)-\u003e{\n\t\t\t\tLogicDebug.debug(\"action1(%s, %s)\", config.x, config.y);\n\t\t\t\treturn LogicResult.TRUE;\n\t\t\t};\n\n\t\t\taction2 = (Person person, ILogicExecutor e, PersonConfig config)-\u003e{\n\t\t\t\tLogicDebug.debug(\"action2(%s, %s)\", config.x, config.y);\n\t\t\t\treturn LogicResult.FALSE;\n\t\t\t};\n\t\t}\n\t}\n\t\n\tstatic final ILogicNode logic = defineStart(Person.class)\n\t\t.genSequenceFalse(\n\t\t\tgenSequenceTrue(\n\t\t\t\tgenNode(Person.action1, new PersonConfig(1, \"config1\")),\n\t\t\t\tgenNode(Person.action2, new PersonConfig(1, \"config1\")),\n\t\t\t\tgenNode(Person.action1, new PersonConfig(1, \"config1\"))\n\t\t\t),\n\t\t\tgenParallelAnd(\n\t\t\t\tgenNode(Person.action1, new PersonConfig(1, \"config1\")),\n\t\t\t\tgenNode(Person.action2, new PersonConfig(1, \"config1\")),\n\t\t\t\tgenNode(Person.action1, new PersonConfig(1, \"config1\"))\n\t\t\t)\n\t\t).defineFinish();\n\n\tpublic static void main( String[] args ) {\n\t\tPerson person = new Person();\n\t\tLogicExecutor executor = new LogicExecutor(person, logic);\n\t\texecutor.run();\n\t}\n}\n```\n  \nYou can run this simple example under examples directory:\n```\ncd examples/helloworld\nmvn packge\njava -jar target/helloworld-1.0-SNAPSHOT-jar-with-dependencies.jar\n```\n\n## Where amazing happens\n#### GUI Json Editor -\u003e Json -\u003e Logic Definition Class\n```\nPM(production manager) | SE(software engineer) | QA(quality assurance)  \nPM: edit the global loigc in a visual way and change it any time  \nSE: implement the action node with simple and clear code  \nQA: simply test the action node without worry about global logic  \nAND MAKE EVERYBODY HAPPY.\n```\n\n## Design Concepts\n![containers](https://raw.githubusercontent.com/thegenius/LogicWeaver/master/docs/containers.png)\n\n## Node Status\n|Status|Description|\n|------|-----------|\n|Init   |with no result|\n|Waiting|result is a task, run the task will get the actual result|\n|Null   |result is meaningless, just ignore it|\n|True   |resutl is success|\n|False  |result is fail|\n|Discard|result is fatal error, discard and restart|  \n\n![status](https://raw.githubusercontent.com/thegenius/LogicWeaver/master/docs/status.jpg)\n\n\n## Basic Usage\n```\nGlobal View\n1.Config class can be defined as any POJO.\n2.Entity class can be defined without any limit.\n3.Action node must be static ILogicAction type and annotated with LogicActionNode.\n4.Logic definition must begin with defineStart and end with defineFinish.\n5.Executor takes entity and logic as constructor parameters.\n\nAction View\n1.Action return LogicResult.TRUE to indicate success.\n2.Action return LogicResult.FALSE to indicate fail.\n3.Action return LogicResult.NULL to indicate ignore.\n4.Action return LogicResult.DISCARD to indicate stop and clear.\n5.Action return ILogicFunction to give an extra task.\n6.Action can call any function of the entity, because entity passed by the first parameter.\n7.Action can call functions on executor to affect the logic running flow.\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthegenius%2Flogicweaver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthegenius%2Flogicweaver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthegenius%2Flogicweaver/lists"}