{"id":20372783,"url":"https://github.com/sidmishraw/scriptwars","last_synced_at":"2026-04-18T07:35:44.708Z","repository":{"id":86400701,"uuid":"103219767","full_name":"sidmishraw/scriptwars","owner":"sidmishraw","description":"Script Wars ∩༼˵☯‿☯˵༽つ¤=[]:::::\u003e","archived":false,"fork":false,"pushed_at":"2017-09-14T05:31:33.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-04T20:43:20.932Z","etag":null,"topics":["java8","javascript","multi-agent","nashorn","nashorn-engine","scriptwars","transport"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sidmishraw.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-12T03:54:38.000Z","updated_at":"2017-09-14T05:32:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"cd8959e9-c004-45ad-b834-3c74839185fc","html_url":"https://github.com/sidmishraw/scriptwars","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sidmishraw/scriptwars","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidmishraw%2Fscriptwars","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidmishraw%2Fscriptwars/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidmishraw%2Fscriptwars/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidmishraw%2Fscriptwars/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sidmishraw","download_url":"https://codeload.github.com/sidmishraw/scriptwars/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidmishraw%2Fscriptwars/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31961347,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["java8","javascript","multi-agent","nashorn","nashorn-engine","scriptwars","transport"],"created_at":"2024-11-15T01:14:53.432Z","updated_at":"2026-04-18T07:35:44.693Z","avatar_url":"https://github.com/sidmishraw.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Scriptwars\n#\n# ∩༼˵☯‿☯˵༽つ¤=[]:::::\u003e\n\nAuthor: Sidharth Mishra \u003c\u003c sidmishraw@gmail.com \u003e\u003e\n\n\n\n## Motivation(?)\n\nJust for Fun! Jk\nTo check out the ways we can stream/transport compute in distributed/multi-agent networks (?) \n\nPersonally, I use it for fun lol!\n\nThis application simulates a way of transporting compute over the network. The scriptwar consists of a HTTP webserver.\n\nThe game has 2 contexts `/attack` and `/receive`.\n\n\n\t**AND**\n\n\nThe server has 2 contexts `/serialize` and `/deserialize`.\n\n\n## `/attack`\nThe `/attack` context is used to submit the attack to the opponent via a POST request. It takes the `host` and `port` of the agent to attack as `x-www-form-urlencoded` parameters. The attack's damage is computed from the js script used while starting the game!\n\n\n## `/receive`\nThe `/receive` context is used to receive the attack from the opponent via a POST request. If the your HP drops below `0`, your game ends and the application ends.\n\n## JS Script template\n\nThe js file named warscript is the template that needs to be modified. It needs the `computeDamage` function. Please do not modify the function signature. The body of the function is actually what needs to be modified to do the damage.\n\nHave fun!\n\n\n## Samples:\n\nAgent#1\n```\nsidmishraw@Sidharths-MBP ~/Desktop\u003e java -jar scriptwars.jar localhost 3030 warscript.js \nHost:: localhost :: Port :: 3030\n\n\n\nReceiving attack from :: /receive\nComputing damage!\nDamage received:: 100.0\nYour HP:: 270.7929315264443\nComputing the attack\nAttacking agent at :: localhost:3050\nInitiating attack...\nLogging:: Attack object :: StandardLambdaObject [objectId=Sid#0001, lambdaJSScript=/** * `computeDamage` is the function that specifies the damage to be dealt to the * opponent. The `baseDamage` and `randomMultiplier` are mandatory and are set * randomly when the script executes. *  * To print stuff or display messages, you can use `println()` or `print()` *  * @param baseDamage *            the baseDamage of the attack, a double * @param randomMultiplier *            the random multiplier that can be used in the attack, a double *  * @return the computed damage, a double */var computeDamage = function (baseDamage, randomMultiplier) {\tprint(\"Computing damage!\");\treturn 150.0;};]\nAwaiting response...\nAttack stats :: Attack succeeded, damage dealt :: 150.0\n```\n\nAgent#2\n```\nsidmishraw@Sidharths-MBP ~/Desktop\u003e java -jar scriptwars.jar localhost 3050 warscript2.js \nHost:: localhost :: Port :: 3050\n\nComputing the attack\nAttacking agent at :: localhost:3030\nInitiating attack...\nLogging:: Attack object :: StandardLambdaObject [objectId=Sid#0001, lambdaJSScript=/** * `computeDamage` is the function that specifies the damage to be dealt to the * opponent. The `baseDamage` and `randomMultiplier` are mandatory and are set * randomly when the script executes. *  * To print stuff or display messages, you can use `println()` or `print()` *  * @param baseDamage *            the baseDamage of the attack, a double * @param randomMultiplier *            the random multiplier that can be used in the attack, a double *  * @return the computed damage, a double */var computeDamage = function (baseDamage, randomMultiplier) {\tprint(\"Computing damage!\");\treturn 100.0;};]\nAwaiting response...\nAttack stats :: Attack succeeded, damage dealt :: 100.0\nReceiving attack from :: /receive\nComputing damage!\nDamage received:: 150.0\nYour HP:: 643.106388567504\n```\n\n\n\n## For Simulations of transporting compute::\n### `/serialize`\nThe `/serialize` context takes in a POST request with 2 form-url-encoded params \"host\" and \"port\". These are the hostname and port of the next agent/java process running the scriptwar application(jar).\n\nThis context/API endpoint, will create the object and assign the JS script contents(lambda replacement) into the object and serialize and wire it to the agent with the `host` and `port` provided. It then waits till the receiving agent replies back.\n\n\n### `/deserialize`\nThe `/deserialize` context receives the serialized object wired to it, and executes the JS script(lamda replacement) and then returns a success response if everything went well else does it's usual thingy :D\n\n\n## Usage:\n\nFor the simulation, start up 2 separate java processes like\n\nAgent#1\n```\njava -jar scriptwars.jar localhost 3030 lamda.js\n```\n\nAgent#2\n```\njava -jar scriptwars.jar localhost 3050 l2.js\n```\n\nThen using Postman client, hit the URL \"http://localhost:3030/serialize\" using a POST request and \"host=localhost\", \"port=3050\" as form-url-encoded params.\n\nIt will execute the contents of the script `lamda.js` at Agent#2 and vice versa.\n\n\n\n\n\n## Generic usage\n```\njava -jar scriptwars.jar \u003cmy host-name\u003e \u003cmy port nbr\u003e \u003cmy js script file path\u003e\n```\n\n\n - Sid\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsidmishraw%2Fscriptwars","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsidmishraw%2Fscriptwars","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsidmishraw%2Fscriptwars/lists"}