flash on 2010-11-30
♥0 |
Line 64 |
Modified 2010-12-01 01:15:48 |
MIT License
archived:2017-03-20 05:35:48
ActionScript3 source code
/**
* Copyright enecre ( http://wonderfl.net/user/enecre )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/aYHa
*/
package {
import flash.text.TextFormat;
import flash.text.TextField;
import flash.display.Sprite;
public class FlashTest extends Sprite {
private var tf:TextField;
public function FlashTest() {
// write as3 code here..
tf = new TextField();
tf.width = tf.height = 465;
tf.defaultTextFormat = new TextFormat("Meiryo", 12);
addChild(tf);
tr("hogehoge");
tr("mojjjaaaa");
}
private function tr(...o:Array):void{
tf.appendText(o + "\n");
tf.scrollV = tf.maxScrollV;
}
}
}
class Syanten {
/*
* ** overview **
* initialization by var hoge:Syanten = new Syanten(tehai);
* hoge.scanChiitoiKokushi();
* remove isolated hai (00100 or 1 jihai)
* remove toitsu jihai (2 jihai)
* remove anko jihai (3 jihai)
* remove kanko jihai (4 jihai)
* now tehai.length == 27 (mps: 9*3)
*/
private var c:Array/*int*/ = [0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0];
private var mentsu:int = 0;
private var taatsu:int = 0;
private var toitsu:int = 0;
private var jihai :int = 0;
private var n4:int = 0; // bit, 4mai motteru hai = toitsutukurenai
private var koritsu:int = 0; //bit
private var minSyanten:int = 8;
function Syanten(a:Array/*int*/, n:int = 34){ //a=tehai, n= 136mode or 34mode
c = a.concat();
}
public function scanChiitoiKokushi():void { };
public function scanNormal():void{
run(0);
}
private function run(depth:int):void{ //depth = 0 ~ 26. 1m ~ 9s.
if(minSyanten == -1)return;
while(!c[depth] && depth < 27) depth++; //if(c[depth] == 0)depth++;
if(depth == 27){ updateResult(); return; } //after scanning(0~26) finished, update result.
var i:int = depth % 9 + 1; // 1 ~ 9
switch(c[depth]){
case 4:{ // anko + (syuntsu | taatsu | koritsu)
break;
}
case 3:{ // anko | toitsu + (syuntsu | taatsu)
break;
}
case 2:{
break;
}
case 1:{
break;
}
}
}
private function updateResult():void{
// calc syanten from information and if it s less than current minSyanten, update minSyanten.
}
}