{"_id":"@ayyo.ai/sdk","name":"@ayyo.ai/sdk","dist-tags":{"latest":"2.0.0"},"versions":{"2.0.0":{"name":"@ayyo.ai/sdk","version":"2.0.0","description":"ayyo.ai Bot Software Development Kit","main":"index.js","type":"module","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"dependencies":{"@hathora/client-sdk":"^0.0.7","@msgpack/msgpack":"^2.8.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"author":{"name":"AYYO.AI"},"license":"Copyright AYYO 2023","directories":{"example":"examples","lib":"lib"},"devDependencies":{},"repository":{"type":"git","url":"git+ssh://git@gitlab.com/ayyo.ai/sdk.git"},"bugs":{"url":"https://gitlab.com/ayyo.ai/sdk/issues"},"homepage":"https://gitlab.com/ayyo.ai/sdk#readme","gitHead":"51844cb8d84b3b9b95f94774bfaa34c14fd4f8be","_id":"@ayyo.ai/sdk@2.0.0","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"integrity":"sha512-BfYUbI2Ks6QsLXVeb3NekRQignHeZgyKypveMAdCZGD+vlQbxvDhsMEj6kTJmABXS0qteFoOoWyeO6yO2VsH1A==","shasum":"313cd0a36bfd0c03ba2d07631f5259226a096434","tarball":"https://registry.npmjs.org/@ayyo.ai/sdk/-/sdk-2.0.0.tgz","fileCount":13,"unpackedSize":17245,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDKsEV03ABOOzvPDaWIhA/ILzQpzdRkqFrkVCMZPVzk4AiAu8Ts0ISHzBuwp3Op4IFbsT2p3Wb2j+Rjxr673dKt1kQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjyIzKACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrvyw//aLAqidn9KWGx2HEGgqHGVlhtDEH5qGf+3Q8pmuCiJ8MOm607\r\nz4ZSghqKvAllojaE2mFfEwtwSmMX1c+8FZClzGyKsLBWFHo+r/nInjAGmERJ\r\nexDHyfCDhIzltYldk2I/nrcOxfJQ5zRJTYn2Gt+vQH2svzX5YohOCd0VNRj/\r\n92RQExK4o/VT0+cOh4bB60q3PI1FV+B3jKQ/bsxkU7PFhMZlhxgjNeD3NbU0\r\neHTfiMxESxVTCJRmEKzngFSvfexSx3iDtwu1g/jcMqv2SkRhJqEKJY/qKdFP\r\n+xxj/9R6gYw8QouUdpi4fuM1/qexQ4viqU0GFys1MU/fylchZzBjFHxEYriR\r\ny1hxqGehHvL8T7TMtOrOfMWQlQqm+vPLi5LYTCPHmhW3ZoVAGKZTC3tBG2Jw\r\nCre1TEI3y7YmblzZMXbj8l6nZ4FdbbUVUOhYOoV2yCwfDA+6/P6MjzO/fJcY\r\n0kwVjyezp/6xrF7SQXRaBI2rLm+1hR/2ySUZUjDp2JcuKDCNCBooSH9pmxhg\r\nfs0Vsw8LIdHKgXVByThCsnBGBInT1nvC8vI+RfU78J4krQaQvHgrcCYQVGWr\r\nQ41p/Dtp1oFCfwZC6og4/jd2OZNr+ad+T2rGmXi81I536z38vU7ObLhMZzRU\r\nLvMN3mVJrbC5FlYXeTG9v8XpUhq40GEoNRA=\r\n=HmEp\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"admiral-byrd","email":"ayyo@marak.com"},"maintainers":[{"name":"admiral-byrd","email":"ayyo@marak.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sdk_2.0.0_1674087626317_0.49922427234046807"},"_hasShrinkwrap":false}},"time":{"created":"2023-01-19T00:20:26.268Z","2.0.0":"2023-01-19T00:20:26.496Z","modified":"2023-01-19T00:20:26.670Z"},"maintainers":[{"name":"admiral-byrd","email":"ayyo@marak.com"}],"description":"ayyo.ai Bot Software Development Kit","homepage":"https://gitlab.com/ayyo.ai/sdk#readme","repository":{"type":"git","url":"git+ssh://git@gitlab.com/ayyo.ai/sdk.git"},"author":{"name":"AYYO.AI"},"bugs":{"url":"https://gitlab.com/ayyo.ai/sdk/issues"},"license":"Copyright AYYO 2023","readme":"![AYYO](https://ayyo.ai/img/ayyo-o.png \"AYYO\")\n\n# AYYO A.I. Bot Software Development Kit\n\n## *Alpha Edition*\n\n*Create your own [ayyo.ai](https://ayyo.ai) Bot*\n\nAYYO fully supports automated agents playing our games and has incorporated ayyo.ai Bots into the ayyo.gg autopilot control system. This means players can either develop and deploy AI behaviors to run autonomously in the cloud or in-game with the flip of a switch in the auto-pilot console. This repository provides a Software Development Kit for building AYYO AI bots.\n\n\nAYYO AI bots act as virtual players in the AYYO game. AYYO A.I. Bots subscribe and process the AYYO game state in real time, responding and sending controller inputs to the AYYO servers.\n\n## Installation\n\n```bash\nnpm install git@gitlab.com:ayyo.ai/sdk.git\n```\n\n## Usage\n\n```js\n\nimport AYYO from '@ayyo.ai/sdk';\n\nasync function go () {\n\n  // Creates a new AYYO.Bot client\n  let bobbyBot = new AYYO.Bot({\n    nickname: 'Bobby',\n    apiKey: '0xAaAaaaAAaaaAaaeEEeeEeeEe89a9EF980AdcA1fC' // your public ETH address\n  });\n\n  // Listens for any errors from the client\n  bobbyBot.on('error', function(err){\n    throw err;\n  });\n\n  // Listens for each gamestate tick event ( 33.33 FPS, 40ms fixed time step)\n  bobbyBot.on('gamestate', function(gamestate){\n    console.log(gamestate.snapshot);\n  });\n\n  // Connects the bot to a random room\n  await bobbyBot.connect();\n  \n  // Joins the default game room\n  await bobbyBot.join();\n\n  console.log('whoami:', bobbyBot.currentPlayer);\n\n  // Emit player controller input to the server\n  // ( see documentation for all available inputs )\n  setInterval(function(){\n    // Moves player forward while auto-firing weapon\n    bobbyBot.sendInputs({ UP: true, primaryWeapon: true });\n  }, 2000);\n}\n\ngo();\n```\n\n## Low-Level API\n\n```js\n\nimport AYYO from '@ayyo.ai/sdk';\n\nasync function go () {\n  // Creates a new AYYO.Bot client\n  let bobbyBot = new AYYO.Bot({\n    nickname: 'Bobby',\n    apiKey: '0xAaAaaaAAaaaAaaeEEeeEeeEe89a9EF980AdcA1fC' // your public ETH address\n  });\n\n  // Listens for any errors from the client\n  bobbyBot.on('error', function(err){\n    throw err;\n  });\n\n  bobbyBot.on('gamestate', function(gamestate){\n    //console.log('gamestate', gamestate)\n    // Perform arbitrary logic on gamestate array\n    // Each item contains a \"Thing\" which represents a gamestate entity\n    gamestate.snapshot.state.forEach(function(thing){\n      // TODO: paste console output from term\n      //console.log(thing);    \n    })\n    // \n    // set any of the available control input values to true or false,\n    // for example, move the player up\n    bobbyBot.sendInputs({\n      UP: false,\n      primaryWeapon: true\n    });\n  });\n\n  // Connects the bot to a random room\n  await bobbyBot.connect();\n  \n  // Joins the default game room\n  await bobbyBot.join();\n\n  console.log('whoami:', bobbyBot.game.currentPlayer);\n\n}\n\ngo();\n\n```\n\n## AI Behaviors API ( recommended )\n\nChainable API with built-in AI Behaviors ( found here ) and custom middlewars\n```js\nimport AYYO from '@ayyo.ai/sdk';\n\nasync function go () {\n\n  // Creates a new AYYO.Bot client\n  let bobbyBot = new AYYO.Bot({\n    nickname: 'Bobby',\n    apiKey: '0xAaAaaaAAaaaAaaeEEeeEeeEe89a9EF980AdcA1fC' // your public ETH address\n  });\n\n  // Listens for any errors from the client\n  bobbyBot.on('error', function(err){\n    throw err;\n  });\n\n  function autoFire (gamestate, response, next) {\n    console.log('Firing Primary Weapon')\n    // Set controller inputs\n    response.inputs.primaryWeapon = true;\n    // Call next() to continue to the next middleware\n    next();\n    // To stop middleware processing for this game tick,\n    // you can call response.end() instead of next() to end the response\n    // response.end();\n  }\n\n  // after connection, each of these behaviors are run top to bottom each each gametick \n  bobbyBot\n    .use(autoFire)\n    .use(function avoidDanger(gamestate, response, next) {\n      // Perform custom logic here based on gamestate.snapshot\n      // Set response.inputs controller values to true or false\n      next();\n    })\n    .use(function logger(gamestate, response, next) {\n      //console.log(gamestate, response, next)\n      gamestate.snapshot.state.forEach(function(thing){\n        console.log(thing.type, thing.id, thing.x.toFixed(2),thing.y.toFixed(2));\n      })\n    });\n\n  // Connects the bot to AYYO game servers\n  await bobbyBot.connect();\n\n  // Joins a random game room\n  await bobbyBot.join();\n\n  console.log('whoami:', bobbyBot.currentPlayer);\n\n}\n\ngo();\n\n```\n\n*Note: The Server will reset all input values to `false` on each new gametick.*\n\n### Available Controller Inputs\n\n```js\nconst controls = {\n  UP: 'UP',\n  DOWN: 'DOWN',\n  LEFT: 'LEFT',\n  RIGHT: 'RIGHT',\n  primaryWeapon: 'SPACE',\n  secondaryWeapon: 'D',\n  tertiaryWeapon: 'A',\n  quadWeapon: 'F',\n  leftBumper: 'SHIFT',\n  leaderboardToggle: 'TAB',\n  zoomIn: 'OPEN_BRACKET',\n  zoomOut: 'CLOSED_BRACKET',\n  exit: 'ESC'\n};\n```\n\n![AYYO](https://ayyo.ai/img/logo.png \"AYYO\")\n## Copyright AYYO.ai 2023","readmeFilename":"ReadMe.md"}