Skip to content

Commit

Permalink
0.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
zyr17 committed May 11, 2019
1 parent c776c73 commit f70ca56
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 122 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ result中即为结果。

## 已知问题

分析国际服数据时请确认自己的网络环境可以基本流畅访问Google Facebook等网站,否则很可能无法正常获取牌谱。
<!-- 分析国际服数据时请确认自己的网络环境可以基本流畅访问Google Facebook等网站,否则很可能无法正常获取牌谱。 -->

Ubuntu高版本中可能会出现GUI将可执行文件当做动态链接库的情况。目前没有找到解决方法,请使用Terminal执行。

Expand Down
6 changes: 6 additions & 0 deletions SimpleMahjong/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,12 @@ class Viewprototype{
let bafunum = parseInt(this.matchdata.nowround / 4);
nowhanname = '场风' + (bafunum == 0 ? '东' : fonname[bafunum]);
}
if (nowhanname == '河底摸鱼'){
nowhanname = '河底捞鱼';
}
if (nowhanname == '海底捞月'){
nowhanname = '海底摸月';
}
let addflag = false;
for (let i = 0; i < hanname.length; i ++ )
if (parseInt(nowhanname) == i || hanname[i][0] == nowhanname || hanname[i][1] == nowhanname){
Expand Down
5 changes: 5 additions & 0 deletions doc/release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.2.7
1.PaipuAnalyzer运行速度优化
2.修改JS注入时间,减少获取不到用户ID的情况
3.对于部分远古牌谱出现河底摸鱼、海底捞月导致BUG的修正。如果存在2018年8月以前的对战记录请删除牌谱数据重新下载转换。

0.2.6
1.改进副露结算

Expand Down
6 changes: 3 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const ready = () => {

browseWindow.nowingamepage = true;

browseWindow.webContents.on('did-stop-loading', function (){
browseWindow.webContents.on('dom-ready', function (){
browseinject();
if (!/^https:\/\/(?:majsoul|game.mahjongsoul|mahjongsoul)/.test(browseWindow.webContents.getURL())){
if (browseWindow.nowingamepage)
Expand Down Expand Up @@ -264,13 +264,13 @@ const ready = () => {
label: '进入国际服',
click: function () {
gotonewpage('https://mahjongsoul.game.yo-star.com');
dialog.showMessageBox({
/* dialog.showMessageBox({
type: 'info',
noLink: true,
buttons: ['确定'],
title: '国际服提示',
message: '由于技术原因,使用国际服时请确保当前网络能够较为通畅的访问Google, FaceBook等,否则很可能无法正确获取牌谱数据。'
});
}); */
}
}, {
label: '登录专用窗口',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "majsoul-paipu-crawler",
"version": "0.2.6",
"version": "0.2.7",
"description": "Get Paipu from Majsoul",
"main": "main.js",
"scripts": {
Expand Down
46 changes: 27 additions & 19 deletions src/algo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,32 @@ int getrank(std::vector<int> points, int who, int initial){
}
}

std::vector<int> pdata2tilevec(const MatchPlayerData &pdata){
std::vector<int> res, tile;
int pdata2tilevectile[20];

std::vector<int> pdata2tilevec(const MatchPlayerData &pdata) {
std::vector<int> res;
res.resize(Tiles::TILENUM);
for (auto i : pdata.hand) tile.push_back(i);
if (pdata.get != Tiles::EMPTY) tile.push_back(pdata.get);
for (auto &i : tile)
if ( ++ res[i - (i == 5 || i == 15 || i == 25)] > 4){
auto tile = pdata2tilevectile;
int tileend = 0;
for (auto i : pdata.hand) tile[tileend++] = i;
if (pdata.get != Tiles::EMPTY) tile[tileend++] = pdata.get;
assert(tileend <= 20);
for (int k = 0; k < tileend; k++) {
int i = tile[k];
if (++res[i - (i == 5 || i == 15 || i == 25)] > 4) {
//某张牌出现5张,数据有问题返回空数组
res.clear();
res.resize(Tiles::TILENUM);
return res;
}
}
return res;
}

std::map<long long, int> shantenmap;
const int SHANTENSYS = 4;
std::vector<int> shantenmap;
const int SHANTENSYS = 4, TILESYS = 3;
int listshantenarr[9], makeshantenarr[5];
int Td[5], Ttvec[5];

void makeshantenmap(int &mapval, int k = 0, int num = 0){
if (k == 9){
Expand Down Expand Up @@ -173,7 +181,7 @@ void listshantenmap(int k = 0, int num = 0){
i = 1 << (SHANTENSYS - 1);
long long index = 0;
for (auto i : listshantenarr)
index = (index << SHANTENSYS) + i;
index = (index << TILESYS) + i;
int &mapval = shantenmap[index];
makeshantenmap(mapval);
return;
Expand Down Expand Up @@ -213,27 +221,25 @@ int calcmentsu(const std::vector<int> &bu, int mentsu){
for (int i = 30; i < 37; i ++ )
if (bu[i] >= 3) mentsu ++ ;
else if (bu[i] == 2) toi ++ ;
std::vector<int> d, tvec;
d.resize(5);
for (auto &i : d)
i = -100;
auto &d = Td, &tvec = Ttvec;
for (int i = 0; i < 5; i ++ )
d[i] = -100;
d[0] = 0;
tvec.resize(5);
for (int i = 0; i < 30; i += 10){
long long index = 0;
for (int j = 0; j < 10; j ++ )
if (j != 5) index = (index << SHANTENSYS) + bu[i + j];
if (j != 5) index = (index << TILESYS) + bu[i + j];
int cint = shantenmap[index];
for (int k = 4; k >= 0; k -- ){
tvec[k] = cint & ((1 << SHANTENSYS) - 1);
cint >>= SHANTENSYS;
}
for (int j = int(d.size()) - 1; j >= 0; j -- )
for (int k = int(d.size() - 1) - j; k >= 0; k -- )
for (int j = int(5) - 1; j >= 0; j -- )
for (int k = int(5 - 1) - j; k >= 0; k -- )
if (!(tvec[k] >> (SHANTENSYS - 1)) && d[j] + tvec[k] > d[j + k])
d[j + k] = d[j] + tvec[k];
}
for (int I = 0; I < int(d.size()); I ++ ){
for (int I = 0; I < int(5); I ++ ){
int i = I + mentsu, j = toi + d[I];
int tt = 8 - i * 2 - j;
if (i + j > 4) tt = 4 - i;
Expand All @@ -243,8 +249,10 @@ int calcmentsu(const std::vector<int> &bu, int mentsu){
}

int calcshanten(const MatchPlayerData &pdata, bool chitoikokushi){
if (!shantenmap.size())
if (!shantenmap.size()){
shantenmap.resize(84000000);
listshantenmap();
}

auto tilevec = pdata2tilevec(pdata);
int chitoi = (pdata.show.size() || !chitoikokushi) ? INT_MAX : chitoishanten(tilevec);
Expand Down
Loading

0 comments on commit f70ca56

Please sign in to comment.