-
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
Showing
11 changed files
with
127 additions
and
139 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file modified
BIN
+0 Bytes
(100%)
out/production/baduk/com/company/baduk/Client/Begin$1.class
Binary file not shown.
Binary file modified
BIN
+352 Bytes
(110%)
out/production/baduk/com/company/baduk/Client/Begin.class
Binary file not shown.
Binary file modified
BIN
-159 Bytes
(99%)
out/production/baduk/com/company/baduk/Client/ChessPad.class
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
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
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
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
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,53 @@ | ||
package com.company.baduk.DataStruct; | ||
|
||
import com.company.baduk.Client.Point; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class myHashTable { | ||
public List<String> chessHash; | ||
public List<Point[][]> chessHistory; | ||
|
||
public myHashTable() { | ||
this.chessHash = new ArrayList<>(); | ||
this.chessHistory = new ArrayList<>(); | ||
} | ||
|
||
public void add(Point[][] temp) { | ||
chessHistory.add(temp); | ||
chessHash.add(hashFun(temp)); | ||
} | ||
|
||
//为当前棋局生成一个哈希值 | ||
public static String hashFun(Point[][] points) { | ||
int hash = 0; | ||
for (int i = 2; i <= 20; i++) { | ||
for (int j = 2; j <= 20; j++) { | ||
Point point = points[i][j]; | ||
if (point.getPlayer().equals(Player.BLACK)) | ||
hash += (point.getX() * 3 + point.getY() * 5) * 3; | ||
else if (point.getPlayer().equals(Player.WHITE)) | ||
hash += (point.getX() * 3 + point.getY() * 5) * 5; | ||
else if (point.getPlayer().equals(Player.NONE)) | ||
hash--; | ||
} | ||
} | ||
return String.valueOf(hash); | ||
} | ||
|
||
public int find(String key) { | ||
return chessHash.indexOf(key); | ||
} | ||
|
||
public Point[][] get(int i) { | ||
return chessHistory.get(i); | ||
} | ||
|
||
public Point[][] pop() { | ||
chessHistory.remove(chessHistory.size() - 1); | ||
chessHash.remove(chessHash.size() - 1); | ||
return chessHistory.get(chessHistory.size() - 1); | ||
} | ||
|
||
} |
Oops, something went wrong.