forked from yuanfengyun/q_algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9cd895
commit b0c02c3
Showing
28 changed files
with
673 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
由网友ak翻译过来。 | ||
split 选将拆分法 | ||
|
||
table 查表法 | ||
|
||
查表法由网友ak翻译过来 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Integer, Boolean> 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(); | ||
} | ||
} |
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
|
||
} |
Binary file not shown.
Oops, something went wrong.