CS4386AIGameProgramming

AI权益加码!Claude Code、Cursor等20+工具免费用! 购周边限时加赠Coding Plan Lite,畅享主流AI工具!学习进阶更高效! 阅读详情

CS4386AIGameProgramming
Assignment2:
TheX-patternGame
Set by CS4386 TA Team
Early Testing Deadline:
Thursday 28th 23:59 March2024
Sunday7th23:59 April 2024
Final Submission Deadline:
Sunday21th 23:59 April 2024
This assignment is worth
20 %(twenty percent)
of the overall course mark
Overview
1 Introduction
2 Marking scheme
3 TheX-pattern Game
4 Online Judgment platform
5 Requirements
6 Q&A
1 Introduction
You are tasked with writing an AI program that can run the X-pattern game, you
can implement your AI program using algorithms including but not limited to
those learned in class. You can use Python, C or C++ to implement your AI
program. An online AI game judgment platform is provided to submit and test
your code.
2 Marking scheme
Item
Due
Mark
Beat preset AI
Tournament1
Tournament2
Tournament3
Report
21th April 2359
28th March 2359
7th April 2359
21th April 2359
21th April 2359
30
0
20
20
30
Total
100
Note: Your AI performance depends on:
● Whetheryoubeat our three preset AIs. If you beat all our three preset AIs,
you will get 30 points (10 points for each AI).
● Yourranking in tournaments. We will schedule three tournaments. After
each tournament, you’ll be able to 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 algorithm
and report will also affect the final score. Take some time to make it look good.
3 TheX-pattern Game
The X-Pattern Game is a strategic board game where two artificial intelligence
(AI) players compete to form ‘X’ patterns on a 10x10 grid. Each player takes turns
to place their pieces, aiming to create as many ‘X’ patterns as possible to get
higher points. The game ends when the grid is filled(no more than 100 moves)
and the player who creates more X-pattern on the grid will be the winner. You
are encouraged to come up with your own strategies to make your AI make
better decisions in each turn. We are excited to see your brilliant ideas and how
they challenge each other !
2
Figure 1. Scoreshapeexamples
Whenthe gameends, we will calculate your score by counting the number of
full ‘X’ patterns in the grid. The player with the higher score will be the winner,
and the final score and game log will be provided. For example, in figure1, player
Ogains 4 points and player X gains 5 points, so player X is the winner.
4Online 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. The platform
supports Python, C and C++ as your program language.
Register and log in
● Youshouldregister using your Cityu email.
● Youshouldregister using your real name.
● Uponregistration, you will be arranged a useID. Only your ID will be
showed in the ranking.
Submit your code: play against preset AI
Click on “Game” in the left column, then you can see the X-pattern game. Click
“X-pattern” game then click “Submit Here” to go to the submission page. Fill in
your code and click “Submit” to submit. You can choose a language you are
familiar with.
3
4
Figure2. Submityourcodeandgetresult
We’ve set up three predetermined AI opponents for you to challenge: “Random,”
“Defensive,” and “Offensive,” designated by user IDs 1, 2, and 3, respectively. Upon
submitting your code, it will automatically be matched against the Random (AI1)
and Defensive (AI2). You’ll need to periodically refresh the page to view the
outcomes of these matches.
To ensure fairness, considering the advantage or disadvantage of starting first,
we’ll conduct two matches for each AI pairing. This includes one game where
your AI going first, and another where it plays second(opponent going first). The
results of these matches, along with the time and memory usage statistics, will
be updated following each submission.
To earn the “Beat preset AI” score, your most recent AI submission must
outperform our preset AIs in both match configurations—once your AI going
f
irst and once opponent going first. Please note, the matches against the
“Offensive AI” will not be visible during your testing phase.
5
Check log:
You can download the log to view the state of the chessboard at each step after
getting the results.
Figure 3. Foreachsubmission,youcanclickthedownloadlogs ile(format:
userid1_userid2 , userid1 is alwaystheplayergoing irst).Youcanalsoviewthelogs
directly on thewebsite.
View ranking
The system will save the most recent version of your code submitted prior to
each tournament deadline. 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).
In instances where two participants’ AIs have identical win rates, the AI that
used less time to achieve its wins will receive a higher ranking. While you’re free
to check the rankings at any moment, it’s important to remember that these
interim rankings only compare your AI against our preset AI and not against the
entire field of competitors. Therefore, these preliminary standings do not
represent the final rankings for the tournament. The definitive rankings will be
announced once all matches are concluded and thoroughly evaluated.
6
5 Requirement
Format of the code:
● Theanswermustinclude 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
● stepindicates 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.
● Thatis, player A’s step is always odd, 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.
● Youcanreadtheboard and save the decision by read_ckbd, save_decsion
functions. MAX_M, MAX_N are the size of the board, (equal 10 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
● Inthearray/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.
● Notethat you must save your decision by calling save_decision in
play_games function, don’t return anything. Do not try to write
those functions, you just call them. You can read any step of chess
before the current step.
● Themainfunction is not allowed in the answer (especially for C/C++ ).
● Youcanuseprint/printf/cout to print logs to help you debugging. They
will be printed in the battle_log.txt.
● Thedetails of the read_ckbd, save_decsion functions are in the appendix.
Just for helping you run the battle on your computer. Please do not
include them in your answer.
7
Submission requirements:
● ForPythonusers: 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.
● ForC/C++users: most header files are allowed, even including
<bits/stdc++.h>, and .
● Youcannotusesomesystemcalls like change directory, list file, create
f
ile, remove file etc.
● Forall AI programs, we limit the total running time and the total memory
usage, you can find it on the website.
● Violation of any of the above will raise an error and let the game 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 it 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 obtain the code. You must declare how
much of your submitted code is obtained from someone/somewhere else and
howmuchis 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.
Nameyour files according to the following format, where XXXXXXXX is the 8
digits of your student ID number:
CS4386-2324B-A2-XXXXXXXX-Report.pdf (should be in PDF format)
6 Q&A
For any questions, please write an email to: yicongli4-c@my.cityu.edu.hk, We will
also create a discussion on Canvas. You can ask questions there and the TAs will
check it everyday and answer your questions as soon as possible.
8
Appendix: Sample submission code
Python:
import random
from battle_base import read_ckbd, save_decsion
def
play_games(step:int,rival_decision_x:int,rival_decision_y:int)->No
ne:
states = []
for s in range(max(step-2,0),step):
states.append(read_ckbd(s))
legal_decision = []
M,N = len(states[-1]),len(states[-1][0])
for m in range(M):
for n in range(N):
if states[-1][m][n]==0: # 0 is unplayed area
legal_decision.append((m, n))

make your decision here

decision = random.choice(legal_decision)
save_decsion(decision[0], decision[1])
9
C:
#include <stdio.h>
#include <stdlib.h>
#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[2][MAX_M][MAX_N]; // Assuming MAX_M and MAX_N are
defined board size
int states_count = 0;
for (int s = max(step- 2, 0); s < step; s++) {
read_ckbd(s, states[states_count]);
states_count++;
}
int legal_decision[MAX_MMAX_N][2];
int legal_count = 0;
for (int m = 0; m < MAX_M; m++) {
for (int n = 0; n < MAX_N; n++) {
if (states[states_count- 1][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]);
}
10
C++:
#include <stdio.h>
#include <stdlib.h>
#include
#include “battle_base.h”
void play_games(int step, int rival_decision1,int rival_decision2)
{
int states[2][MAX_M][MAX_N]; // Assuming MAX_M and MAX_N are
defined board size
int states_count = 0;
for (int s = std::max(step- 2, 0); s < step; s++) {
read_ckbd(s, states[states_count]);
states_count++;
}
int legal_decision[MAX_MMAX_N][2];
int legal_count = 0;
for (int m = 0; m < MAX_M; m++) {
for (int n = 0; n < MAX_N; n++) {
if (states[states_count- 1][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]);
}
11
The following code is for reference only, do not include them in
your answer.
Battle_base.py
import os
DESCISION_TMP = os.path.join(‘decision.txt’)
BATTLE_LOG = ‘logs’
MAX_M = 10
MAX_N = 10
def read_ckbd(step):
try:
array =[]
txt_path = ‘{}/ckbd{:0>3d}.txt’.format(BATTLE_LOG,step)
with open(txt_path,‘r’) as f:
data_lists = f.readlines()
for lines in data_lists:
array.append([int(x) for x in lines.strip().split(’
‘)])
return array
except:
raise IndexError(‘Invalid read’)
def save_decsion(a,b):
with open(DESCISION_TMP,‘w’) as f:
f.write(’{:d} {:d}'.format(a,b))
12
Battle_base.h
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_M 10
#define MAX_N 10
#define BATTLE_LOG “logs”
#define DESCISION_TMP “decision.txt”
#ifndef BATTLE_h
#define BATTLE_h
inline int read_ckbd(int step, int array[MAX_M][MAX_N]);
inline void save_decision(int a, int b);
void play_games(int step, int rival_decision1,int
rival_decision2);
int read_ckbd(int step, int array[MAX_M][MAX_N]) {
char txt_path[100];
sprintf(txt_path, “%s/ckbd%03d.txt”, BATTLE_LOG, step);
FILE *f = fopen(txt_path, “r”);
if (f == NULL) {
printf(“Error opening file\n”);
return 1;
}
int array_index = 0;
char line[100];
while (fgets(line, sizeof(line), f)) {
char *token = strtok(line, " ");
int index = 0;
while (token != NULL) {
array[array_index][index] = atoi(token);
token = strtok(NULL, " ");
index++;
}
array_index++;
}
fclose(f);
13
return 0;
}
void save_decision(int a, int b) {
FILE *f = fopen(DESCISION_TMP, “w”);
if (f == NULL) {
printf(“Error opening file\n”);
return;
}
fprintf(f, “%d %d”, a, b);
fclose(f);
}
#endif
14

GCP Vertex AI 生产监控告警:Cloud Function 转发钉钉与电话 Vertex AI / Gemini 的指标在 Cloud Monitoring 里有 200+ 条,但通知渠道是邮件、Slack、PagerDuty、Webhook。国内值班要钉钉和电话,必须自己接一层转发。容量不够(429)怎么扩,看同库 PT 文。错误和配额超限怎么在 5 分钟内打到人,恢复时不要再打电话。用哪些 metric.type,duration 为什么是 300s单 Function +?project=路由电话组回滚是删策略 / 换渠道,不是删模型。 阅读详情

相关推荐

EasyOCR全栈实战 | 全网独家复现图像增强与多语言适配优化、助力票据证件仪表盘工业OCR精准落地

光学字符识别(OCR)是工业数字化、政务无纸化、企业数据自动化采集的核心基础技术,核心作用是将图片、视频帧中的印刷体、手写体字符转化为可编辑、可统计、可入库的结构化文本,广泛应用于财务票据归档、身份证件信息提取、工业仪表盘数据采集、多语言图文解析、纸质文档电子化等场景。在智能制造、政企数字化转型的大背景下,传统人工录入文字的方式效率低、误差大、人力成本高,智能OCR识别已成为替代人工数据采集的刚需能力。当前工业场景落地的传统OCR方案存在大量无法规避的技术短板,严重制约实际落地效果。

qq_36130719的博客 346

Hi3516CV610 YOLOv8模型转换与部署实战:从ONNX到OM全流程解析

在嵌入式AI领域,将YOLOv8这样的先进目标检测模型部署到海思Hi3516CV610这类边缘计算平台,正成为智能安防、工业质检、智慧交通等场景的热门需求。然而,从PyTorch模型到开发板可执行文件的全链路涉及环境配置、模型导出、格式转换、量化优化等多个环节,每一步都可能遇到“坑”。本文将基于实战经验,带你从头开始,完整走通YOLOv8模型从PyTorch导出ONNX,再到海思平台OM模型转换的全流程。本文完整梳理了从环境搭建到YOLOv8模型转换为Hi3516CV610平台OM格式的全流程。环境先行。

437

CS4386 Java

● Step indicates the move number dai 写CS4386、Java in the current game. It starts from。

wantwished的博客 751

【IEEE出版】第八届机器学习、大数据与商务智能国际会议(MLBDBI 2026)

收录检索: IEEE Xplore, EI Compendex, Scopus。第八届机器学习、大数据与商务智能国际会议(MLBDBI 2026)早鸟优惠截止时间:2026年9月8日 23:59。三轮截稿时间:2026年9月11日23:59。点击官网 即可参会/投稿/了解会议详情。接受/拒稿通知:投稿后1周左右。2026年10月23-25日。

Paperthinker的博客 212

本地商户 AI 搜索占位落地实操:解决实体门店获客难题

AI搜索占位是近两年新兴的、适合本地商家的低成本获客方式。这项工作的核心不是为了争抢广告排名,而是搭建一套完整、可信的本地门店信息。当用户查询同城服务相关问题时,AI可以自然抓取和引用门店信息。这套实操方法适配家政、装修、汽修、美业、餐饮等所有本地实体行业。掌握以上全套 AI 搜索占位落地方法,本地实体商家可以低成本、长期稳定获取 AI 问答精准客源,是当下性价比很高的新型本地获客方式。

2601_95649986的博客 99

【AI 大模型】国内各平台 AI 大模型 价格、性能 对比分析 ① ( DeepSeek | 火山方舟 )

一、DeepSeek 1、模型价格 2、MOE 模型架构 3、deepseek-v4-flash、deepseek-v4-pro 多维度对比 二、火山方舟 1、火山引擎 和 火山方舟 2、火山方舟 AI 大模型付费方式 3、火山方舟 性价比高的模型 4、多维度对比 火山方舟 AI 大模型 5、火山方舟 AI 大模型 接入到 AI 编程工具

让 学习 成为一种 习惯 ( 韩曙亮 の 技术博客 ) 309

matlab车牌出入库识别系统停车场演示【源码61期】

<think>我们只需要根据用户提供的长文生成摘要≤150字。内容是车牌识别系统介绍,包括算法流程、功能、不足和代码获取。摘要要简洁概括核心。</think>基于MATLAB GUI的车牌识别与停车场管理系统,集车牌定位、字符分割、模板匹配识别及Excel车辆管理于一体。采用Canny边缘检测、投影法精确定位蓝色车牌,通过垂直投影分割字符并归一化匹配识别。系统支持入库出库及车位查询,但依赖蓝色车牌、模板匹配鲁棒性有限,后续可引入深度学习与数据库优化。

2401_87395509的博客 270

ChatGPT 的回答也能被结构化抓取?AI Bot Scraper 对比测评

AI Bot Scraper 可以理解为一类「对话式 AI 的自动化采集工具」。它的本质不是传统意义上的网络爬虫,而是把「浏览器自动化、网络请求拦截、DOM 解析、数据清洗」组合起来的采集流水线。与抓取静态网页不同,它要处理的是一个实时生成、不断变化、需要登录态的复杂页面。会话准备:启动无头或有头浏览器,加载目标 AI 产品页面(如 ChatGPT、Claude、Gemini),并恢复登录态。登录态通常通过已保存的 Cookie、文件或扫码会话注入;提示词注入:把提前整理好的问题依次写入输入框并发送。

2601_96493715的博客 302

基于音视频转写与大模型摘要的会议纪要自动生成工具技术对比

本文对比百度网盘“简单听记”、讯飞听见、通义听悟三款AI会议纪要工具,分析其转写、说话人区分、摘要生成及存储安全等能力,并给出选择建议:网盘用户可选简单听记,重准确率可选讯飞听见,轻量免费可选通义听悟。同时提出提升纪要质量的实操建议,如优化录音、预置标签、导入热词、人工复核关键信息。

LearnYard的博客 461

FlyEnv 本地开发环境与 AI 协同能力深度评测

FlyEnv 以原生架构替代传统容器,实现轻量级本地开发环境。它通过自动识别项目依赖、一键启动全栈服务、多版本运行时隔离与 HTTPS 自动配置,显著提升开发效率。结合 MCP 协议,AI 可直接操控环境,完成“写代码—跑代码—修代码”闭环。实测显示其资源占用低、启动快,尤其适合低配设备与多项目并行场景。虽在复杂分布式场景仍难替代 Docker,但对 90% 的日常开发而言,是更高效、智能的现代化选择。

weixin_39394450的博客 269

免费AI网关测评:LiteLLM、New API和1Panel AI网关

为企业运维团队、AI业务团队提供选型参考。

FIT2CLOUD飞致云的博客 108

提取视频脚本有哪些方法?提取视频脚本的完整流程

视频脚本提取已成为内容创作与学习中的高频需求。尽管语音识别技术可将视频转为文字,但原始转写常含口语冗余、结构混乱、多人发言混淆等问题。需经去口语化、断句、分段与逻辑重构等二次整理,才能形成可用脚本。关键在于建立“识别→校对→结构化→再加工”的工作流,结合人工校验,将视频转化为可复用的知识素材,提升信息转化效率。

weixin_47068383的博客 250

基于LangChain+LLM大模型+机器学习的恶意域名(流量)智能检测系统

【夯爆了!

2601_96229748的博客 173

拉孚在AI领域的应用全景:从DeepBasic Folar数据底座到空间认知智能体,如何让物理空间“长“出智能

2025—2026年,大模型与AI智能体(Agent)技术已相当成熟,但在写字楼、工业园区、医院、机场等真实物理空间中,AI的落地率却远低于预期。数据孤岛林立:一栋楼里暖通、照明、安防、能耗、停车各自为政,BACnet、Modbus、KNX、OPC UA等协议互不相通,数据各守一方;空间模型不统一:同一个房间,楼宇自控叫"B3-201",安防系统叫"2F-A区",能源计量叫"计量点#47",坐标系都无法对齐,更谈不上跨系统推理;AI拿不到可用数据。

2601_96544574的博客 353

AI工具链驱动全栈开发:解锁未来软件的趋势密码与竞争力内核

文章浏览阅读511次,点赞5次,收藏10次。AI工具链正重塑全栈开发模式,推动三大核心趋势:开发范式从

2601_96207771的博客 207

深入理解人工智能 chatGPT的客户端与接入层 (Client & Access Layer)

**第三方集成**:通过 **Apps SDK** 和 **Model Context Protocol (MCP)**,ChatGPT 可以作为一个“宿主”环境,在其中运行第三方开发者构建的交互式应用(Widget)。* **用户认证**:对于普通用户,接入层会集成 **OAuth 2.0 / OIDC** 等标准协议,并支持企业级的 **SSO**。接入层是请求进入 OpenAI 后端基础设施的第一站,扮演着**流量警察**、**认证中心**和**调度员**的多重角色。

m0_73457176的博客 113

弱网环境下,电力AR系统如何保证SOP执行、任务同步与本地计算?

弱网环境下的电力AR系统,关键并不是要求所有功能在断网后完全不变,而是根据网络依赖把能力合理拆分SOP在现场执行,AI在边缘计算,任务在系统间同步,远程专家在网络可用时介入。安宝特AR电力解决方案通过AR眼镜、便携边缘服务器、移动通信设备和中心平台构成这一架构,使山区输电线路、电缆隧道、偏远变电站等网络条件复杂的电力现场,不必把所有作业能力建立在持续稳定公网之上。主动断一次网,确认SOP、AI、数据记录和恢复同步分别会发生什么。

安宝特AR的博客 317

车牌OCR识别-车牌号识别-车牌识别-车牌号OCR识别-车牌号图片识别

名称类型必须说明base64String否图片base64。base64、url、file 三选其一urlString否图片完整url。base64、url、file 三选其一fileFile否图片文件。base64、url、file 三选其一戳这里查看详情。

聚美智数 574

AI时代如何利用AI学好网络安全

AI时代为网络安全学习带来了全新的可能性。善用AI,可以大幅提升学习效率,加速技能成长;但也要清醒地认识到,AI只是工具,真正的核心竞争力在于扎实的基础知识、敏锐的安全思维和良好的职业道德。希望每一位学习者都能在AI的助力下,走出一条属于自己的网络安全成长之路。

2301_77732591的博客 201
上一篇: 命题公式的范式python
下一篇: CS360 Machine Learning Final Competition
todcode
博客等级 码龄7年 359粉丝 108原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值