Skip to content
LmeSzinc edited this page Aug 9, 2020 · 2 revisions

How to do statistics on item drop rate

This document will show how to use dev_tools/item_statistics.py

Enable statistics in alas

In alas GUI,

  1. set enable_drop_screenshot to yes, if enabled, alas will add a 1s sleep before screenshot, to avoid capture the flash. There's a flash light when item shows up.

  2. set drop_screenshot_folder to be the folder you want to save. It is recommended to save it in SSD.

  3. Run Alas few hours or few days, and you will get a folder structure like:

    (Screenshots are named after millisecond timestamp.)

<your_folder>
    campaign_7_2
        get_items
            158323xxxxxxx.png
            158323xxxxxxx.png
            158323xxxxxxx.png
        get_mission
        get_ship
        mystery
        status
    campaign_10_4_HARD
        get_items
        get_mission
        get_ship
        status
    d3
        get_items
        get_mission
        get_ship
        status

Prepare a new environment

  1. Prepare another virtual environment, accoring to requirements.txt. But use the GPU version of mxnet.

    I am using GTX1080Ti, and I installed mxnet-cu101==1.6.0, CUDA10.1, cuDNN. Google mxnet gpu install, and see how to do in details. You may intall other version of CUDA, and mxnet for that CUDA, because you are using another graphic card.

  2. Goto module/ocr/al_ocr.py line 21, replace

context='cpu',

to be:

context='gpu',

Now cnocr will run on GPU.

You can skip this procedure anyway, and use the same environment as alas, but the OCR will run really slow.

First Run

Before any actual statistics, you need to extract templates first.

  1. Change your server in line 8:
server.server = 'cn'  # Edit your server here.
  1. Set your FOLDER and CSV_FILE at the bottom of the file.
"""
Args:
    FOLDER:   Alas drop screenshot folder.
              Examples: '<your_drop_screenshot_folder>/campaign_7_2'
    CSV_FILE: Csv file to save.
              Examples: 'c72.csv'
"""
FOLDER = ''
CSV_FILE = ''
drop = DropStatistics(FOLDER)
  1. Uncomment the this and run.
# drop.extract_template()

You will get some new templates named in number under folder item_template. Here's an example log:

  1%|          | 107/12668 [00:05<10:24, 20.10it/s]2020-06-03 10:39:42.609 | INFO | New item template: 50
  1%|          | 158/12668 [00:07<10:42, 19.47it/s]2020-06-03 10:39:45.098 | INFO | New item template: 51
  2%|▏         | 207/12668 [00:10<10:33, 19.66it/s]2020-06-03 10:39:47.772 | INFO | New item template: 52
  2%|▏         | 215/12668 [00:10<11:20, 18.29it/s]2020-06-03 10:39:48.304 | INFO | New item template: 53
100%|██████████| 12668/12668 [10:33<00:00, 19.99it/s]
  1. Rename new templates with Camel-Case, such as PlateGeneralT3. Suffix in name will be ignore.

    For example, Javelin and Javelin_2 are different templates, but have same output name 'Javelin'.

Why extract templates before every stats, why not provide ready-made templates

  • There are too many items in game, can't collect them all.
  • If it find new templates during actual run, may give unexpected result.
  • If some of your accounts used All-Skin, ship icons will be different.
  • Too many templates will make it slow.

Second Run

  1. Comment the code in first run.
drop.extract_template()
  1. uncomment this, and run.
import csv
with open(CSV_FILE, 'a', newline='') as csv_file:
    writer = csv.writer(csv_file)
    for d in drop.generate_data():
        writer.writerows(d)

Here's an example log:

2020-06-03 12:23:55.355 | INFO | [ENEMY_GENRE 0.007s] 中型侦查舰队
2020-06-03 12:23:55.363 | INFO | [Amount_ocr 0.009s] [1, 1, 22]
100%|█████████▉| 14916/14919 [20:32<00:00, 13.20it/s]2020-06-03 12:23:55.442 | INFO | [ENEMY_GENRE 0.007s] 大型航空舰队
2020-06-03 12:23:55.455 | INFO | [Amount_ocr 0.013s] [1, 1, 1, 17]
2020-06-03 12:23:55.539 | INFO | [ENEMY_GENRE 0.007s] 敌方旗舰
2020-06-03 12:23:55.549 | INFO | [Amount_ocr 0.010s] [1, 2, 1, 63]
100%|█████████▉| 14918/14919 [20:33<00:00, 12.35it/s]2020-06-03 12:23:55.623 | INFO | [ENEMY_GENRE 0.007s] 精英舰队
2020-06-03 12:23:55.633 | INFO | [Amount_ocr 0.010s] [1, 1, 1, 17]
100%|██████████| 14919/14919 [20:33<00:00, 12.10it/s]

Now you have a csv file, formated to be:

<get_item_timestamp>, <battle_status_timestamp>, <enemy_name>, <item_name>, <item_amount>

like this:

1590271317900,1590271315841,中型主力舰队,主炮部件T3,1
1590271317900,1590271315841,中型主力舰队,物资,23
1590271359374,1590271357251,小型侦查舰队,通用部件T1,1
1590271359374,1590271357251,小型侦查舰队,鱼雷部件T2,1
1590271359374,1590271357251,小型侦查舰队,物资,13
1590271415308,1590271413207,敌方旗舰,彗星,1
1590271415308,1590271413207,敌方旗舰,通用部件T3,1
1590271415308,1590271413207,敌方旗舰,科技箱T1,1
1590271415308,1590271413207,敌方旗舰,物资,42
1590271415308,1590271413207,敌方旗舰,_比萨研发物资,1
1590271415308,1590271413207,敌方旗舰,_鸢尾之印,1

You can open it in Excel or load it into database.

Improvement

These code is running on single thread, you can try adding multiprocess to speed up. I didn't do that because it's still acceptable (25it/s without ocr, 15it/s with ocr)

Clone this wiki locally