Final Project Description
December 24, 2015
Announcement and Important Data
Competition date: 2016/01/21 09:30-16:30 at CSIE 204.
Rules:
http://www.iis.sinica.edu.tw/˜tshsu/tcg/2015/hwks/rules.pdf Submit page: http://w.csie.org/˜tcg/2015/final.php
Submission due data: 2016/01/22 09:00 Download link for final project files:
http://w.csie.org/˜tcg/tcg 2015 final project.zip Check your school e-mail address for password.
Basic requirement NegaScout Hash table
Brief Rules for Final Project
瑞士制
預估六至八輪。
一個對戰組合互先一次。
請提前到場抽籤決定第一輪對手。
單場限時 900秒
超時算敗
Files and Description
Template code folder
final project template (Provide by TA, used in class only) GUI interface folder:
CDC package win7 3.0 CDC package linux 3.0
暗棋對弈平台 使用手冊 win7.pdf 暗棋對弈平台 使用手冊 ubuntu.pdf
GUI Mode and Protocal Type
連線方法:
單機模式: 透過 Board.txt, Move.txt 連線模式: 透過 Socket
Play mode:
Human v.s. Human
Human v.s. Computer (Computer play as second player) Computer v.s. Human (Computer play as first player) Computer v.s. Computer
帳號/密碼: 大寫學號
High Level Flow Chart of Protocol: 單機模式
Initial the game state according to board.txt Generate a move
Write the move to move.txt
High Level Flow Chart of Protocol: 連線 模式
Initial the socket connection
Initial the game state through the socket While(true)
If it’s your turn
Generate a move and send it through the socket Update the local game state
Receive the message from the server Change the turn
If it’s opponent’s turn Wait for opponents’ move
Receiving Opponent’s move and update the game state.
Change the turn
Template Code
File
main.cc anqi.cc anqi.h Protocol.h Protocol.cpp ClientSocket.h ClientSocket.cpp
Need -static -s when compiling in all system Need -lwsock32 when compiling in windows system
Can use -D WINDOWS to anable extra WINDOWS only feature.
Main Function
BOARD B;
TimeOut=(B.LoadGame(”board.txt”)-3)*1000;
if(!B.ChkLose())Output(Play(B))
Function Play
MOV Play(const BOARD &B) { POS p; int c=0;
// 新遊戲?隨機翻子
if(B.who==-1){p=rand()%32;return MOV(p,p);}
//若搜出來的結果會比現在好就用搜出來的走法
if(SearchMax(B,0,2)>Eval(B))return BestMove;
//否則隨便翻一個地方 但小心可能已經沒地方翻了
for(p=0;p<32;p++)if(B.fin[p]==FIN X)c++;
if(c==0)return BestMove;
c=rand()%c;
for(p=0;p<32;p++)if(B.fin[p]==FIN X&&–c<0)break;
return MOV(p,p);
}
Function SearchMax
SCORE SearchMax(const BOARD &B,int dep,int cut) { if(B.ChkLose())return -WIN;
MOVLST lst;
if(cut==0kTimesUp()kB.MoveGen(lst)==0)return +Eval(B);
SCORE ret=-INF;
for(int i=0;i<lst.num;i++) BOARD N(B);
N.Move(lst.mov[i]);
const SCORE tmp=SearchMin(N,dep+1,cut-1);
if(tmp>ret){ret=tmp;if(dep==0)BestMove=lst.mov[i]
}
return ret;
}
Board Index
Template-Code
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
24 25 26 27
28 29 30 31
Protocal
28 29 30 31
24 25 26 27
20 21 22 23
16 17 18 19
12 13 14 15
8 9 10 11
4 5 6 7
0 1 2 3
Protocal-(x,y)
(0,7) (1,7) (2,7) (3,7) (0,6) (1,6) (2,6) (3,6) (0,5) (1,5) (2,5) (3,5) (0,4) (1,4) (2,4) (3,4) (0,3) (1,3) (2,3) (3,3) (0,2) (1,2) (2,2) (3,2) (0,1) (1,1) (2,1) (3,1) (0,1) (1,1) (2,1) (3,1)
Frequency Asked Questions
For MAC:
Q: Is there a GUI version for MAC?
A: Currently there is no MAC version.
For Linux
Q: What does permission denied means?
A: Your “search” file needs to be executable.
Q: Why my GUI interface does not work?
A: Make sure to add the LD LIBRARY PATH=. to include the GameDLL.so
For Windows
Q: When using “背景” mod, the GUI just hanging there?
A: In some combinations of Windows OS and compiler, the number arguments passing by the commnd line is not implemented by the stander. Check the value of argc, if it’s not 3, then in Line 167 of main.cc
protocol→init protocol(argv[1],atoi(argv[2]));
Unfrequency Asked Qustions
A: What’s the difference bettwen “背景” and “讀檔”
Q: In “讀檔” mode, GUI called search engine for every single move. That is, the search program is terminated once it returned the move. In “背景” mode, the search engine is called in the beginning of the game, and it will be terminated only when the game is over.
A: What if I want to compare the search engine for two different version?
Q; You need to create another folder contains the GUI interface. Use one GUI interface to create the game room, and use the other to join the game room.