以炎黄为例对LPC游戏开发中常用Efun的数据分析

如果你要做Mud二次开发,要快手上手应该学习哪些Efun?这里以炎黄MUD使用的Efun为统计,分析结果供参考。

关于数据说明

注意,数据源统计了Fluffos 361个Efun(包括默认驱动未开启的Efun)在炎黄中使用的数据,如果有在.c代码中使用,统计数据为所有相关数量和文件,其中包括了doc说明文档和框架mudcore中的数据,如果没有在.c代码文件中使用,仅仅在doc文档中说明,统计数量计为0。

import pandas as pd

df=pd.read_csv('dataset/efun_count.csv')
df.head()
type efun count file
0 Arrays allocate 139 50
1 Arrays arrayp 267 109
2 Arrays element_of 31 15
3 Arrays filter_array 214 126
4 Arrays map_array 26 17

Efun 分类及数量

df['type'].value_counts()
Interactive    43
Contrib        39
Strings        29
System         27
Objects        27
Misc           25
Floats         20
Internals      19
Filesystem     16
Mudlib         14
Sockets        12
Calls          12
Parsing        10
Arrays         10
Mappings        9
General         8
PCRE            8
DB              8
Class           7
Buffers         6
Functions       4
Numbers         4
ED              4
Name: type, dtype: int64

Efun分类以mud.wiki为数据源,仅供参考,因为部分分类是以功能分,部分是根据Efun在源码中所属package分的,其中Misc类别主要是说明文档不全基本没有在开发中使用的Efun,而Contrib基本是新增的杂七杂八的Efun,有部分实用,但多数据在开发中没有有效利用。

炎黄中用到的Efun

efun = df[df['count']>0]
efun
type efun count file
0 Arrays allocate 139 50
1 Arrays arrayp 267 109
2 Arrays element_of 31 15
3 Arrays filter_array 214 126
4 Arrays map_array 26 17
... ... ... ... ...
334 Contrib variables 4 3
336 Misc act_mxp 2 1
341 Misc external_start 3 2
342 Misc has_gmcp 4 2
354 Misc send_gmcp 18 4

242 rows × 4 columns

242/361
0.6703601108033241

炎黄中使用1次以上的efun有242个,占总数的67%

efun.describe()
count file
count 242.000000 242.000000
mean 307.347107 131.396694
std 1126.604830 402.751635
min 1.000000 1.000000
25% 7.000000 4.000000
50% 18.000000 12.000000
75% 96.250000 50.750000
max 13396.000000 3563.000000
efun['type'].value_counts()
Interactive    41
Objects        27
Strings        22
Contrib        19
System         18
Mudlib         12
Filesystem     12
Sockets        12
Calls          11
Arrays         10
Internals      10
Mappings        8
General         8
Parsing         7
DB              5
Buffers         4
Floats          4
Misc            4
Numbers         3
Functions       3
PCRE            1
ED              1
Name: type, dtype: int64

使用量前%20

int(242*0.2)
48

根据二八原则看看使用Efun前20%的数量,共48个(这里我们统计50个)

efun20 = efun.sort_values(['count'],ascending=False).head(50)
efun20
type efun count file
110 Interactive notify_fail 13396 2417
181 Numbers random 5973 2240
96 Interactive command 4572 616
26 Calls this_object 4102 1348
286 System replace_program 3568 3563
136 Interactive write 3164 793
190 Objects environment 2741 1049
132 Interactive this_player 2452 1265
187 Objects clonep 2431 2411
92 General sizeof 2335 1193
199 Objects objectp 2294 1314
208 Objects tell_object 2102 811
17 Calls call_out 1779 686
95 Interactive add_action 1617 822
256 Strings sprintf 1515 371
172 Mudlib living 1119 899
189 Objects destruct 1091 719
201 Objects present 1069 595
253 Strings replace_string 1011 129
262 Strings stringp 950 350
109 Interactive message 796 368
197 Objects new 737 385
257 Strings sscanf 701 353
24 Calls remove_call_out 635 401
192 Objects find_object 618 307
162 Mappings mapp 614 241
293 System time 503 336
179 Mudlib seteuid 468 357
159 Mappings keys 405 232
171 Mudlib getuid 400 320
194 Objects load_object 393 213
263 Strings strlen 354 122
123 Interactive say 276 149
1 Arrays arrayp 267 109
209 Objects tell_room 267 71
5 Arrays member_array 245 115
22 Calls previous_object 241 82
51 Filesystem file_size 236 120
298 Contrib base_name 228 124
3 Arrays filter_array 214 126
184 Objects all_inventory 213 156
160 Mappings map_delete 198 68
180 Numbers intp 186 76
264 Strings strsrch 183 72
240 Sockets socket_write 169 24
141 Internals debug_message 165 54
103 Interactive find_player 162 111
244 Strings explode 146 90
107 Interactive input_to 144 23
191 Objects file_name 142 71

这些常用Efun中replace_program目前已没有使用的必要,而socket_write只在有限的文件中使用,查看源码可知主要是在ftpd模拟FTP服务器使用,目前游戏开发也没有太大的意义,而其它需要通信的需求可以通过external_start调用系统指令来实现,所以在socket方面也可以无视,另外,input_to虽然分布的文件只有23个,但这个函数很重要,所以不可忽视。

efun20 = efun20.query("efun !=['replace_program','socket_write']")

最常用的5个efun

efun20.head()
type efun count file
110 Interactive notify_fail 13396 2417
181 Numbers random 5973 2240
96 Interactive command 4572 616
26 Calls this_object 4102 1348
136 Interactive write 3164 793

Efun类别统计

efun20['type'].value_counts()
Objects        12
Interactive     9
Strings         7
Calls           4
Mudlib          3
Mappings        3
Arrays          3
Numbers         2
General         1
System          1
Filesystem      1
Contrib         1
Internals       1
Name: type, dtype: int64
efun20['type'].value_counts().plot(kind='bar')
<AxesSubplot:>

file

从数据可看到最常用的Efun主要是Objects类别的,占12个,其次是Interactive类别,占9个,然后是Strings类别7个。

更多分析更新中……

京ICP备13031296号-4