首页
编程语言
数据库
网络开发
Algorithm算法
移动开发
系统相关
金融统计
人工智能
其他
首页
>
> 详细
program讲解 、辅导 C++设计程序
Project 2: Tank War
Due: Aug 11th (Sunday), 2024, 23:59
Language: C++
Note: C++ is compatible with C codes, i.e. you can write C codes and view
it as C++ code. However, a bonus will be given to those who use Object-Oriented
Programming (OOP) in their C++ code.
This is a group project. You may find your teammate on Canvas - People. Start
early - it’s strongly recommended that you do not leave this project to the last
minute. No late submissions are allowed!
This project is designed to hone your programming skills in C and C++. You
and your partner will implement a simplified Tank War game. You may find the
main idea of this project is a bit similar to demo project 2, Reversi. However,
instead of implementing the given functions, we will provide you maximum degrees
of freedom this time. No starter tiles, no skeleton, you are free to design your
own program structure and write everything you like.
Contents
Project 2: Tank War ......................................................... 1
1 Introduction .............................................................. 1
2 Rules ..................................................................... 1
2.1 Movement ................................................................ 1
2.2 Bullet .................................................................. 1
2.3 Life Point .............................................................. 2
2.4 Map ..................................................................... 2
2.5 Winning and Losing ...................................................... 2
3 Tasks (TO-DO List) ........................................................ 4
3.1 Features (75%) .......................................................... 4
3.1.1 Command-line Options (15%) ............................................ 4
3.1.2 PVP Mode (25%) ........................................................ 4
3.1.3 PVE Mode (15%) ........................................................ 4
3.1.4 DEMO Mode (10%) ....................................................... 4
3.1.5 Instruction Prompts and messages (10%) ................................ 4
3.2 Code Quality (10%) ...................................................... 4
3.3 README Documentation (10%) .............................................. 4
3.4 Peer Evaluation (5%) .................................................... 5
3.5 Bonus ................................................................... 5
4 Program Structure ......................................................... 5
5 Sample I/O (Minimal Example) .............................................. 5
5.1 Sample command-line options: ............................................ 5
5.2 Sample Input from stdin: ................................................. 5
5.3 Corresponding Output in stdout ........................................... 6
5.4 Sample Output of the Map ................................................ 6
6 Submission ................................................................ 7
1 Introduction
Tank War is a classic computer game. Each player controls a tank in this game,
competing to become the last survivor. This time, you are going to implement a
simplified two-player Tank War and write an AI to support Player Versus Environment
(PVE) and DEMO modes.
2 Rules
2.1 Movement
1. Two players battle in a spare map.
2. Each player controls a tank.
3. The tank moves 1 meter/turn.
4. Each turn, the tank can choose to move left, right or forward.
2.2 Bullet1. The tank shoots a bullet every three turns (starting from the first turn), and
the bullet will be generated 2 meter ahead of the tank’s position. (The bullet
has the same direction as the tank, and it is generated after the tank moves
in its turn, otherwise the tank will be shot by itself)
2. Bullet moves straightly at the speed of 2 meter/turn.
2.3 Life Point
1. Tank has p life points. (Determined by the user, default is 5)
2. Once a tank is hit by a bullet, 2 life points will be deducted.
3. To make your life easier, just assume that the bullet moves after the tank
moves since this will avoid geometry calculations. Hint: each turn there are
three possible cases where the bullet may hit a tank in your calculation.
4. Once a bullet hits a tank, it will not go further but explode.
2.4 Map
1. Initially, the the size of the map is 20*20. (A tank can go outside the map)
2. The map shrinks by block to the center every 16 turns (the first shrink occurs
in the 16th turn), namely the map size will
be 20*20 -> 18*18 -> 16*16 …
2. As long as a tank is outside of the map, one life point will be deducted
each turn.
2.5 Winning and Losing
1. The tank whose life points are first deducted to 0 will lose.
2. If the life points of two tanks are deducted to 0 in the same turn, they have
a draw competition.
3. When two tanks crash, the tank with high life points wins.
4. To make your life easier, each turn the calculation takes place after both two
tanks move.
Here’s a flow chart of the above rules:One thing that needs to be clarified is that after a bullet is spawned, it will
move two meters in this turn. So in the flow chart above, the “Move a Bullet”
part includes the bullet that is just generated this turn.3 Tasks (TO-DO List)
Your final product is a Tank War game that accepts command-line options, has
a command-line interface and supports PVP (Player vs. Player), PVE (Player vs.
Environment/AI) and DEMO (AI vs. AI) modes, and can run on every computer. In
this part, we provide a general guideline on project goals, sample I/O format and
project structure.
Just in case you get confused by the following project description and don’t
know what features will ultimately need to be implemented, here’s a brief to-do
list (and the score for each):
3.1 Features (75%)
3.1.1 Command-line Options (15%)
Your program should accept the following command-line options:
• -h and --help: Print a help message and exit.
• --log-file
: Log the game process to a file. (The default is tankwar.log) (Hint:
You may use -l as a short option, though it’s not required)
• -m
and --mode=
: Specify the game mode. The mode can be PVP, PVE or DEMO.
The default mode is PVP.
• -p
and --initial-life=p: Specify the initial life points of the tanks. The
default value is 5.
Note that both abbreviated and long options must be supported, i.e. help should
be displayed when either of the -h or --help command-line options are provided.
Hint: Check getopt.h.
$ ./tankwar --help
Usage: ./tankwar [options](optional)
Options:
-h | --help Print this help message and exit.
--log-file
Log the game process to a file. (Default: tankwar.log)
-m
| --mode=
Specify the game mode (PVP/PVE/DEMO). (Default: PVP)
-p
| --initial-life=
Specify the initial life points of the tanks. (Default: 5)
3.1.2 PVP Mode (25%)
• Correct Implementation of the Game Rules: 20%
• Clearly output the map after each turn: 5%
3.1.3 PVE Mode (15%)
• AI can work properly: 5%
• PVE mode functions correctly: 10%
3.1.4 DEMO Mode (10%)
• DEMO mode functions correctly: 10%
3.1.5 Instruction Prompts and messages (10%)
• Print the instruction prompts and messages in the game, e.g. “You have chosen
the PVE mode”, “Player 1′s turn”, “Please input the initial position of tank
A”, etc. (5%)
• Reasonable Command-Line Interface and I/O format (5%)
3.2 Code Quality (10%)
As mentioned in the labs, your code should be well-structured, commented and not
too long, with meaningful variable names and proper indention.Moreover, take care
of possible memory leaks and other possible issues mentioned in the lecture.
3.3 README Documentation (10%)
Search online what README is. Write a README for your project. The README should
be well-structured and informative. It should include the following sections:• We provide some sample questions to help you better construct your README. You
do not need to follow these questions strictly, but generally, you should write
your README around these questions.
• (Important) How to compile and run your program? Did you use the Layered Architecture
Pattern? If yes, briefly describe the components of each layer. If
not, explain your pattern;
• Did you use the Object-Oriented Paradigm? If yes, briefly describe the classes
you defined and their meanings. If not, state your paradigm;
• Your program’s I/O format including the log file;
• (Optional) Some typical issues and bugs you encountered in the development, and
your solutions;
• (Optional) Any other information you think is important, including bonus.
3.4 Peer Evaluation (5%)
Completing the evaluation will give you 5%. Official evaluation forms are to be
announced, so pay attention to Canvas Announcements. Note that your peer evaluation
result and the git activity will be taken into account when grading.
3.5 Bonus
• Use Object-Oriented Programming (OOP) in your C++ code. (up to 5%)
• For other features that you think can be counted as bonus, please discuss with
the Teaching Team before implementing them.
4 Program Structure
One of the fundamental design patterns when developing an object-oriented project
is Layered Architecture Pattern. This pattern partitions all of an application’s
classes and interfaces (future and current) into layers. It brings much flexibility
while also saving much rewriting when adjusting the code and allowing
faster debugging in case of a problem. The idea is to organize the code in terms
of layers and prevent any function for a lower layer from calling functions from
a higher layer. Functions from a higher layer can use functions in the same layer
or a layer below.
For this project, design your own layers. Here’s a link that may help you:
Layered Architecture Pattern
5 Sample I/O (Minimal Example)
This part gives a sample I/O of project 2. Please note that this is just a minimal
I/O example. As a user-friendly program, your I/O format should be more decorated
and detailed. For example, you may have some kind instructions and print the
current game board after each turn, just like what you did / will do in demo
project 2.
5.1 Sample command-line options:
./tankwar -m PVP --initial-life=5
5.2 Sample Input from stdin:0 0 19 19 2 0
In the command line options, --mode=PVP indicates that you start the PVP mode,
namely, both tanks’ initial positions and following actions are taken from user
input. --initial-life=5 indicates that the initial life point of each tank is 5.
In the first line of input, 0 0 and 19 19 are the initial positions of tank A
and tank B respectively, 2 (Right) is the initial direction of tank A, and 0 (Left)
is the initial direction of tank B. Here the directions and actions are defined
as below (feel free to change this definition in your program),
enum Direction {
D_Left, D_Up, D_Right, D_Down
};
enum Move {
M_Forward, M_Left, M_Right
};
6 Submission
Before submitting the project on Gitea (will be covered in lab 10), ensure the
project compiles on JOJ. The JOJ compilation test will be opened soon.
• A project submission which directly crashes when run will not be graded;
• We provide you with a CMakeLists.txt, but it’s recommended to write your own
Makefile/CMakeLists.txt;
• If the submission uses external libraries, e.g. GTK or sockets, please inform
the teaching team when uploading the code, and briefly conclude your design and
implementation in your README.
Then, in your repository, have a release with both title and tag as p2. The release
should contain:
• The source code of your project;
• A README file that includes the information mentioned above.
联系我们
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-21:00
微信:codinghelp
热点文章
更多
讲解 econ1202 – quantitativ...
2024-11-22
辅导 msds 490: healthcare an...
2024-11-22
讲解 civl 326 geotechnical d...
2024-11-22
辅导 term paper medicine whe...
2024-11-22
讲解 eng3004 course work辅导...
2024-11-22
讲解 ee512: stochastic proce...
2024-11-22
辅导 geog100 ol01 - fall 202...
2024-11-22
辅导 st5226: spatial statist...
2024-11-22
讲解 ece 101a engineering el...
2024-11-22
讲解 database development an...
2024-11-22
讲解 comp3134 business intel...
2024-11-22
讲解 practice exam 2, math 3...
2024-11-22
讲解 project 4: advanced opt...
2024-11-22
辅导 38003 organisational be...
2024-11-22
辅导 economic growth调试spss
2024-11-22
辅导 ee512: stochastic proce...
2024-11-22
讲解 eesb04 "principles of h...
2024-11-22
辅导 am2060 final assignment...
2024-11-22
辅导 acfim0035 fundamentals ...
2024-11-22
辅导 stat 612 (fall 2024) ho...
2024-11-22
热点标签
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
联系我们
- QQ: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!