游戏王残局简化版

Annotation For 残局文料/lua_lib/常用库.lua
Login

Annotation For 残局文料/lua_lib/常用库.lua

Origin for each line in 残局文料/lua_lib/常用库.lua from check-in 91958121fe:

9942dfa51d 2024-02-04    1: local d = {}
1fd4d78c98 2024-02-03    2: local 简文件库 = require("lfs")
91958121fe 2024-02-05    3: local ffi = require("ffi")
b29c01f0b6 2024-02-02    4: --~ 排
2c6261c44d 2024-02-03    5: --~ 办排中值的能
fb63b2804e 2024-02-03    6: --~ 入参2
fb63b2804e 2024-02-03    7: --~ 入参3
fb63b2804e 2024-02-03    8: --~ 入参4
9942dfa51d 2024-02-04    9: function d.历排(o1_0, o1, o2_0, o3_0, o4_0)
dbb3ab98a4 2024-02-03   10:   local k1_0
fb63b2804e 2024-02-03   11:   --~ 集排
dbb3ab98a4 2024-02-03   12:   k1_0 = {}
dbb3ab98a4 2024-02-03   13:   for o2 = 1, #o1_0 do
dbb3ab98a4 2024-02-03   14:     k1_0[#k1_0 + 1] = o1(o1_0[o2], o2_0, o3_0, o4_0)
fb63b2804e 2024-02-03   15:     end
dbb3ab98a4 2024-02-03   16:   return k1_0
fb63b2804e 2024-02-03   17:   end
fb63b2804e 2024-02-03   18: --~ 文
fb63b2804e 2024-02-03   19: --~ 历文的能
fb63b2804e 2024-02-03   20: --~ 入参2
fb63b2804e 2024-02-03   21: --~ 入参3
9942dfa51d 2024-02-04   22: function d.历文(o1, o2, o1_0, o2_0)
4af7b78130 2024-02-03   23:   local k1_0
0b316b136c 2024-02-03   24:   --~ 集排
4af7b78130 2024-02-03   25:   k1_0 = {}
4af7b78130 2024-02-03   26:   for o3_0 in o2(o1, o1_0, o2_0) do
4af7b78130 2024-02-03   27:     k1_0[#k1_0 + 1] = o3_0
f4c48d2eb7 2024-02-05   28:     end
f4c48d2eb7 2024-02-05   29:   return k1_0
f4c48d2eb7 2024-02-05   30:   end
f4c48d2eb7 2024-02-05   31: function d.历对(o1_0, o1)
91958121fe 2024-02-05   32:   local k1
91958121fe 2024-02-05   33:   local k1_0, k2_0
f4c48d2eb7 2024-02-05   34:   --~ 对
f4c48d2eb7 2024-02-05   35:   k1_0 = {}
91958121fe 2024-02-05   36:   for o2, o2_0 in pairs(o1_0) do
f4c48d2eb7 2024-02-05   37:     --~ 键
f4c48d2eb7 2024-02-05   38:     --~ 值
91958121fe 2024-02-05   39:     k1, k2_0 = o1(o2, o2_0)
91958121fe 2024-02-05   40:     if k1 then
91958121fe 2024-02-05   41:       k1_0[k1] = k2_0
f4c48d2eb7 2024-02-05   42:     else
f4c48d2eb7 2024-02-05   43:       end
9942dfa51d 2024-02-04   44:     end
9942dfa51d 2024-02-04   45:   return k1_0
9942dfa51d 2024-02-04   46:   end
2fe4cafc95 2024-02-03   47: --~ 表中值
2fe4cafc95 2024-02-03   48: --~ 值类
2fe4cafc95 2024-02-03   49: --~ 办值的能
9942dfa51d 2024-02-04   50: function d.操类(o1_0, o1, o2)
733d68b305 2024-02-04   51:   if type(o1_0) == o1 then
733d68b305 2024-02-04   52:     return o2(o1_0)
2fe4cafc95 2024-02-03   53:   else
733d68b305 2024-02-04   54:     return o1_0
1fd4d78c98 2024-02-03   55:     end
1fd4d78c98 2024-02-03   56:   end
1fd4d78c98 2024-02-03   57: --~ 排中文
1fd4d78c98 2024-02-03   58: --~ 入参2
1fd4d78c98 2024-02-03   59: --~ 入参3
1fd4d78c98 2024-02-03   60: --~ 入参4
9942dfa51d 2024-02-04   61: function d.全筛文(o1, o2, o3, o4)
d1b9d0d34f 2024-02-03   62:   if string.find(o1, o2, o3, o4) then
e94f91e6b3 2024-02-03   63:     return o1
e94f91e6b3 2024-02-03   64:     end
e94f91e6b3 2024-02-03   65:   end
e94f91e6b3 2024-02-03   66: --~ 文
e94f91e6b3 2024-02-03   67: --~ 前缀
9942dfa51d 2024-02-04   68: function d.加前缀(o1, o2)
4d150d683b 2024-02-03   69:   return (o2 or "") .. o1
4d150d683b 2024-02-03   70:   end
4d150d683b 2024-02-03   71: --~ 文
4d150d683b 2024-02-03   72: --~ 后缀
9942dfa51d 2024-02-04   73: function d.加后缀(o1, o2)
4d150d683b 2024-02-03   74:   return o1 .. (o2 or "")
4d150d683b 2024-02-03   75:   end
4d150d683b 2024-02-03   76: --~ 令
9942dfa51d 2024-02-04   77: function d.办令(o1)
4d150d683b 2024-02-03   78:   print(o1)
4d150d683b 2024-02-03   79:   os.execute(o1)
4d150d683b 2024-02-03   80:   end
4d150d683b 2024-02-03   81: --~ 文
4d150d683b 2024-02-03   82: --~ 前缀
9942dfa51d 2024-02-04   83: function d.全筛前缀(o1, o2)
4d150d683b 2024-02-03   84:   if string.sub(o1, 1, #o2) == o2 then
4d150d683b 2024-02-03   85:     return o1
4d150d683b 2024-02-03   86:     end
4d150d683b 2024-02-03   87:   end
4d150d683b 2024-02-03   88: --~ 文
4d150d683b 2024-02-03   89: --~ 后缀
9942dfa51d 2024-02-04   90: function d.全筛后缀(o1, o2)
4e48ffd0e5 2024-02-03   91:   if string.sub(o1, -#o2) == o2 then
4e48ffd0e5 2024-02-03   92:     return o1
4e48ffd0e5 2024-02-03   93:     end
4e48ffd0e5 2024-02-03   94:   end
0ebfa0e128 2024-02-04   95: --~ 目对
9942dfa51d 2024-02-04   96: function d.用令行工具操文件(o1_0)
4e48ffd0e5 2024-02-03   97:   local k1_9
4e48ffd0e5 2024-02-03   98:   --~ 令行排
9942dfa51d 2024-02-04   99:   k1_9 = d.历文(o1_0.文件目, 简文件库.dir)
9942dfa51d 2024-02-04  100:   k1_9 = d.历排(k1_9, d.全筛后缀, o1_0.文件类)
0ebfa0e128 2024-02-04  101:   for o1 = 1, #k1_9 do
9942dfa51d 2024-02-04  102:     k1_9[o1] = d.加前缀(k1_9[o1], o1_0.文件目)
9942dfa51d 2024-02-04  103:     k1_9[o1] = d.加前缀(k1_9[o1], [["]])
9942dfa51d 2024-02-04  104:     k1_9[o1] = d.加后缀(k1_9[o1], [["]])
9942dfa51d 2024-02-04  105:     k1_9[o1] = d.加前缀(k1_9[o1], o1_0.令行前缀)
9942dfa51d 2024-02-04  106:     d.办令(k1_9[o1])
4e48ffd0e5 2024-02-03  107:     end
4e48ffd0e5 2024-02-03  108:   end
4e48ffd0e5 2024-02-03  109: --~ 文件路
4e48ffd0e5 2024-02-03  110: --~ 式
9942dfa51d 2024-02-04  111: function d.读文件(o1, o2)
4e48ffd0e5 2024-02-03  112:   local k1
4e48ffd0e5 2024-02-03  113:   local k1_3
4e48ffd0e5 2024-02-03  114:   --~ 文件
4e48ffd0e5 2024-02-03  115:   k1_3 = io.open(o1, o2 or "r")
4e48ffd0e5 2024-02-03  116:   --~ 文
4e48ffd0e5 2024-02-03  117:   k1 = k1_3:read("a")
4e48ffd0e5 2024-02-03  118:   k1_3:flush()
4e48ffd0e5 2024-02-03  119:   k1_3:close()
4e48ffd0e5 2024-02-03  120:   return k1
4e48ffd0e5 2024-02-03  121:   end
4e48ffd0e5 2024-02-03  122: --~ 常量排
9942dfa51d 2024-02-04  123: function d.加对限(o1_0)
b92c73c8f3 2024-02-04  124:   table.insert(o1_0, 1, "local k1_0 = {}")
b92c73c8f3 2024-02-04  125:   table.insert(o1_0, "return k1_0")
b92c73c8f3 2024-02-04  126:   return table.concat(o1_0, "\n")
4e48ffd0e5 2024-02-03  127:   end
4e48ffd0e5 2024-02-03  128: --~ 文
4e48ffd0e5 2024-02-03  129: --~ 文件路
4e48ffd0e5 2024-02-03  130: --~ 式
9942dfa51d 2024-02-04  131: function d.写文件(o1, o2, o3)
168300f866 2024-02-03  132:   local k1_3
168300f866 2024-02-03  133:   --~ 文件
168300f866 2024-02-03  134:   k1_3 = io.open(o2, o3 or "w")
168300f866 2024-02-03  135:   k1_3:write(o1)
168300f866 2024-02-03  136:   k1_3:flush()
168300f866 2024-02-03  137:   k1_3:close()
168300f866 2024-02-03  138:   end
1b64e61bc7 2024-02-04  139: --~ 文
9942dfa51d 2024-02-04  140: function d.删左右空白(o1)
168300f866 2024-02-03  141:   o1 = string.gsub(o1, "^%s+", "")
168300f866 2024-02-03  142:   return string.gsub(o1, "%s+$", "")
f4c48d2eb7 2024-02-05  143:   end
f4c48d2eb7 2024-02-05  144: --~ 对
f4c48d2eb7 2024-02-05  145: --~ 对
f4c48d2eb7 2024-02-05  146: function d.连两对(o1_0, o2_0)
f4c48d2eb7 2024-02-05  147:   for o3_0, o4_0 in pairs(o2_0) do
f4c48d2eb7 2024-02-05  148:     o1_0[o3_0] = o4_0
f4c48d2eb7 2024-02-05  149:     end
f4c48d2eb7 2024-02-05  150:   return o1_0
f4c48d2eb7 2024-02-05  151:   end
f4c48d2eb7 2024-02-05  152: --~ 键
f4c48d2eb7 2024-02-05  153: --~ 值
f4c48d2eb7 2024-02-05  154: function d.修对类(o1_0, o2_0)
f4c48d2eb7 2024-02-05  155:   if tonumber(o1_0) then
f4c48d2eb7 2024-02-05  156:     return tonumber(o1_0), o2_0
f4c48d2eb7 2024-02-05  157:   else
f4c48d2eb7 2024-02-05  158:     return o1_0, o2_0
f4c48d2eb7 2024-02-05  159:     end
f4c48d2eb7 2024-02-05  160:   end
f4c48d2eb7 2024-02-05  161: do
f4c48d2eb7 2024-02-05  162:   --~ 加数
f4c48d2eb7 2024-02-05  163:   local k1 = 0
f4c48d2eb7 2024-02-05  164:   function d.递增()
f4c48d2eb7 2024-02-05  165:     k1 = k1 + 1
f4c48d2eb7 2024-02-05  166:     return k1
f4c48d2eb7 2024-02-05  167:     end
f4c48d2eb7 2024-02-05  168:   end
f4c48d2eb7 2024-02-05  169: --~ 左加数
f4c48d2eb7 2024-02-05  170: --~ 右加数
f4c48d2eb7 2024-02-05  171: function d.加法(o1, o2)
f4c48d2eb7 2024-02-05  172:   return o1 + o2
f4c48d2eb7 2024-02-05  173:   end
f4c48d2eb7 2024-02-05  174: --~ 左减数
f4c48d2eb7 2024-02-05  175: --~ 右减数
f4c48d2eb7 2024-02-05  176: function d.减法(o1, o2)
f4c48d2eb7 2024-02-05  177:   return o1 - o2
f4c48d2eb7 2024-02-05  178:   end
f4c48d2eb7 2024-02-05  179: --~ 左乘数
f4c48d2eb7 2024-02-05  180: --~ 右乘数
f4c48d2eb7 2024-02-05  181: function d.乘法(o1, o2)
f4c48d2eb7 2024-02-05  182:   return o1 * o2
f4c48d2eb7 2024-02-05  183:   end
f4c48d2eb7 2024-02-05  184: --~ 左除数
f4c48d2eb7 2024-02-05  185: --~ 右除数
f4c48d2eb7 2024-02-05  186: function d.除法(o1, o2)
f4c48d2eb7 2024-02-05  187:   return o1 / o2
7a7894a746 2024-02-05  188:   end
7a7894a746 2024-02-05  189: --~ 左数
7a7894a746 2024-02-05  190: --~ 右数
7a7894a746 2024-02-05  191: function d.位和(o1, o2)
7a7894a746 2024-02-05  192:   return bit.band(o1, o2)
6bd570d52a 2024-02-05  193:   end
91958121fe 2024-02-05  194: --~ 数
91958121fe 2024-02-05  195: --~ 右移几位
91958121fe 2024-02-05  196: function d.位右移(o1, o2)
91958121fe 2024-02-05  197:   return bit.rshift(o1, o2)
91958121fe 2024-02-05  198:   end
91958121fe 2024-02-05  199: --~ 对
91958121fe 2024-02-05  200: function d.找对中最大值(o1_0)
91958121fe 2024-02-05  201:   local k1, k2
91958121fe 2024-02-05  202:   k2 = -math.huge
91958121fe 2024-02-05  203:   for o1, o2 in pairs(o1_0) do
91958121fe 2024-02-05  204:     if k2 < o2 then
91958121fe 2024-02-05  205:       k1, k2 = o1, o2
91958121fe 2024-02-05  206:     else
91958121fe 2024-02-05  207:       end
6bd570d52a 2024-02-05  208:     end
91958121fe 2024-02-05  209:   return k1, k2
91958121fe 2024-02-05  210:   end
91958121fe 2024-02-05  211: --~ 内数
91958121fe 2024-02-05  212: function d.to_uint64(o1)
91958121fe 2024-02-05  213:   local uint64_pointer = ffi.new("uint64_t[1]", o1)
91958121fe 2024-02-05  214:   return uint64_pointer[0]
9942dfa51d 2024-02-04  215:   end
9942dfa51d 2024-02-04  216: return d