Theory of Computer Games (Fall 2020) Homework 2
NTU CSIE
Due: 14:20 (UTC+8), December 24, 2020
Game Description
Outline
1 Game Description
2 Homework Requirements
3 Submission and Grading Policy
Game Description
Einstein W¨ urfelt Nicht! (Dame)
Game Rules
1 The game is played on a 6x6 board. Initially, there are 6 red and 6 blue pieces located at top leftandbottom rightconsecutively.
2 The initial pieces configuration is random.
3 In a turn, player can move any piece of its own one square forward in one of thethree directions closer to the opponent’s corner.
4 A player can capture other pieces by landing on their square and then replacing them. Note that a player is allowed to capture a piece of its own.
5 A player can pass if and if only there is no legal move available
Game Description
Terminal Condition
The game is over when:
1 If the last redpiece is captured, blueplayer wins
2 If the last bluepiece is captured, redplayer wins
3 If sixred pieces reach corner, red player wins
4 If sixblue pieces reach corner, blueplayer wins
5 If all remainingblue pieces and all remainingredpieces reach corner, If number of red pieces is greater than blue pieces,redplayer wins If number of blue pieces is greater than red pieces,blueplayer wins If number of blue pieces is equal to red pieces, player with highest corner piece number wins
If number of blue pieces is equal to red pieces and SouthEast and NorthWest corner have the same piece number, then it is adraw
Game Description
Terminal Condition
A player has reached corner when all of its remaining pieces:
Cannot capture opponent’s piece Cannot move to an empty square
5 Blue pieces same number of no red pieces at corner pieces, 4 > 3 left
Blue won Blue won Blue won
Game Description
Einstein W¨ urfelt Nicht! (Dame)
Initial board Blue can only capture Blue won!
Red: E, S, SE its own piece Blue: W, N, NW
Game Description
Let’s Play
Compilation
Run make under hw2 directory.
It’ll generate 4 executables: game, random, conservative and greedy.
game is the main gaming environment, while the others are baseline agents.
How to Play
The game supports AI-AI, AI-human and human-human mode.
You can choose which mode to play by specifying [-f] (first player) and/or [-s] (second player).
For example, the following command runs random and vs human mode
$ ./game -f ./random
Homework Requirements
Outline
1 Game Description
2 Homework Requirements
3 Submission and Grading Policy
Homework Requirements
Requirements
HW Requirements
1 Implement an agent of modified Einstein W¨urfelt Nicht! (Dame) using Monte-Carlo Tree Search.
2 Beat the conservativeAI and thegreedy AI.
3 Analyze the performance of your agent
Homework Requirements
Part I: Einstein Agent
Basic Requirements
1 Write an agent that receives opponent’s last move (from game) and sends move accordingly back.
2 We’ve handled most parts of the communication. Receive messages byreading from stdin and send messages bywriting to stdout.
3 Read everythingcharacter-by-character: if you expect a message of length k, read one character k times instead of directly reading a string of length k.
4 Remember to flushevery time after writing a message to stdout.
Homework Requirements
Part I: Einstein Agent (Cont’d)
Basic Requirements
1 You can assume that every move your agent receives is valid.
2 Your agent should send a valid move within 10 seconds. If game receives an invalid move, or doesn’t receive a move within the time limit, your agent will be killed and your opponent wins immediately.
Homework Requirements
Message Format
Message Format R: Received, S: Sent
R1: 12 characters that denote initial pieces configuration, e.g.
345120345120 (see illustration) R2: A single character
’f’: you are thefirst player
’s’: you are thesecond player
R3: 2 characters, can be ”--” (pass) or nd (otherwise), where n = number of piece to be moved
d = direction: 0 (vertical), 1 (horizontal), 2 (diagonal) S : 2 characters, can be ”--” (pass) or nd (otherwise) only.
Homework Requirements
Frame of an Agent
1: while True do 2: receive R1, R2
3: B ← Board(R1)
4: myTurn ← R2==”f” ? True : False 5: while True do
6: if B.terminal() then
7: break
8: end if
9: if myTurn == False then 10: receive R3
11: do opponent’s move R3on B 12: else
13: choose a move S 14: do the move S on B
15: send S
16: end if
17: myTurn ←!myTurn 18: end while
19: end while
Homework Requirements
Algorithms
1 You are required to implement the following algorithms:
UCT tree searchwith tree expansion based on UCBscore Addat least oneof Progressive Pruning (PP) or RAVE
2 Singe core, and no more than 4GB RAM
3 You can add plug-in learning + training data, but the training needs to be done by TA in 30 minutes using hardware described above
4 Your agent will be tested by
$ ./game -f [your agent] -s [our agent] -r 5
Homework Requirements
Part II: Agent Performance Analysis
Report Structure
Your report should include but not limited to:
1 Implementation
How tocompile and runyour code in linux. Don’t upload the compiled executable file.
What algorithm and heuristic you implemented.
2 Experiments
Results and findings of your implementation
3 Discussion
Observe your refinement on UCT tree search and (PP/RAVE), try to measure the improvements.
Submission and Grading Policy
Outline
1 Game Description
2 Homework Requirements
3 Submission and Grading Policy
Submission and Grading Policy
Submission
Directory hierarchy:
student id// e.g. r08922166(lowercase) Makefile// make your code
src// a folder contains all your codes report.pdf// your report
Compress your folder into azip file and submit to https://www.csie.ntu.edu.tw/˜tcg/2020/hw2.php.
Due to server limitation, the file size is restricted to2 MB.
Submission and Grading Policy
Grading Policy
1 Beat the baselines (10 points)
BeatSimple Conservative Agent(SCA) (5 points) BeatSimple Greedy Agent(SGA) (5 points)
2 Report (5 points)
3 Bonus
DominateSimple Greedy Agent(SGA) Peer competition
BeatHidden Benchmark
Submission and Grading Policy
Beat the Baselines
One round consists of 2 games with alternating first player.
We will calculate the total net score of 5 rounds between your agent and the baseline agents
You can get S , S ∈ {−2, −1, 0, 1, 2} score for each round Win: +1 point
Draw: 0 point Lose: −1 point
We consider total net score no less than zeroas beating the baseline.
Submission and Grading Policy
Bonus
Dominate SGA
Get total net score of strictly more than 2 when playing againts Simple Greedy Agent (SGA) in 5 rounds (+1 point)
Peer Competition
N = number of HW participants.
We will host a 5-round game between each participant.
Get net score strictly more than 5 × (N − 1) (+1 point).
Top K agents will be awarded more points, where K will be decided later, based on the results.
Submission and Grading Policy
Bonus
Beat Hidden Benchmark
You will have 3 rounds to fight the hidden benchmark.
W = net score after 3 rounds
Additional bonus points of min(max(W , 0), 3)