Last active
June 21, 2017 04:19
-
-
Save Restar9/7c2fbfe204f5297d9273 to your computer and use it in GitHub Desktop.
天鳳牌譜解析用コード
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////////////////////////////////////////////////////////// | |
// TENHOU.NET (C)C-EGG http://tenhou.net/ | |
//----------------------------------------------------------------- | |
//////////////////////////////////////////////////// | |
//ノー和了ノー放銃の順位分布を求める// | |
/////////////////////////////////////////////// | |
var we=window.external; | |
/////////////////////////////////////////////////////////////////// | |
// INTERNAL OBJETCS | |
//----------------------------------------------------------------- | |
// IDispatchLogAnaImpl ={analyze({}),stop(),nTotal,nProgress} | |
// IDispatchFileImpl ={open(default,ext,title),close(),write(str)} | |
// IDispatchLogInfoImpl={file,wGameType,wLobbyID,tw} | |
// IDispatchPlayerImpl ={un,dan,rate,sx,tehai,ten} | |
// IDispatchTehaiImpl ={operator[],length,sort(),toArray(),syanten()} | |
//----------------------------------------------------------------- | |
var logana; // IDispatchLogAnaImpl | |
var loginfo; // IDispatchLogInfoImpl [static reference] | |
var player; // IDispatchPlayerImpl [static reference] | |
logana=we.mjCommand("CREATEINSTANCE::LOGANA1.0"); | |
/////////////////////////////////////////////////////////////////// | |
// LOCAL | |
//----------------------------------------------------------------- | |
var agari_who; | |
var houju_who; | |
var o_who; | |
var bunpu = [0,0,0,0]; | |
var N_Log =0; | |
var nnlog=0; | |
var ss=""; | |
var file = ""; | |
var tmpfile; | |
/////////////////////////////////////////////////////////////////// | |
// EVENT HANDLER | |
//----------------------------------------------------------------- | |
//function OnAnalyzeBegin() | |
//function OnEnumLog(loginfo) | |
//function OnLogBegin(loginfo,player[4]) | |
//function OnSceneBegin(kyoku,honba,nagare,dice0,dice1,dora[1]) | |
//function OnTsumo(who,hai136,tehai) | |
//function OnDahai(who,hai136,tehai) | |
//function OnNaki(who,m,type,kui,hai0,hai1,hai2,hai3) | |
//function OnDora(hai136) | |
//function OnReach(who) | |
//function OnAgari(who,fu,tokuten,mangan,yaku[],yakuman[],doraUra[],sc[8],paoWho) | |
//function OnRyuukyoku(type,sc[8],show[4]) | |
//function OnSceneEnd() | |
//function OnLogEnd(sc[8]); | |
//function OnAnalyzeEnd(pf) | |
//sc=[ten0,diff0,ten1,diff1,ten2,diff2,ten3,diff3] | |
//----------------------------------------------------------------- | |
// ANALYZER PARAM | |
//----------------------------------------------------------------- | |
//var sSortAs "CTimeAscent"|"CTimeDescent" | |
// | |
//----------------------------------------------------------------- | |
//var sortAs="CTimeAscent"; // | |
var sortAs="CTimeDescent"; //(default) | |
function OnAnalyzeBegin(){ | |
eh('c','<button onclick="logana.stop()">STOP</button>'); | |
} | |
function OnEnumLog(loginfo){ // (ret:bool analyze or not) | |
nnlog++; | |
if (loginfo.wGameType>.SANMA || !(loginfo.wGameType>.NAN)) return false; //東風戦の場合 | |
return true; | |
} | |
function OnLogBegin(loginfo_,player){ | |
//初期化 | |
tmpfile = loginfo_.file; | |
agari_who = [0,0,0,0]; | |
houju_who = [0,0,0,0]; | |
o_who=-1; | |
} | |
function OnAgari(who,fu,tokuten,mangan,yaku,yakuman,doraUra,sc,paoWho,fromWho){ | |
agari_who[who]+=1; | |
houju_who[fromWho]+=1; | |
} | |
function OnLogEnd(sc){ | |
//ss+=agari_who + " " + houju_who; | |
for (var i = 0; i < 4; i++) { | |
if (agari_who[i]==0 && houju_who[i]==0) o_who=i; | |
}; | |
if(o_who==-1) return; | |
N_Log+=1; | |
bunpu[juni(o_who,sc)] += 1; | |
if (juni(o_who,sc)==0) file += "<br>" + tmpfile; | |
} | |
function juni(who,sc){ | |
var k = 0; | |
for (var i=0;i<4;i++){ | |
if(who != i && (sc[2*who] < sc[2*i] || (sc[2*who] == sc[2*i] && who > i))) k += 1; | |
} | |
return k; | |
} | |
function OnAnalyzeEnd(){ | |
var heikin=0; | |
var s = "0ほーら0ほーじゅうの順位分布"; | |
s += "解析した牌譜の数:" + nnlog +"<br><br>"; | |
s += "該当した牌譜の数:" + N_Log +"<br><br>"; | |
for (var i=0;i<4;i++){ | |
s += (i+1) + "位:" + bunpu[i] + "回/" + Math.floor(bunpu[i]/N_Log*1000)/10 + "%<br>"; | |
heikin += (i+1)*bunpu[i]; | |
} | |
s += "平均順位=" + heikin / N_Log; | |
s+= "<br>" + file; | |
eh('c',s); | |
logana.stop(); | |
} | |
logana.analyze(window); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////////////////////////////////////////////////////////// | |
// TENHOU.NET (C)C-EGG http://tenhou.net/ | |
//----------------------------------------------------------------- | |
//juni関数やその他もろもろ http://enecre.blog86.fc2.com/ さんからお借りしている部分があります | |
//////////////////////////////////////// | |
///先制リーチの平均点を求める //////// | |
//////////////////////////////////////// | |
var we=window.external; | |
/////////////////////////////////////////////////////////////////// | |
// INTERNAL OBJETCS | |
//----------------------------------------------------------------- | |
// IDispatchLogAnaImpl ={analyze({}),stop(),nTotal,nProgress} | |
// IDispatchFileImpl ={open(default,ext,title),close(),write(str)} | |
// IDispatchLogInfoImpl={file,wGameType,wLobbyID,tw} | |
// IDispatchPlayerImpl ={un,dan,rate,sx,tehai,ten} | |
// IDispatchTehaiImpl ={operator[],length,sort(),toArray(),syanten()} | |
//----------------------------------------------------------------- | |
var logana; // IDispatchLogAnaImpl | |
var loginfo; // IDispatchLogInfoImpl [static reference] | |
var player; // IDispatchPlayerImpl [static reference] | |
logana=we.mjCommand("CREATEINSTANCE::LOGANA1.0"); | |
/////////////////////////////////////////////////////////////////// | |
// LOCAL | |
//----------------------------------------------------------------- | |
var o_who; | |
var nnlog=0; | |
var N_Log=0; | |
var ss=""; | |
var loginfo; | |
var oya; | |
var ko_count=0; | |
var ko_score=0; | |
var oya_count=0; | |
var oya_score=0; | |
var flg; | |
/////////////////////////////////////////////////////////////////// | |
// EVENT HANDLER | |
//----------------------------------------------------------------- | |
//function OnAnalyzeBegin() | |
//function OnEnumLog(loginfo) | |
//function OnLogBegin(loginfo,player[4]) | |
//function OnSceneBegin(kyoku,honba,nagare,dice0,dice1,dora[1]) | |
//function OnTsumo(who,hai136,tehai) | |
//function OnDahai(who,hai136,tehai) | |
//function OnNaki(who,m,type,kui,hai0,hai1,hai2,hai3) | |
//function OnDora(hai136) | |
//function OnReach(who) | |
//function OnAgari(who,fu,tokuten,mangan,yaku[],yakuman[],doraUra[],sc[8],paoWho) | |
//function OnRyuukyoku(type,sc[8],show[4]) | |
//function OnSceneEnd() | |
//function OnLogEnd(sc[8]); | |
//function OnAnalyzeEnd(pf) | |
//sc=[ten0,diff0,ten1,diff1,ten2,diff2,ten3,diff3] | |
//----------------------------------------------------------------- | |
// ANALYZER PARAM | |
//----------------------------------------------------------------- | |
//var sSortAs "CTimeAscent"|"CTimeDescent" | |
// | |
//----------------------------------------------------------------- | |
//var sortAs="CTimeAscent"; // | |
var sortAs="CTimeDescent"; //(default) | |
function OnAnalyzeBegin(){ | |
eh('c','<button onclick="logana.stop()">STOP</button>'); | |
} | |
function OnEnumLog(loginfo){ // (ret:bool analyze or not) | |
nnlog++; | |
if (loginfo.wGameType>.SANMA) return false; | |
return true; | |
} | |
function OnSceneBegin(kyoku,honba,nagare,dice0,dice1,dora){ | |
oya=kyoku % 4; | |
flg=false; | |
} | |
function OnReach(who){ | |
if(flg) return; | |
flg=true; | |
o_who=who; | |
} | |
function OnAgari(who,fu,tokuten,mangan,yaku,yakuman,doraUra,sc,paoWho,fromWho){ | |
N_Log++; | |
if(o_who==who){ | |
if(who==oya){ | |
oya_count++; | |
oya_score += tokuten; | |
}else{ | |
ko_count++; | |
ko_score += tokuten; | |
} | |
} | |
//ss += "<br>tokuten=" + tokuten + " yaku" + yaku + " log=" + loginfo.file; | |
} | |
function OnAnalyzeEnd(){ | |
var s = "先制立直の平均点"; | |
s += "解析した牌譜の数:" + nnlog +"<br><br>"; | |
s += "該当した牌譜の数:" + N_Log +"<br><br>"; | |
s+= "<br>親リーチの平均点:" + oya_score/oya_count; | |
s+= "<br>子リーチの平均点" + ko_score / ko_count; | |
eh('c',s); | |
logana.stop(); | |
} | |
logana.analyze(window); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html><head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<title>牌譜解析スクリプト</title> | |
<style type="text/css"><!--A:link{color:blue;}A:visited{color:blue;}A:hover{color:red;}BODY,TABLE{font-size:10pt;}--></style> | |
</head><body> | |
<center> | |
<div id=v></div> | |
<hr size=1 color=#CCCCCC> | |
<br> | |
<div id=c> | |
牌譜を解析しています ...<br> | |
<br> | |
しばらくお待ちください<br> | |
</div> | |
<br> | |
<hr size=1 color=#CCCCCC> | |
<font color=#888888>※エラーが出る場合には最新版に更新してください。</font><br> | |
</center> | |
<script type="text/javascript" src="tenhou.js"></script> | |
<script type="text/javascript" src="util.js"></script> | |
<script type="text/javascript" src="agh2.js"></script><!--ここに作った解析用のjsを入れる)--> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment