首页
服务项目
代写案例
服务流程
客户好评
联系我们
CS4386代写、代做Java语言程序
CS4386 AI Game Programming (Semester B, 2024-2025)
Assignment 1:
Trap Gomoku
Set by CS4386 TA Team
Tournament1 Deadline:
Friday 28 February 2025 23:59
Tournament2 Deadline:
Wednesday 12 March 2025 23:59
This assignment is worth
15 % (fifteen percent)
of the overall course mark
Overview
1 Introduction
2 Marking Scheme
3 The Trap Gomoku Game
4 Online Judgment Platform
5 Requirements
6 Q&A
7 Academic Honesty
Appendix: Sample submission code
1 Introduction
Your task is to develop an AI program capable of playing the Trap Gomoku game.
You may implement your AI using algorithms covered in class or explore other
strategies. The implementation can be done in Python, Java, C, or C++.
To test and evaluate your AI, you will submit your code to an online AI game
judgment platform. The platform provides three preset AI opponents of varying
difficulty, allowing you to test your AI an unlimited number of times by
competing against them. Testing and refining your AI strategy against the three
preset AIs on the platform will help you improve your AI before competing in the
tournaments, where each participant will compete against every other
participant.
2 Marking Scheme
Item Due Mark
Tournament1 (students vs. students)
Tournament2 (students vs. students)
Students vs. Preset AIs
Report
28th Feb 23:59
12th Mar 23:59
12th Mar 23:59
12th Mar 23:59
20
20
30
30
Total 100
Your final grade will be based on the following aspects:
● Whether you beat our three preset AIs. If you beat all three preset AIs, you
will get 30 points (10 points for each AI). The battle against each preset AI
is divided into two games: first player and second player. If you win only
one game, you will get 5 points.
● Your ranking in tournaments. We will schedule two tournaments, where
each participant will compete against every other participant once. After
the tournament, you will see where your AI stands in the rankings. These
rankings are an integral part of your overall assessment.
● In addition to the score from your AI performance, the quality of your
report will also affect the final score. Your report should explain your
1
approach, justify algorithmic choices, and analyze the strengths and
weaknesses of your AI.
3 The Trap Gomoku Game
The Trap Gomoku Game is a strategic board game where two artificial
intelligence (AI) players compete by aligning five of their pieces consecutively in
a straight line (horizontally, vertically, or diagonally) on a 15x15 grid. In addition,
at the beginning of the game, the system will randomly generate 10-15 trap
pieces and make them public to players. If the chess piece you place lands on a
trap, it will devour the piece, and the trap will remain.
Each player takes turns placing their pieces, aiming to align five consecutively in
a straight line. The "X" represents the trap, and the black and gray circles
represent Player 1 and Player 2's pieces, respectively (shown in Figure 1). The
game ends when the grid is filled (no more than 225 moves) and the player who
creates five of their pieces consecutively in a straight line on the grid will be the
winner. Special Case: If the board is full and there is still no line of 5 pieces. Then
the side with the longest connection is judged to be the winner (for example, if
the white chess piece has the longest 4 pieces in a line, and the black chess piece
has the longest 3 pieces in a line, then the white piece wins), otherwise, it is a
draw. You are encouraged to come up with your own strategies to make your AI
make better decisions at each turn. We are excited to see your brilliant ideas and
how they challenge each other!
2
Figure 1. Two instances of the game board
4 Online Judgment Platform
Website URL: http://cs4386.cs.cityu.edu.hk/user/login/
This URL can only be accessed within the CityU campus network. If you want to
use this website outside the campus, please use CityU VPN first.
Register and log in
● You should register using your CityU email.
● You should register using your real name.
● Upon registration, you will be assigned a user ID. Only your ID will be
shown in the ranking.
Submit your code: play against preset AI
Click "Game" in the left column, and then you will see the Trap Gomoku game. In
the game description, there are time and memory constraints for each step.
Please note that exceeding the time or memory limit will result in an automatic
loss. Click "Submit Here" to go to the submission page. The platform provides a
sample algorithm: a random decision AI. You can use this as a reference to
understand the input-output format and game mechanics before implementing
your own strategy. The system will only retain your latest submission, so please
ensure that your last submitted code runs correctly. If you have iterated through
3
multiple versions, it is recommended that you save them locally to avoid losing
previous work.
We have set up three predetermined AI opponents for you to challenge:
"Offensive," "Defensive," and "Random," designated by user IDs 1, 2, and 3,
respectively. You can select the AI you want to compete against by choosing its
ID.
After submitting your code, you will not receive the result immediately. You
need to click refresh to view your game results. To ensure fairness and account
for any advantages or disadvantages of moving first, each AI pairing will consist
of two matches:
● One match where your own AI moves first.
● One match where your opponent moves first.
The results of these matches, along with time and memory usage, will be
updated after each submission.
Check log
You can download the log to view the state of the chessboard at each step after
getting the results. We also provide a visual interface that displays the placement
of each move step by step, making it easier for you to analyze and review your
games.
Tournament and Ranking
The tournament itself takes place the day following the deadline. On this
"competition day," the server will be offline. Your AI's performance will be
evaluated based on its win rate across the matches (If there is a draw, it will not
count as a win). When two participants' AIs have identical win rates, the AI that
used less time to achieve its wins will receive a higher ranking. After the
tournament, each participant can view the match logs of all their games against
other players. Once everyone has reviewed the logs and confirmed no issues, we
will announce the tournament rankings through the ranking page.
4
5 Requirements
Format of the code:
● The answer must include the play_games function as the interface for
online judgment, which is defined as,
C/C++: void play_games(int step, int rival_decision1,int rival_decision2);
Python: play_games(step:int,rival_decision_x:int,rival_decision_y:int)->None
Java: public static void play_games(int step, int rival_decision_x, int
rival_decision_y)->None
● Step indicates the move number in the current game. It starts from
Player A, step=1, then turns to player B, step=2, and then turns to
player A, step=3, …, end of the game.
● That is, player A's step is always odd, and player B's step is even.
Step=0 represents an empty checkerboard for initialization.
● rival_decision_x,y are the opponent’s decisions made in the
previous step, which can help you make better responses.
● You can read the board and save the decision through the read_ckbd and
save_decision functions. MAX_M and MAX_N are the size of the board
(equal to 15 in this game). They are defined in battle_base.
● C/C++: void read_ckbd(int step, int array[MAX_M][MAX_N]);
void save_decision(int x, int y);
● Python: read_ckbd(step:int)->List[List[int]]
save_decision(x:int, y:int)->None
● Java: battle_base.read_ckbd(int step) -> int [MAX_M][MAX_N];
battle_base.save_decision(int x, int y);
● In the array/list returned by read_ckbd, 0 represents the unplayed
area and you can make a decision here. 1 represents player A’s
decisions, 2 represents player B’s decisions, and 3 represents the
traps.
● Note that you must save your decision by calling save_decision in
the play_games function, don’t return anything. Do not try to
rewrite those functions, you just call them. You can read the
previous step of chess before the current step.
● The main function is not allowed in the answer.
● You can use print/printf/cout to print logs to help you debug. They will
be printed in the battle_log.txt.
5
● If you use Java, JVM will occupy memory, resulting in higher memory
usage.
Submission requirements:
● For Python users: python base modules (in sys.modules.keys()): functools,
random, sorted, heapq, collections, etc. are allowed. You are not allowed
to use other packages like numpy, sklearn, etc.
● For C/C++ users: most header files are allowed, even including
,
and
.
● For Java users: You cannot use external third-party libraries or other
non-standard Java packages that are not included in the JDK.
● You cannot use some system calls such as change directory, list file,
create file, remove file, etc.
● For all AI programs, we limit the running time and the total memory
usage, which you can find on the website.
● Violation of any of the above will raise an error and cause the game to be
lost.
Requirement for the report:
You should write a report to explain your AI. Describe your algorithm as clearly
as possible. Feel free to use examples and add screenshots or other figures if
they can help better illustrate your method. If you adopt some part of your code
from somewhere, you must fully acknowledge this and provide a reference to
where you obtained the code. You must declare how much of your submitted
code is obtained from someone/somewhere else and how much is indeed
written by you. At the end of your report, include the related references from
where you have gathered useful information in working on your assignment.
You need to submit your source code to the online judgment system and submit
your report to Canvas.
Name your files according to the following format, where XXXXXXXX is the 8
digits of your student ID number:
CS4386-2425B-A1-XXXXXXXX-Report.pdf (should be in PDF format)
6 Q&A
We will also create a discussion on Canvas. You can ask questions there; the TAs
will check it daily and answer your questions as soon as possible.
6
7 Academic Honesty
We have repeatedly emphasized the importance of academic honesty. Review
the website https://www.cityu.edu.hk/pvdp/ah/index.htm on academic
honesty if needed.
This is an individual assignment so each of you should write your own code. You
should never send any part of your code to your classmate “for his/her
reference” or copy any part of the code from your classmate. You should
obviously understand the code that you submit, and be able to explain your code
when asked.
Make sure that you do not commit any academic dishonest behaviors while
working on this assignment!
7
Appendix: Sample submission code
Python:
import random
from battle_base import read_ckbd, save_decision,MAX_M,MAX_N
def play_games(step:int,rival_decision_x:int,rival_decision_y:int)->None:
states = read_ckbd(step-1)
legal_decision = []
for m in range(MAX_M):
for n in range(MAX_N):
if states[m][n]==0: # 0 is unplayed area
legal_decision.append((m, n))
# make your decision here
decision = random.choice(legal_decision)
save_decision(decision[0], decision[1])
C:
#include
#include
#include "battle_base.h"
#define max(a,b) ((a) >= (b) ? (a) : (b))
void play_games(int step, int rival_decision_x,int rival_decision_y) {
int states[MAX_M][MAX_N]; // Assuming MAX_M and MAX_N are defined board
size
read_ckbd(step-1, states);
int legal_decision[MAX_M*MAX_N][2];
int legal_count = 0;
for (int m = 0; m < MAX_M; m++) {
for (int n = 0; n < MAX_N; n++) {
if (states[m][n] == 0) // 0 is unplayed area
{
{
legal_decision[legal_count][0] = m;
legal_decision[legal_count][1] = n;
legal_count++;
}
}
}
}
// Make your decision here
int random_index = rand() % legal_count;
int* decision = legal_decision[random_index]; // Example of random
strategy
save_decision(decision[0], decision[1]);
}
8
C++:
#include
#include
#include
#include "battle_base.h"
void play_games(int step, int rival_decision1,int rival_decision2) {
int states[MAX_M][MAX_N]; // Assuming MAX_M and MAX_N are defined board
size
int states_count = 0;
read_ckbd(step-1, states);
int legal_decision[MAX_M*MAX_N][2];
int legal_count = 0;
for (int m = 0; m < MAX_M; m++) {
for (int n = 0; n < MAX_N; n++) {
if (states[m][n] == 0) // 0 is unplayed area
{
{
legal_decision[legal_count][0] = m;
legal_decision[legal_count][1] = n;
legal_count++;
}
}
}
}
// Make your decision here
int random_index = rand() % legal_count;
int* decision = legal_decision[random_index]; // Example of random
strategy
save_decision(decision[0], decision[1]);
}
Java:
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class play_fun {// Do not change the class name
static final int MAX_M = battle_base.MAX_M;
static final int MAX_N = battle_base.MAX_N;
public static void play_games(int step, int rival_decision_x, int
rival_decision_y) {
int[][] states = battle_base.read_ckbd(step-1);
List
legalDecision = new ArrayList<>();
for (int m = 0; m < battle_base.MAX_M; m++) {
for (int n = 0; n < battle_base.MAX_N; n++) {
if (states[m][n] == 0) { // 0 is unplayed area
legalDecision.add(new int[]{m, n});
9
}
}
}
// Make your decision here
Random random = new Random();
int[] decision =
legalDecision.get(random.nextInt(legalDecision.size()));
battle_base.save_decision(decision[0], decision[1]);
}
}
10
热门主题
代做ceng0006: coursework代写...
02-22
代做assignment 1 - case stud...
02-22
代写co 101 project 1 mass co...
02-22
代做uestc 4004 digital commu...
02-22
代做accfin5246 data science ...
02-22
代写accfin5246_2a data scien...
02-22
代做java lab 2代做留学生java...
02-22
代写math 132a assignment 4代...
02-22
代做uestc 4004 digital commu...
02-22
代做uestc 4004 digital commu...
02-22
代写math 132a assignment 3调...
02-22
代做uestc 4004 digital commu...
02-22
代写ee6307、代做java/python编...
02-22
代写program、代做python设计编...
02-22
代写tutorial 5 structured qu...
02-21
代写homework 6: measuring bi...
02-21
代做problem set 1代写process...
02-21
代写f24 adms 3541 case study...
02-21
代写lang7402 introduction to...
02-21
代写english language and stu...
02-21
课程名
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
站长地图