{"_id":"@aracus755/gcalc","_rev":"1-1e00e3e725e1c3a92f723234db0601b6","name":"@aracus755/gcalc","dist-tags":{"latest":"0.2.0"},"versions":{"0.2.0":{"name":"@aracus755/gcalc","description":"Game probability calculator","version":"0.2.0","license":"MIT OR Apache-2.0","repository":{"type":"git","url":"git+https://github.com/simhyeon/gcalc.git"},"module":"gcalc.js","homepage":"https://github.com/simhyeon/gcalc","types":"gcalc.d.ts","sideEffects":false,"keywords":["cli","game-development"],"gitHead":"b1dd92804ef548ba64891012febd9e8d33b2e0f9","bugs":{"url":"https://github.com/simhyeon/gcalc/issues"},"_id":"@aracus755/gcalc@0.2.0","_nodeVersion":"17.3.0","_npmVersion":"8.3.0","dist":{"integrity":"sha512-18MX/K8PinTcV/BzNit9P0GfwpviCJAAh6+pH7FY8MkmUEtkZNSx7MtLBMEWfCkuPWXAqzE4IOp+H2zS1NHYJQ==","shasum":"94ba3372c45d3de8bd725d6c92e5503d8580243f","tarball":"https://registry.npmjs.org/@aracus755/gcalc/-/gcalc-0.2.0.tgz","fileCount":8,"unpackedSize":190340,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh1AX4CRA9TVsSAnZWagAAQ/8P/29d1v8XsJtPwgXkjoYa\nIqouAW4WE8KVqrufB9TfJ0vjqmf2diVqdcmGMu2zbYPhdP7aUU3sacbsli0q\naDUKyQ9z+fsZi+I+1sbTlB6rhP8S2MGbiPqkrJyer/a71uK8UpdvXH6Gkj/e\nmS/rEfujAi7ykME7Z+TabHGZkg0mQetaBUVXpzRwJ8p/RIqtqWVMjeKZG6CS\nxh6b5hboD3E0xpkBPnsDvi8qp5rceq1bFteuioqHwXlUYGu0gse12xpBtLrO\nSHAZ0Q2rTsN/pz+y1GvphRUfa/0XxpBu+NCsm0zYL0asQ4150MveNR+sM8ic\n0L9IgFYpzWUP75CtiTdVFliQM82iFQkfzNB8HJtthMZVEvIxRo/4JABT+hYe\n5/1jlPXuehPmpjsgGTmzu0e/T5tPQKpa3ABN9ubacyaihvrk4e3WyYFIlGOX\nzY4uZznqsH2MYyLV/2eZaOPtS0U7NLJ9TSteiJ82NCO54xXPc9otLudgpbNn\nD54oxzbecmg9skmyuI8NgmHVXf1jX8LyOud7yARrT0QuVPqEce7/ZIWFO4SC\nsukGP4YM9hAQcaJq1EnTp6M6yhUb0rBgzMwAiKJu2uR2FAjYPE40WaKrn92B\nwqOndfzp1GlF509Qfobv66udJXWzpDAviyq9BWSj4WZm43szZqUF0Z8HdYp1\nMZ1L\r\n=y0HK\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCTa8dkA+xGkgV6pt8ICxmtucTKfY8b7HIB+UrVz832IAIhAOyPPa5z2KY4P6J6LCAUruLIUG/pAqCMIXsQE1bC2VJ1"}]},"_npmUser":{"name":"aracus755","email":"aracus755@gmail.com"},"directories":{},"maintainers":[{"name":"aracus755","email":"aracus755@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gcalc_0.2.0_1641285112370_0.8956318047295653"},"_hasShrinkwrap":false}},"time":{"created":"2022-01-04T08:31:52.295Z","0.2.0":"2022-01-04T08:31:52.830Z","modified":"2022-04-04T15:14:25.244Z"},"maintainers":[{"name":"aracus755","email":"aracus755@gmail.com"}],"description":"Game probability calculator","homepage":"https://github.com/simhyeon/gcalc","keywords":["cli","game-development"],"repository":{"type":"git","url":"git+https://github.com/simhyeon/gcalc.git"},"bugs":{"url":"https://github.com/simhyeon/gcalc/issues"},"license":"MIT OR Apache-2.0","readme":"# Gcalc\n\nGcalc is a game probability calculator.\n\nGcalc is not merely a gacha simulator but more of a generic probability\ncalculator.\n\n## Usage\n\n```bash\n# Basic\ngcalc <SUBCOMMAND> <OPTIONS>\n\n# SUBCOMMANDS:\n#   cond         Conditional calculation\n#   qual         Conditional calculation but only prints result\n#   range        Prints range of calculations\n#   reference    Create a reference file\n#   option       Create an option file\n\n# For cond and qual\n-b, --budget <budget>          Budget of total cost\n-C, --cost <cost>              Cost per try\n\n# For range\n-c, --count <count>            Counts to execute\n-S, --start <start>            Starting index to print\n\n# Global option\n    --constant <constant>      Constant value to be added into probability\n-f, --format <format>          Table format(csv|console|gfm)\n    --fallback <fallback>      Set csv value fallback {rollback|ignore|none} [default: none]\n-h, --help                     Print help information\n-l, --column <column>          Column mapping\n    --noheader                 CSV without header\n-o, --out <FILE>               File to write output\n-O, --option <option>          Option file to use\n-p, --probability <prob>       Basic probability\n-P, --precision <precision>    Precision\n-r, --ref <reference>          Reference file\n    --refin                    Reference from stdin\n-s, --strict                   Set strict CSV reader mode, every try should be corresponding csv record.\n-t, --target <target>          Target probability to achieve\n-T, --type <probtype>          Probability type(percentage|fraction)\n```\n\n## Install\n\n**binary**\n```bash\ncargo install gcalc --features binary --locked\n```\n\n**libary**\n```toml\n[dependencies]\ngcalc = \"0.2.0\"\n```\n\n## Demo\n\n```bash\n# Print records of probability 0.2(20%) with budget of 100 and cost of 20 for each iteration.\n# Target probability is 0.6\ngcalc cond --probability 0.2 --budget 100 --cost 20 -f console --precision 2 -T percentage -t 0.6\n\n# Print from 0 to 10 as github markdown formatted table, which has a precision of\n# 2 digits. Each try has cost of 1000.\ngcalc range --probability 0.2 --count 10 --format gfm --precision 2 --cost 1000\n\n# Print probability changes illustrated as csv formatted table, which has a\n# precision of 2 digits. Target probability is 0.8.\ngcalc cond --probability 0.2 --format csv --precision 2 --target 0.8\n\n# Print how many counts are required to reach 0.99 probability with 0.01 change of each try\n# Qual subcommand uses geometric-series formula if no reference was given as an argument\n# Which is efficient for very small probability cases\ngcalc qual --probability 0.001 -f gfm --target 0.99 --precision 2\n\n# Use reference file \ngcalc <SUBCOMMAND> --ref ref.csv\n\n# Use reference from stdin\ncat ref.csv | gcalc <SUBCOMMAND> --refin\n\n# Read options from option file\ngcalc range --option option.json\n```\n\nResults of prior usages are,\n\n```bash\n# gcalc cond --probability 0.2 --budget 100 --cost 20 -f console --precision 2 -T percentage -t 0.6\n+-------+-------------+------+\n| count | probability | cost |\n+-------+-------------+------+\n|   1   |   20.00%    |  20  |\n+-------+-------------+------+\n|   2   |   36.00%    |  40  |\n+-------+-------------+------+\n|   3   |   48.80%    |  60  |\n+-------+-------------+------+\n|   4   |   59.04%    |  80  |\n+-------+-------------+------+\n|   5   |   67.23%    | 100  |\n+-------+-------------+------+\n\n# gcalc range --probability 0.2 --count 10 --format gfm --precision 2 --cost 1000\n| count | probability | cost  |\n|-------+-------------+-------|\n|   1   |    0.20     | 1000  |\n|   2   |    0.36     | 2000  |\n|   3   |    0.48     | 3000  |\n|   4   |    0.59     | 4000  |\n|   5   |    0.67     | 5000  |\n|   6   |    0.73     | 6000  |\n|   7   |    0.79     | 7000  |\n|   8   |    0.83     | 8000  |\n|   9   |    0.86     | 9000  |\n|  10   |    0.89     | 10000 |\n\n# gcalc cond --probability 0.2 --format csv --precision 2 --target 0.8\ncount,probability,cost\n1,0.20,0.0\n2,0.36,0.0\n3,0.48,0.0\n4,0.59,0.0\n5,0.67,0.0\n6,0.73,0.0\n7,0.79,0.0\n8,0.83,0.0\n\n# gcalc qual --probability 0.001 -f gfm --target 0.99 --precision 2\n| count | probability | cost |\n|-------+-------------+------|\n| 4602  |    0.99     |  0   |\n```\n\n**Reference file example**\n```csv\ncount,probability,constant,cost\n1,0.1,0,50\n2,0.2,0,40\n3,0.3,0,30\n4,0.4,0,20\n5,0.5,0,10\n```\n\n**option file example**\n\n```json\n{\n\t\"count\": 10,\n\t\"prob_type\": \"Percentage\",\n\t\"prob_precision\": 2,\n\t\"budget\": null,\n\t\"fallback\": \"None\",\n\t\"no_header\": false,\n\t\"strict\": false,\n\t\"target\": null,\n\t\"column_map\": {\n\t\t\"count\": 0,\n\t\t\"probability\": 1,\n\t\t\"constant\": 2,\n\t\t\"cost\": 3\n\t},\n\t\"format\": \"GFM\",\n\t\"csv_ref\": {\n\t\t\"File\": \"ref.csv\"\n\t},\n\t\"out_option\": \"Console\"\n}\n```\n\"csv\\_ref\" is a tuple which has variant of...\n```\n\"csv_ref\" : {\n\t\"Raw\" : \"count,probability,constant,cost\n1,0.1,0.0,10\"\n}\n\nor\n\n\"csv_ref\" : {\n\t\"File\": \"file_name_in_string\"\n}\n\nor\n\n\"csv_ref\" : \"None\",\n```\n\n## Advanced usage\n\n**Column mapping**\n\nYou can read existing csv file without changing order of original source with\ncolumn option. You can type any character if given colun is not used by gcalc.\n\nCurrently, reference csv **requires all count,cost,probability,constant\ncolumns**. This behaviour might change in the future though.\n\nDefault order of columns are\n\n- count\n- probability\n- constant\n- cost\n\n```bash\n# Example csv content...\ndb,type,count,constant,cost,probability\nt1,a,1,0.1,30,0.1\nt1,b,2,0.1,20,0.1\nt1,c,3,0.1,10,0.1\nt1,a,4,0.2,30,0.1\nt1,b,5,0.2,20,0.2\nt1,c,6,0.2,10,0.3\n\n# Example usage\ngcalc --ref ref.csv range --count 6 --column db,type,count,constant,cost,probability\n\n# You can also write as\ngcalc --ref ref.csv range --count 6 --column ,,count,constant,cost,probability\n```\n\n**Strict Read**\n\nGcalc doesn't match every try for corresponding reference's record by default.\n\n```bash\n# Example csv file\ncount,probability,constant,cost\n1,0.5,0,50\n2,0.2,0,40\n3,0.3,0,30\n4,0.4,0,20\n5,0.5,0,10\n\n# Range from 1 to 10\n# From 6th try, 5th record values are used\ngcalc range --count 10 --ref ref.csv \n```\n\nUser can disable this behaviour with strict flag\n\n```bash\ngcalc range --count 10 --ref ref.csv --strict\n\n# Previous command yields error\nInvalid csv error\n= Empty row in index: 6\n```\n\n**Fallback**\n\nGcalc tries to parse CSV value as intended data type. But user can define\nfallback behaviour for such situations.\n\n```bash\n# Example csv file\ncount,probability,constant,cost\n1,0.5,0.2,50\n2,0.2,-,40\n3,0.3,0.1,30\n4,0.4,-,20\n5,0.5,-,10\n\n# Default value is 'none'\n# Option is case insensitive, btw\ngcalc <SUBCOMMAND> --ref ref.csv --constant 0.7 --fallback rollback|ignore|none\n```\nOn previous example, at the third record which is ```3,0.3,0.1,30```\n\n- Rollback : Set constant as 0.7 which is an initial value given as argument\n- Ignore   : Set constant as 0.2 which is the updated value of constant.\n- None     : Panics and abort a program\n\n## About\n\n### Why not use a simple formula?\n\nWell because, real life usages are not clear cut demonstrated geometric\nsequences. Sometimes there is bonus for a specific gacha stage and there is\nalso a so-called confirmed gacha system, which makes it hard to use geometric\nseries formula. \n\n### Ok, why not use other gacha simulators or calculators?\n\nFirst, simulation is not calculation. The major reasoning of this crate is\nabout expectation and calibration, especially game development in mind.\n\nSecond, existing calculators only consider fixed value of probability. However\nthere are plenty of contents that utilize bonus probability on specific steps\nand there are some gachas that have different probability for different\nsituations.\n\nThird, those are hard to integrate with other systems. Most of them are either\nsimple programs with integrated front end (GUI) which can be only losely\nconnected to other game development tools at the most and automation is\nnearly impossible.\n\n\n## Goal\n\n- Easily usable binary and library for probability check and calculations\n- Easy automation with csv files\n- Multi format: cross-platform binary + wasm binary\n- Integration with jupyter notebooks\n","readmeFilename":"README.md"}