From b0c02c3c8e708b7ac8f0bcc962ab03eb60810663 Mon Sep 17 00:00:00 2001 From: yuanfengyun <273461474@qq.com> Date: Mon, 13 Nov 2017 12:00:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0java=E7=89=88=E9=80=89?= =?UTF-8?q?=E5=B0=86=E6=8B=86=E5=88=86=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mjlib_java/readme.txt | 6 +- mjlib_java/split/logic.java | 153 +++++++++ mjlib_java/split/main.class | Bin 0 -> 1031 bytes mjlib_java/split/main.java | 34 ++ mjlib_java/split/split.class | Bin 0 -> 2901 bytes mjlib_java/split/split.java | 303 ++++++++++++++++++ mjlib_java/split/test.class | Bin 0 -> 2705 bytes mjlib_java/split/test.java | 171 ++++++++++ .../split/\346\265\213\350\257\225.bat" | 2 + ...5\347\247\215\350\212\261\350\211\262.bat" | 2 + .../split/\347\274\226\350\257\221.bat" | 3 + mjlib_java/{ => table}/.classpath | 0 mjlib_java/{ => table}/.project | 0 .../org.eclipse.core.resources.prefs | 0 .../.settings/org.eclipse.core.runtime.prefs | 0 .../.settings/org.eclipse.jdt.core.prefs | 0 .../src/gen_feng_table/Program.java | 0 .../src/gen_feng_table/SetTable.java | 0 .../src/gen_feng_table/TableMgr.java | 0 .../{ => table}/src/gen_table/Program.java | 0 .../{ => table}/src/gen_table/SetTable.java | 0 .../{ => table}/src/gen_table/TableMgr.java | 0 mjlib_java/{ => table}/src/main.java | 0 .../{ => table}/src/org/yungege/mj/Hulib.java | 0 .../src/org/yungege/mj/Program.java | 0 .../src/org/yungege/mj/SetTable.java | 0 .../src/org/yungege/mj/TableMgr.java | 0 .../src/org/yungege/test/Test.java | 0 28 files changed, 673 insertions(+), 1 deletion(-) create mode 100644 mjlib_java/split/logic.java create mode 100644 mjlib_java/split/main.class create mode 100644 mjlib_java/split/main.java create mode 100644 mjlib_java/split/split.class create mode 100644 mjlib_java/split/split.java create mode 100644 mjlib_java/split/test.class create mode 100644 mjlib_java/split/test.java create mode 100644 "mjlib_java/split/\346\265\213\350\257\225.bat" create mode 100644 "mjlib_java/split/\346\265\213\350\257\225\345\215\225\347\247\215\350\212\261\350\211\262.bat" create mode 100644 "mjlib_java/split/\347\274\226\350\257\221.bat" rename mjlib_java/{ => table}/.classpath (100%) rename mjlib_java/{ => table}/.project (100%) rename mjlib_java/{ => table}/.settings/org.eclipse.core.resources.prefs (100%) rename mjlib_java/{ => table}/.settings/org.eclipse.core.runtime.prefs (100%) rename mjlib_java/{ => table}/.settings/org.eclipse.jdt.core.prefs (100%) rename mjlib_java/{ => table}/src/gen_feng_table/Program.java (100%) rename mjlib_java/{ => table}/src/gen_feng_table/SetTable.java (100%) rename mjlib_java/{ => table}/src/gen_feng_table/TableMgr.java (100%) rename mjlib_java/{ => table}/src/gen_table/Program.java (100%) rename mjlib_java/{ => table}/src/gen_table/SetTable.java (100%) rename mjlib_java/{ => table}/src/gen_table/TableMgr.java (100%) rename mjlib_java/{ => table}/src/main.java (100%) rename mjlib_java/{ => table}/src/org/yungege/mj/Hulib.java (100%) rename mjlib_java/{ => table}/src/org/yungege/mj/Program.java (100%) rename mjlib_java/{ => table}/src/org/yungege/mj/SetTable.java (100%) rename mjlib_java/{ => table}/src/org/yungege/mj/TableMgr.java (100%) rename mjlib_java/{ => table}/src/org/yungege/test/Test.java (100%) diff --git a/mjlib_java/readme.txt b/mjlib_java/readme.txt index 7069cd1..c5d994a 100644 --- a/mjlib_java/readme.txt +++ b/mjlib_java/readme.txt @@ -1 +1,5 @@ -由网友ak翻译过来。 +split 选将拆分法 + +table 查表法 + +查表法由网友ak翻译过来 diff --git a/mjlib_java/split/logic.java b/mjlib_java/split/logic.java new file mode 100644 index 0000000..e1db83a --- /dev/null +++ b/mjlib_java/split/logic.java @@ -0,0 +1,153 @@ +import java.util.HashMap; + +public class logic +{ + static Boolean check__yitiaolong(int[] cards, int gui_num, Boolean eye) + { + int key = 0; + + for (int i = 0 ; i < 9 ; i++) + { + key = key * 10 + cards[i]; + } + + if (key == 0) + { + return false; + } + + HashMap m; + if (!eye) + { + m = gui_tested[gui_num]; + } + else + { + m = gui_eye_tested[gui_num]; + } + + if (m.containsKey(key)) + { + return false; + } + + m.put(key, true); + + for (int i = 0 ; i < 9 ; i++) + { + if (cards[i] > 4) + { + return true; + } + test_cards[i] = cards[i]; + } + test_cards[33] = gui_num; + if(!split.get_hu_info(test_cards, 34, 33)){ + System.out.println("error: cant't hu"); + } + return true; + } + + static void parse_table_sub(int[] cards, int num, boolean eye) + { + for (int i = 0 ; i < 9 ; i++) + { + if (cards[i] == 0) + { + continue; + } + + cards[i]--; + + if (!check_add(cards, num, eye)) + { + cards[i]++; + continue; + } + + if (num < 4) + { + parse_table_sub(cards, num + 1, eye); + } + cards[i]++; + } + } + + static void parse_table(int[] cards, boolean eye) + { + if (!check_add(cards, 0, eye)) + { + return; + } + parse_table_sub(cards, 1, eye); + } + + static void gen_auto_table_sub(int[] cards, int level, boolean eye) + { + for (int i = 0 ; i < 16 ; ++i) + { + if (i <= 8) + { + if (cards[i] > 3) + { + continue; + } + cards[i] += 3; + } + else + { + int index = i - 9; + if (cards[index] > 5 || cards[index + 1] > 5 || cards[index + 2] > 5) + { + continue; + } + cards[index] += 1; + cards[index + 1] += 1; + cards[index + 2] += 1; + } + + parse_table(cards, eye); + if (level < 4) + { + gen_auto_table_sub(cards, level + 1, eye); + } + + if (i <= 8) + { + cards[i] -= 3; + } + else + { + int index = i - 9; + cards[index] -= 1; + cards[index + 1] -= 1; + cards[index + 2] -= 1; + } + } + } + + static void gen_eye_table() + { + int[] cards = new int[34]; + for (int i = 0 ; i < 34 ; ++i) + { + cards[i] = 0; + } + + for (int i = 0 ; i < 9 ; ++i) + { + System.out.println("jiang"); + cards[i] = 2; + parse_table(cards, true); + gen_auto_table_sub(cards, 1, true); + cards[i] = 0; + } + } + + public static void main(String[] args) + { + System.out.println("test single color begin..."); + init_cache(); + gen_eye_table(); + } +} diff --git a/mjlib_java/split/main.class b/mjlib_java/split/main.class new file mode 100644 index 0000000000000000000000000000000000000000..6942823bf989f1c977e21ef8d6e0757b25369ee7 GIT binary patch literal 1031 zcmcJN-EI;=6vzJqyA1nL*h2XzEuU5kn8=NHHQtz*5UZGAOehy*!7bei3t<-%A4T85 zON~)t&pW0?~Toxq$Lu_QDZJp1Pj%WH}u=i)Z$5LK!n~{9xcOM zI&5?`O&iX+XhMQB^?&I_l^oaTVgLms9tP2*S&>FTquTro@ty)QmKY0@WDHBBm`i_z zOM$OeZLRmBN~fpLr$#%y7=4oBIE_|}0!wlfPBo5nhQTmZ!j2>)I7)KPV(cA4^qr@mPDvYYydDOIOR&|BQ8yFuDO(~zCvcyOzF-3BKDBh79 zA4%kzvPsIsA%0>lVUc*c+Upe0PF;_9Wh?&e|HWG*K1bs7B);&M_!QC`@yBEfKN7h@ ZYz4V}CJFKnC=tu_WGYm&NAn0WzX7k~xNraf literal 0 HcmV?d00001 diff --git a/mjlib_java/split/main.java b/mjlib_java/split/main.java new file mode 100644 index 0000000..bdbec39 --- /dev/null +++ b/mjlib_java/split/main.java @@ -0,0 +1,34 @@ +public class main { + public static void test_success() { + int[] cards = { + 1,1,0,0,1,0,1,0,0, + 0,0,0,2,4,2,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,2 + }; + + if(split.get_hu_info(cards, 34, 33)){ + System.out.println("test success"); + } + } + + public static void test_fail() { + int[] cards = { + 1,1,0,0,1,0,1,0,0, + 0,0,0,2,4,2,1,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,1 + }; + + if(!split.get_hu_info(cards, 34, 33)){ + System.out.println("test success"); + } + } + + public static void main(String[] args) { + // TODO Auto-generated method stub + test_success(); + test_fail(); + } + +} \ No newline at end of file diff --git a/mjlib_java/split/split.class b/mjlib_java/split/split.class new file mode 100644 index 0000000000000000000000000000000000000000..f6e7a565ce88a3bae186d1e421499701c0cb0b22 GIT binary patch literal 2901 zcmaJ@dvKIj75|<6-rp`^H{>SS7eaW2)GTeqPvjB$us|ww6>3`^H5;-E34|n*hE}kS zwx;zlom!`k4&a0Y=&T(xYOS`hGN`SOTE~udbR2cm%8a#Y2NfMl86f`d-3+w;VKRH} z_nmvrx##ga=YB6-dgc^>Z_{L+Ci69E(PV)p3q36Iuvp-(?i=VE=@3}0 zOK%g{Hx8C7g4rAU1}eAg-?y_ed~5g4esbcwD?x$pJPj7Zoa-i~| zk*>Rj`uj%cSF1jNTx)QER;-bGc&uMjKiDS-jOvWymcjkQJ(YER+R@M$DD3IJyE}mp z@dWBICxHg21Tx4b(1@l4nl(wIN#M*JnA94}`nv~qFDvfcQ|X}(vF)9h&twJ6D!9@( z;-m?_<+%!1r|oIT6MSGQNL|CEd#J-~K2tPy29Dm7Zzo$$hPPOet?XpWF{Ij+-KOk9 zanzRT^qH*Yh3(lL1-n$FP)@%m+H-}-ZqHdot-I2(A~zO!R^%&RZ%=Uv`jbI#6sRES zm!eRG$pz!^lJldmUHJuj9No%y$|{(kE&WtDjH2@G%N$#C){s+D;c+8lm&mz_vX?oI z=A@PVML5=^9l2@8Qht$+R1qmJHjX-d)?s+ck39W2hGxAeyW~t@R@zbSs4G+%^%?1U z<&9lodW_ZgPKH}8tGLzX&*9ItiYo(4N2A1I^%>Df6QPxQG^!bSjl{>ymFEdmc{RC1lL@1+>Zq&XHy^ z&%+}Ph<$ck4g1t~P5XR28)@(=m-W1v$jK}BDDmP(UYl|WU_*%DobuB46g0w#l0@28 zuEu6jIm$0bj&ckJiKgoGQ?ba+(~9dxZd*>dTF;JXa}4pc?JBRP=1st}tFWyrHC%@j zqrVjvGmyY-tlI6Y&K<1mRz%o_wXD)Q+==(%gV;owE!at^9=?^)hYD-A3wNW} zi*SWWsON8yyn$Iv!UcqUYm)FfJqkE`YU#jfo~ftFfU=LEfw;B{Iw=I2a_#aYGn8cn zUhX&)GZOZ;DX&n9+)TqkG+_;OOwjA z@>6jBH}ZW%?*JnoBtC~3`CVwi2nt-6;~uQS0d(LX*5ku?Kkj9oKEnJQWIpa=9`0xC z517as;Wu7{BLq*AYaSFM*VB>{b|&5j8L!QFS6UqzI-i})jG-Zu42L>M`d8%-P5-kB zD{mi#pJ#7}nQU$f?quE>pMJ?adslpK)G51 z6M=T|O(|V$3OYuUN7+0RJm?tP`~+M2F}89Q%kVfs^=0Ey0!&o1NGyyw+9_T@HK$@v z(IPS(ZE97t-N4s)J zXDgTV9Pv`cS>?Dj&QZK#I4>Le8)X~5!$x}1aGqB-EAgzc&`b+QwH@vT$|c{Wj4?G~ zgpaUN;H2gWkK}1+gE@Yoa#+zoIaH`^)*EvPW6qe+r`ERaFz0PH0vnB`bs7rS8%wjv zrX|B(W?aoE=MX)bIe@1(o6UM-C1I?X1H3~s<-9uY978hedjnssmqRsh?n}zs^!W$qD{Vmij5q{cqt~oWynbE@#L0uo2I4qCCf$ z@qO&Uk1&K6I5U32e)=hU=x6vOC;h{C3CB6@AIC58Rs0&?z;E#keuwYi_q-GSK#7;} zEBuk1(|Cn9!fT{w@hZ;YFSvxiij6Z8;P0aF56R-J%*VgvTKt=L!|T$4bFv;6WFs!h zW)ZnvVsfWgQWjTsOCb9slo5%`y;3J1m3nzV8ss6~F#29-LuQ%*`BXE1Kz&onN#$el zu+gcDry5DaRIH%}Vt!Q3bk>jAn;!Ld=8mA=e7TrARA0rMT6U6mfO7PA%k^!_F@sOT zm}qqkTr|ECEKDilysm*ape|pPojn0p*^{FV=i4bh@RZtpypojwqqil8K=PO)^U%ml z%$F8^i!Q)2S%_7#2=9?4xLI29K54^N?stj4slmzY&zTwE4HEa`=izgTF`%3|BL81$ CCh>y+ literal 0 HcmV?d00001 diff --git a/mjlib_java/split/split.java b/mjlib_java/split/split.java new file mode 100644 index 0000000..1159c46 --- /dev/null +++ b/mjlib_java/split/split.java @@ -0,0 +1,303 @@ +public class split +{ + public static boolean get_hu_info(int[] hand_cards, int curCard, int gui_index) + { + int[] cards = new int[34]; + for (int i = 0 ; i < 34 ; ++i) + { + cards[i] = hand_cards[i]; + } + + if (curCard < 34) + { + cards[curCard]++; + } + int gui_num = 0; + if (gui_index < 34) + { + gui_num = cards[gui_index]; + cards[gui_index] = 0; + } + + int[] eye_tbl = new int[34]; + int eye_num = 0; + int empty = -1; + for (int i = 0; i < 34; ++i) { + // ŻֶΣƣ + int min = (i / 9) * 9; + int max = min + 8; + if(max==35) max=33; + if(cards[i] == 1 && + (i-2 < min || cards[i-2] == 0) && + (i-1 < min || cards[i-1] == 0) && + (i+1 > max || cards[i+1] == 0) && + (i+2 > max || cards[i+2] == 0)){ + if (gui_num<0) { + return false; + } + eye_num = 1; + eye_tbl[0] = i; + empty = -1; + break; + } + if (empty == -1 && cards[i] == 0) empty = i; + if (cards[i] > 0 && cards[i] + gui_num>=2) { + eye_tbl[eye_num++] = i; + } + } + if (empty > 0) { + eye_tbl[eye_num++] = empty; + } + + boolean hu = false; + int[] cache = { 0,0,0,0 }; + for (int i = 0; i < eye_num; i++) { + int eye = eye_tbl[i]; + if (eye == empty) { + hu = foreach_eye(cards, gui_num - 2, gui_num, 1000, cache); + } + else{ + int n = cards[eye]; + if (n == 1) { + cards[eye] = 0; + hu = foreach_eye(cards, gui_num - 1, gui_num, eye/9, cache); + } + else { + cards[eye] -= 2; + hu = foreach_eye(cards, gui_num, gui_num, eye/9, cache); + } + cards[eye] = n; + } + if (hu) { + break; + } + } + + if (gui_num > 0) { + cards[gui_index] = gui_num; + } + return hu; + } + + public static boolean foreach_eye(int[] cards, int gui_num, int max_gui, int eye_color, int[] cache) + { + int left_gui = gui_num; + for (int i = 0; i < 3; i++) { + int cache_index = -1; + if (eye_color != i) cache_index = i; + int need_gui = check_normal(cards, i*9, i*9+8, max_gui, cache_index, cache); + if (cache_index>0) { + cache[i] = need_gui+1; + } + left_gui -= need_gui; + if (left_gui < 0) { + return false; + } + } + + int cache_index = -1; + if (eye_color != 3) cache_index = 3; + int need_gui = check_zi(cards, max_gui, cache_index, cache); + if (cache_index>0) { + cache[3] = need_gui + 1; + } + return left_gui >= need_gui; + } + + public static int check_normal(int[] cards, int from, int to, int max_gui, int cache_index, int[] cache) + { + if (cache_index >= 0) { + int n = cache[cache_index]; + if (n>0) return n - 1; + } + + int n = 0; + for (int i = from; i <= to; i++) { + n = n * 10 + cards[i]; + } + + if (n == 0) return 0; + + boolean n3 = false; + for (int i = 0; i <= max_gui; i++) { + if ((n + i) % 3 == 0) { + n3 = true; + break; + } + } + + if (!n3) { + return max_gui+1; + } + + return next_split(n, 0, max_gui); + } + + public static int next_split(int n, int need_gui, int max_gui) + { + int c=0; + while(true){ + if (n == 0) return need_gui; + + while (n > 0) { + c = n % 10; + n = n / 10; + if (c != 0) break; + } + if (c == 1 || c == 4) { + return one(n, need_gui, max_gui); + } + else if (c == 2) { + return two(n, need_gui, max_gui); + } + } + } + + public static int one(int n, int need_gui, int max_gui) + { + int c1 = n % 10; + int c2 = (n % 100) / 10; + + if (c1 == 0) ++need_gui; + else n -= 1; + + if (c2 == 0) ++need_gui; + else n -= 10; + + if (n == 0) return need_gui; + + if (need_gui > max_gui) return need_gui; + + return next_split(n, need_gui, max_gui); + } + + public static int two(int n, int need_gui, int max_gui) + { + int c1 = n % 10; + int c2 = (n % 100) / 10; + int c3 = (n % 1000) / 100; + int c4 = (n % 10000) / 1000; + + boolean choose_ke = true; + if (c1 == 0) { + // c1 == 0 ȫ + } + else if (c1 == 1) + { + // + if (c2 == 0 || c2 == 1) + { + + } + else if (c2 == 2) { + if (c3 == 2) { + if(c4 == 2) choose_ke = false; + } else if(c3==3){ + if(c4 != 2) choose_ke = false; + } + else { + choose_ke = false; + } + } + else if (c2 == 3) { + if (c3 != 3) + { + choose_ke = false; + } + } + else if (c2 == 4) { + if (c3 == 2){ + if(c4==2 || c4==3 || c4==4) choose_ke = false; + } + if (c3 == 3) { + choose_ke = false; + } + } + } + else if (c1 == 2) + { + choose_ke = false; + } + else if (c1 == 3) { + if (c2 == 2) { + if (c3 == 1 || c3==4) { + choose_ke = false; + }else if(c3==2){ + if(c4 != 2) choose_ke = false; + } + } + if (c2 == 3) { + choose_ke = false; + } + else if (c2 == 4) { + if (c3 == 2) { + choose_ke = false; + } + } + } + else if (c1 == 4) { + if (c2 == 2 && c3!=2) { + choose_ke = false; + } + else if (c2 == 3) { + if (c3 == 0 || c3==1 || c3==2) { + choose_ke = false; + } + } + else if(c2==4){ + if(c3==2) choose_ke = false; + } + } + + if (choose_ke) { + need_gui += 1; + } + else + { + if (c1 < 2) { + need_gui += (2 - c1); + n -= c1; + } + else { + n -= 2; + } + + if (c2 < 2) { + need_gui += (2 - c2); + n -= c2; + } + else { + n -= 20; + } + } + + if (n == 0) return need_gui; + + if (need_gui > max_gui) return need_gui; + + return next_split(n, need_gui, max_gui); + } + + public static int check_zi(int[] cards, int max_gui, int cache_index, int[] cache) + { + if (cache_index >= 0) { + int n = cache[cache_index]; + if(n>0) return n - 1; + } + + int need_gui = 0; + for (int i = 27; i < 34;i++) { + int c = cards[i]; + if (c == 0) continue; + if (c == 1 || c == 4) { + need_gui = need_gui + 2; + } + else if (c == 2) { + need_gui = need_gui + 1; + } + if (need_gui > max_gui) return need_gui; + } + + return need_gui; + } +} \ No newline at end of file diff --git a/mjlib_java/split/test.class b/mjlib_java/split/test.class new file mode 100644 index 0000000000000000000000000000000000000000..15d14aff9befe5954ad6b21f7f848f6bcb62ea70 GIT binary patch literal 2705 zcmZuzX>S`<6g}e^d+f<1o+NeB#xZe1TN1Z8UDMKpKuakNDRm(bnxw^<*i*-?V+Su4 zWf2I1kk}+ZY(-^BD+Q21v`8f?%MaiuASCz!eB)bHmUG8$;;K>PJMZ21=H7eGJ?~9^ z{rB200Cpi`U;_pMSdTqA_8L&DlY0#8!=RWU1NUNB7VZ;szii!a-~b*7;2<9Kt1HR|bG!$;nkYu+xFSfb=fmMSv}bO|vjD_{dcQ(T&3q8mLXIuKUSd|S6n+<~x;F%ysD2@~UZQpa(bOqiI&l!+5KX`%~J z9Z#7^Vp<0y&LE}0a*D-5abGlL=gW7Mqq7wqX%h}knYatRCSurPVk_=85yut<-qTt3 zTS13Z7A+A#&WWZ9xk52I<7Be=csy=mla$(z9s-wbOyXATqE5`5c2aazLAb7(QpopN zJ6CZMr-Z4=wfdyMoTy)5uHpjB{BsAB%Ssm=~FQWSjJRLtmo%jLT z*cEtJ#tTrE{`*s6dE8iS@N#THM+;i{*TwNBgs_?306aI~QLZzIUj$iArNo)a$K^}v zusWcHG%K)()`(@y#zI((A&(xbdl}|= zG+aSrOVd>Z-4|AXjuRBv4G(!Y$!r^+o#Z@9bejlwEAb7`-pj)?g6%lUufqv?PGK+d z{1B8dgcmq}1;cn9_u)g_kI(oW5TZI^`~$B-rrP}04fu5Q@nI>g*AWbpJD%fOn=X<& zjc*)Lha-aSP%IKZ58o2@#3Co+S~?L6cM|6^tSW7;cRI0z_OQN)hFDme=6Z9@y`YkV zYpc!NL1f_P$WH`K7)3Kt@WaF2J;obkjHt$m;5ZRX;z8~kB|@pc5k6^jQFGue76enbEI^izg9C@d! zBa+op&m48i0F7>nG*fI^Nl|5AQrsN5G13W_)IoMro3NQ6qQ$DRVWxv()lQF6eg{_`Nf(omN1%-y|O?;1rRjf^H9ItcU Pwm#z2$-pkoJ=py}Om!j6 literal 0 HcmV?d00001 diff --git a/mjlib_java/split/test.java b/mjlib_java/split/test.java new file mode 100644 index 0000000..24f98e0 --- /dev/null +++ b/mjlib_java/split/test.java @@ -0,0 +1,171 @@ +import java.util.HashMap; + +public class test +{ + static HashMap[] gui_tested = new HashMap[5]; + static HashMap[] gui_eye_tested = new HashMap[5]; + static int[] test_cards = new 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 + }; + + static void init_cache() + { + for (int i = 0 ; i < 5 ; i++) + { + gui_tested[i] = new HashMap(); + gui_eye_tested[i] = new HashMap(); + } + } + + static Boolean check_add(int[] cards, int gui_num, Boolean eye) + { + int key = 0; + + for (int i = 0 ; i < 9 ; i++) + { + key = key * 10 + cards[i]; + } + + if (key == 0) + { + return false; + } + + HashMap m; + if (!eye) + { + m = gui_tested[gui_num]; + } + else + { + m = gui_eye_tested[gui_num]; + } + + if (m.containsKey(key)) + { + return false; + } + + m.put(key, true); + + for (int i = 0 ; i < 9 ; i++) + { + if (cards[i] > 4) + { + return true; + } + test_cards[i] = cards[i]; + } + test_cards[33] = gui_num; + if(!split.get_hu_info(test_cards, 34, 33)){ + System.out.println("error: cant't hu"); + } + return true; + } + + static void parse_table_sub(int[] cards, int num, boolean eye) + { + for (int i = 0 ; i < 9 ; i++) + { + if (cards[i] == 0) + { + continue; + } + + cards[i]--; + + if (!check_add(cards, num, eye)) + { + cards[i]++; + continue; + } + + if (num < 4) + { + parse_table_sub(cards, num + 1, eye); + } + cards[i]++; + } + } + + static void parse_table(int[] cards, boolean eye) + { + if (!check_add(cards, 0, eye)) + { + return; + } + parse_table_sub(cards, 1, eye); + } + + static void gen_auto_table_sub(int[] cards, int level, boolean eye) + { + for (int i = 0 ; i < 16 ; ++i) + { + if (i <= 8) + { + if (cards[i] > 3) + { + continue; + } + cards[i] += 3; + } + else + { + int index = i - 9; + if (cards[index] > 5 || cards[index + 1] > 5 || cards[index + 2] > 5) + { + continue; + } + cards[index] += 1; + cards[index + 1] += 1; + cards[index + 2] += 1; + } + + parse_table(cards, eye); + if (level < 4) + { + gen_auto_table_sub(cards, level + 1, eye); + } + + if (i <= 8) + { + cards[i] -= 3; + } + else + { + int index = i - 9; + cards[index] -= 1; + cards[index + 1] -= 1; + cards[index + 2] -= 1; + } + } + } + + static void gen_eye_table() + { + int[] cards = new int[34]; + for (int i = 0 ; i < 34 ; ++i) + { + cards[i] = 0; + } + + for (int i = 0 ; i < 9 ; ++i) + { + System.out.println("jiang"); + cards[i] = 2; + parse_table(cards, true); + gen_auto_table_sub(cards, 1, true); + cards[i] = 0; + } + } + + public static void main(String[] args) + { + System.out.println("test single color begin..."); + init_cache(); + gen_eye_table(); + } +} diff --git "a/mjlib_java/split/\346\265\213\350\257\225.bat" "b/mjlib_java/split/\346\265\213\350\257\225.bat" new file mode 100644 index 0000000..93789d1 --- /dev/null +++ "b/mjlib_java/split/\346\265\213\350\257\225.bat" @@ -0,0 +1,2 @@ +java main +pause \ No newline at end of file diff --git "a/mjlib_java/split/\346\265\213\350\257\225\345\215\225\347\247\215\350\212\261\350\211\262.bat" "b/mjlib_java/split/\346\265\213\350\257\225\345\215\225\347\247\215\350\212\261\350\211\262.bat" new file mode 100644 index 0000000..10f45c1 --- /dev/null +++ "b/mjlib_java/split/\346\265\213\350\257\225\345\215\225\347\247\215\350\212\261\350\211\262.bat" @@ -0,0 +1,2 @@ +java test +pause \ No newline at end of file diff --git "a/mjlib_java/split/\347\274\226\350\257\221.bat" "b/mjlib_java/split/\347\274\226\350\257\221.bat" new file mode 100644 index 0000000..a294c90 --- /dev/null +++ "b/mjlib_java/split/\347\274\226\350\257\221.bat" @@ -0,0 +1,3 @@ +javac split.java +javac test.java +javac main.java \ No newline at end of file diff --git a/mjlib_java/.classpath b/mjlib_java/table/.classpath similarity index 100% rename from mjlib_java/.classpath rename to mjlib_java/table/.classpath diff --git a/mjlib_java/.project b/mjlib_java/table/.project similarity index 100% rename from mjlib_java/.project rename to mjlib_java/table/.project diff --git a/mjlib_java/.settings/org.eclipse.core.resources.prefs b/mjlib_java/table/.settings/org.eclipse.core.resources.prefs similarity index 100% rename from mjlib_java/.settings/org.eclipse.core.resources.prefs rename to mjlib_java/table/.settings/org.eclipse.core.resources.prefs diff --git a/mjlib_java/.settings/org.eclipse.core.runtime.prefs b/mjlib_java/table/.settings/org.eclipse.core.runtime.prefs similarity index 100% rename from mjlib_java/.settings/org.eclipse.core.runtime.prefs rename to mjlib_java/table/.settings/org.eclipse.core.runtime.prefs diff --git a/mjlib_java/.settings/org.eclipse.jdt.core.prefs b/mjlib_java/table/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from mjlib_java/.settings/org.eclipse.jdt.core.prefs rename to mjlib_java/table/.settings/org.eclipse.jdt.core.prefs diff --git a/mjlib_java/src/gen_feng_table/Program.java b/mjlib_java/table/src/gen_feng_table/Program.java similarity index 100% rename from mjlib_java/src/gen_feng_table/Program.java rename to mjlib_java/table/src/gen_feng_table/Program.java diff --git a/mjlib_java/src/gen_feng_table/SetTable.java b/mjlib_java/table/src/gen_feng_table/SetTable.java similarity index 100% rename from mjlib_java/src/gen_feng_table/SetTable.java rename to mjlib_java/table/src/gen_feng_table/SetTable.java diff --git a/mjlib_java/src/gen_feng_table/TableMgr.java b/mjlib_java/table/src/gen_feng_table/TableMgr.java similarity index 100% rename from mjlib_java/src/gen_feng_table/TableMgr.java rename to mjlib_java/table/src/gen_feng_table/TableMgr.java diff --git a/mjlib_java/src/gen_table/Program.java b/mjlib_java/table/src/gen_table/Program.java similarity index 100% rename from mjlib_java/src/gen_table/Program.java rename to mjlib_java/table/src/gen_table/Program.java diff --git a/mjlib_java/src/gen_table/SetTable.java b/mjlib_java/table/src/gen_table/SetTable.java similarity index 100% rename from mjlib_java/src/gen_table/SetTable.java rename to mjlib_java/table/src/gen_table/SetTable.java diff --git a/mjlib_java/src/gen_table/TableMgr.java b/mjlib_java/table/src/gen_table/TableMgr.java similarity index 100% rename from mjlib_java/src/gen_table/TableMgr.java rename to mjlib_java/table/src/gen_table/TableMgr.java diff --git a/mjlib_java/src/main.java b/mjlib_java/table/src/main.java similarity index 100% rename from mjlib_java/src/main.java rename to mjlib_java/table/src/main.java diff --git a/mjlib_java/src/org/yungege/mj/Hulib.java b/mjlib_java/table/src/org/yungege/mj/Hulib.java similarity index 100% rename from mjlib_java/src/org/yungege/mj/Hulib.java rename to mjlib_java/table/src/org/yungege/mj/Hulib.java diff --git a/mjlib_java/src/org/yungege/mj/Program.java b/mjlib_java/table/src/org/yungege/mj/Program.java similarity index 100% rename from mjlib_java/src/org/yungege/mj/Program.java rename to mjlib_java/table/src/org/yungege/mj/Program.java diff --git a/mjlib_java/src/org/yungege/mj/SetTable.java b/mjlib_java/table/src/org/yungege/mj/SetTable.java similarity index 100% rename from mjlib_java/src/org/yungege/mj/SetTable.java rename to mjlib_java/table/src/org/yungege/mj/SetTable.java diff --git a/mjlib_java/src/org/yungege/mj/TableMgr.java b/mjlib_java/table/src/org/yungege/mj/TableMgr.java similarity index 100% rename from mjlib_java/src/org/yungege/mj/TableMgr.java rename to mjlib_java/table/src/org/yungege/mj/TableMgr.java diff --git a/mjlib_java/src/org/yungege/test/Test.java b/mjlib_java/table/src/org/yungege/test/Test.java similarity index 100% rename from mjlib_java/src/org/yungege/test/Test.java rename to mjlib_java/table/src/org/yungege/test/Test.java