CS4386讲解、Programming讲解、Python辅导、Python程序设计调试 调试C/C++编程|讲解数据库SQL
- 首页 >> C/C++编程 CS4386 AI Game Programming, Semester B, 2019-2020
Assignment 2 (Deadline: Friday 24 April 2020)
1. Introduction
In this assignment, you will code your AI bots in Python for playing the game called
‘Dots And Boxes’. This game is played on a rectangular grid of dots. Players alternate
drawing a horizontal or a vertical line between adjacent dots - if they complete a box
then they score 1 point (per box) and get another turn. The player with the most points
once all of the boxes have been completed wins.
1.1 Sign up an Account and View Game Details
1) Go to the webpage https://www.aigaming.com/ and click on the REGISTER button
in the upper right corner to sign up an account.
Then follow the instructions to sign up an account. The account username that you
sign up should have the format 4386_20B_XXXX, meaning that it should have the
prefix 4386_20B_ and followed by XXXX which are the last 4 digits of your student ID
CS4386 AI Game Programming, Semester B, 2019-2020
(e.g., if your student ID is 56781234, then your username should be 4386_20B_1234).
Please remember your username and password.
2) After login, click on GAMES → Dots And Boxes.
Then you will get the information of this game. You can watch the game video (left),
and check the leaderboard of this game (right). If you click on VIEW ALL, you will see
all the battle history or the whole leaderboard.
CS4386 AI Game Programming, Semester B, 2019-2020
Scroll down the page, you can get the documentation and rules of this game.
By clicking on DOCUMENTATION, you can get the detailed game rules, game strategy
and programmers’ reference (how to make a move, gamestate, etc.). You should read
the information carefully, which is very helpful for you to design your own bot.
If you are familiar with this game or website, you can click on ‘Really Quick Start’ (left
column) to get the bare minimum instructions.
CS4386 AI Game Programming, Semester B, 2019-2020
1.2 Getting started by online editor
After we know the above information, we can start coding using online editor. You can
click on Click here (in the upper corner of every page) to enter the editor.
The editor looks like this:
1.3 How to modify the starter bot?
The starter bot gives the easiest way to find a move. In the calculate_move() function,
we can see that, in each turn, the starter bot randomly chooses a legal move x and
then return it.
To write your own bot, you need to change the following line:
CS4386 AI Game Programming, Semester B, 2019-2020
x=random.randint(0,len(legal_moves)-1) to your own AI codes.
Please note that timeout for each turn is 5000 ms. Hence you must make a move
within 5000 ms.
2.Test your bot
2.1 Test your bot online
1) Click on the ‘EDITOR’ button on the top.
2) This page is The Code Editor. It lets you develop your game playing bots and test
your bots online. Please make sure that the game type you select is ‘Dots and Boxes’.
You could use ‘housebot-practice’ as your opponent, which is the easiest one or other
people by selecting the Anyone option from the Select Opponent dropdown. This
option means that your bot will play against any compatible bot that is running at the
same time. If you know another person's bot name, or if you want to compete against
a friend, you can specify their bot name. You do this by typing their bot name into the
field at the top of the Select Opponent dropdown. For the game style, you should
choose ‘8001|5*5|Stake:0|Prize:0’. And the programming language you use MUST be
Python.
3) Choose the bot you want to test on navigator and click on the ‘RUN’ button (upper
right corner).
CS4386 AI Game Programming, Semester B, 2019-2020
Even without changing the codes, you can click on the ‘RUN’ button to submit your
bot. Then you can check your ranking in the leaderboard. In my test, if I submit the
starter bot without any changes, I can rank around 80th in the leaderboard. Therefore,
your bot MUST rank higher than the starter bot.
4) You can click on the blue sign ‘<<’ to check the console output.
If you want to know the content of a variable, you can use the print() function and see
the outputs under ‘Information’, which is very useful for debugging.
5) When your game has finished, you'll be able to see the output.
CS4386 AI Game Programming, Semester B, 2019-2020
2.2 Check the rankings
1) Back to the main page, click on GAMES and choose Dots and Boxes.
2) Click on the VIEW ALL button on DOTS AND BOXES LEADERBOARD part to see the
rankings.
3. Assignment Submission
3.1 Preparation
a) Source code
• At the beginning of ALL your python files, add the following comments to
your code:
#############################
##CS4386 Semester B, 2019-2020
CS4386 AI Game Programming, Semester B, 2019-2020
##Assignment 2
##Name: [Your name]
##Student ID: [Your student ID]
###########################
• Download ALL your python files from the online editor by clicking on
SAVE→SAVE AS button:
• Rename the zip file that contains the related files of your AI bot source code
as CS4386_1920B_[studentID]_[name].zip, where [studentID] is your
student ID and [name] is your name. You need to submit this zip file to
Canvas.
b) A report
• You should write a report to explain your AI bot.
• At the beginning of the report, include the following information:
o The heading “CS4386 Assignment 2 (Semester B, 2019-2020)”
o Your name
o Your student ID
o Your username on AI GAMING
• You should then 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 how much is indeed written by you.
CS4386 AI Game Programming, Semester B, 2019-2020
• At the end of your report, include the related references from where you
have gathered useful information in working on your assignment
• Convert your report to a PDF file with the file name
CS4386_1920B_[studentID].pdf, where [studentID] is your student ID.
• You need to submit this report together with your source code to Canvas.
3.2 Handing in
You should submit your AI bot to BOTH AI GAMING AND Canvas and submit your
report to Canvas before the assignment deadline (Friday 24 April 2020).
a) AI GAMING Website:
• You should upload your last completed bot to AI GAMING website under
your account and run it, as described in section 2.1.
b) Canvas Website:
• You should upload the following 2 files to Canvas (under Assignment >
Assignment 2)
1. CS4386_1920B_[studentID]_[name].zip
2. CS4386_1920B_[studentID].pdf
• Click Browse and select your zip file containing the source code of your AI
bot:
• Click Add Another File, then click Browse and select your PDF file containing
your report:
CS4386 AI Game Programming, Semester B, 2019-2020
• After making sure that you have selected the 2 correct files, click ‘Submit
Assignment’ to finalize your assignment submission on Canvas.
3.3 Grading Policy
The total score for this assignment is 20 marks with the following components:
a) Offline Testing (10 marks)
Our TAs will run your bot with all of the bots of your classmates one by one. This
method is more reliable than the online leaderboard.
Note: If you do not submit your bot, you will get 0 for this part.
b) Report (5 marks)
Note: If you do not submit the report, you will get 0 for this part.
c) Algorithms in your Codes (5 marks)
Note: If your algorithm is the same as the starter bot (or similar to random
selection), you will get 0.
4. References for the Algorithm
The following links contain some potential methods and sample codesthat can be used
for reference. Of course, you are also encouraged to try other algorithms.
Minimax
Code
https://github.com/benjamingorman/DeepBox
https://github.com/Armando8766/Dots-and-Boxes
CS4386 AI Game Programming, Semester B, 2019-2020
5. Help Seeking
At any time if you are lost or if you have any question, you can post your question on
CANVAS and our TAs (Xianjin CHAO and Xiaoya CHONG) will respond to your question
as quickly as possible. Besides, please also feel free to send emails to the TA Xianjin
CHAO (email: xjchao2-c@my.cityu.edu.hk) who will be very happy to help you.
Assignment 2 (Deadline: Friday 24 April 2020)
1. Introduction
In this assignment, you will code your AI bots in Python for playing the game called
‘Dots And Boxes’. This game is played on a rectangular grid of dots. Players alternate
drawing a horizontal or a vertical line between adjacent dots - if they complete a box
then they score 1 point (per box) and get another turn. The player with the most points
once all of the boxes have been completed wins.
1.1 Sign up an Account and View Game Details
1) Go to the webpage https://www.aigaming.com/ and click on the REGISTER button
in the upper right corner to sign up an account.
Then follow the instructions to sign up an account. The account username that you
sign up should have the format 4386_20B_XXXX, meaning that it should have the
prefix 4386_20B_ and followed by XXXX which are the last 4 digits of your student ID
CS4386 AI Game Programming, Semester B, 2019-2020
(e.g., if your student ID is 56781234, then your username should be 4386_20B_1234).
Please remember your username and password.
2) After login, click on GAMES → Dots And Boxes.
Then you will get the information of this game. You can watch the game video (left),
and check the leaderboard of this game (right). If you click on VIEW ALL, you will see
all the battle history or the whole leaderboard.
CS4386 AI Game Programming, Semester B, 2019-2020
Scroll down the page, you can get the documentation and rules of this game.
By clicking on DOCUMENTATION, you can get the detailed game rules, game strategy
and programmers’ reference (how to make a move, gamestate, etc.). You should read
the information carefully, which is very helpful for you to design your own bot.
If you are familiar with this game or website, you can click on ‘Really Quick Start’ (left
column) to get the bare minimum instructions.
CS4386 AI Game Programming, Semester B, 2019-2020
1.2 Getting started by online editor
After we know the above information, we can start coding using online editor. You can
click on Click here (in the upper corner of every page) to enter the editor.
The editor looks like this:
1.3 How to modify the starter bot?
The starter bot gives the easiest way to find a move. In the calculate_move() function,
we can see that, in each turn, the starter bot randomly chooses a legal move x and
then return it.
To write your own bot, you need to change the following line:
CS4386 AI Game Programming, Semester B, 2019-2020
x=random.randint(0,len(legal_moves)-1) to your own AI codes.
Please note that timeout for each turn is 5000 ms. Hence you must make a move
within 5000 ms.
2.Test your bot
2.1 Test your bot online
1) Click on the ‘EDITOR’ button on the top.
2) This page is The Code Editor. It lets you develop your game playing bots and test
your bots online. Please make sure that the game type you select is ‘Dots and Boxes’.
You could use ‘housebot-practice’ as your opponent, which is the easiest one or other
people by selecting the Anyone option from the Select Opponent dropdown. This
option means that your bot will play against any compatible bot that is running at the
same time. If you know another person's bot name, or if you want to compete against
a friend, you can specify their bot name. You do this by typing their bot name into the
field at the top of the Select Opponent dropdown. For the game style, you should
choose ‘8001|5*5|Stake:0|Prize:0’. And the programming language you use MUST be
Python.
3) Choose the bot you want to test on navigator and click on the ‘RUN’ button (upper
right corner).
CS4386 AI Game Programming, Semester B, 2019-2020
Even without changing the codes, you can click on the ‘RUN’ button to submit your
bot. Then you can check your ranking in the leaderboard. In my test, if I submit the
starter bot without any changes, I can rank around 80th in the leaderboard. Therefore,
your bot MUST rank higher than the starter bot.
4) You can click on the blue sign ‘<<’ to check the console output.
If you want to know the content of a variable, you can use the print() function and see
the outputs under ‘Information’, which is very useful for debugging.
5) When your game has finished, you'll be able to see the output.
CS4386 AI Game Programming, Semester B, 2019-2020
2.2 Check the rankings
1) Back to the main page, click on GAMES and choose Dots and Boxes.
2) Click on the VIEW ALL button on DOTS AND BOXES LEADERBOARD part to see the
rankings.
3. Assignment Submission
3.1 Preparation
a) Source code
• At the beginning of ALL your python files, add the following comments to
your code:
#############################
##CS4386 Semester B, 2019-2020
CS4386 AI Game Programming, Semester B, 2019-2020
##Assignment 2
##Name: [Your name]
##Student ID: [Your student ID]
###########################
• Download ALL your python files from the online editor by clicking on
SAVE→SAVE AS button:
• Rename the zip file that contains the related files of your AI bot source code
as CS4386_1920B_[studentID]_[name].zip, where [studentID] is your
student ID and [name] is your name. You need to submit this zip file to
Canvas.
b) A report
• You should write a report to explain your AI bot.
• At the beginning of the report, include the following information:
o The heading “CS4386 Assignment 2 (Semester B, 2019-2020)”
o Your name
o Your student ID
o Your username on AI GAMING
• You should then 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 how much is indeed written by you.
CS4386 AI Game Programming, Semester B, 2019-2020
• At the end of your report, include the related references from where you
have gathered useful information in working on your assignment
• Convert your report to a PDF file with the file name
CS4386_1920B_[studentID].pdf, where [studentID] is your student ID.
• You need to submit this report together with your source code to Canvas.
3.2 Handing in
You should submit your AI bot to BOTH AI GAMING AND Canvas and submit your
report to Canvas before the assignment deadline (Friday 24 April 2020).
a) AI GAMING Website:
• You should upload your last completed bot to AI GAMING website under
your account and run it, as described in section 2.1.
b) Canvas Website:
• You should upload the following 2 files to Canvas (under Assignment >
Assignment 2)
1. CS4386_1920B_[studentID]_[name].zip
2. CS4386_1920B_[studentID].pdf
• Click Browse and select your zip file containing the source code of your AI
bot:
• Click Add Another File, then click Browse and select your PDF file containing
your report:
CS4386 AI Game Programming, Semester B, 2019-2020
• After making sure that you have selected the 2 correct files, click ‘Submit
Assignment’ to finalize your assignment submission on Canvas.
3.3 Grading Policy
The total score for this assignment is 20 marks with the following components:
a) Offline Testing (10 marks)
Our TAs will run your bot with all of the bots of your classmates one by one. This
method is more reliable than the online leaderboard.
Note: If you do not submit your bot, you will get 0 for this part.
b) Report (5 marks)
Note: If you do not submit the report, you will get 0 for this part.
c) Algorithms in your Codes (5 marks)
Note: If your algorithm is the same as the starter bot (or similar to random
selection), you will get 0.
4. References for the Algorithm
The following links contain some potential methods and sample codesthat can be used
for reference. Of course, you are also encouraged to try other algorithms.
Minimax
Code
https://github.com/benjamingorman/DeepBox
https://github.com/Armando8766/Dots-and-Boxes
CS4386 AI Game Programming, Semester B, 2019-2020
5. Help Seeking
At any time if you are lost or if you have any question, you can post your question on
CANVAS and our TAs (Xianjin CHAO and Xiaoya CHONG) will respond to your question
as quickly as possible. Besides, please also feel free to send emails to the TA Xianjin
CHAO (email: xjchao2-c@my.cityu.edu.hk) who will be very happy to help you.