Assignment 2
The Hunt
— introduction
— the rules
— the data
— faq
— the view
— [the hunt]
—
courtesy Richard Buckland, John Shepherd, and many tutors
Marks: 1000 (worth 6/15 towards assignment)
Due: Submit daily between August 3 and August 10 to participate in tournament rounds
Final tournament submission is 20:00 on Mon 10 August
Submit: give cs2521 ass2hunt AllFilesNeededToMakePlayers
Corrections
GameView.c
(provided code)
Click here to get the updated version.
Time updated: 2020-08-08 00:16
Line ~586- return &gv->moveHistory[player][numMovesMade - *numReturnedMoves]; + return &gv->draculaLocationHistory[numMovesMade - *numReturnedLocs];
GameView.c
(provided code)
Click here to get the updated version.
Time updated: 2020-08-04 23:50
Line ~190-193- if (play[3] == 'T') turn.actions[turn.numActions++] = PLACED_TRAP; - if (play[4] == 'V') turn.actions[turn.numActions++] = PLACED_VAMPIRE; - if (play[5] == 'M') turn.actions[turn.numActions++] = TRAP_MALFUNCTIONED; - if (play[5] == 'V') turn.actions[turn.numActions++] = VAMPIRE_MATURED; + if (play[5] == 'V') turn.actions[turn.numActions++] = VAMPIRE_MATURED; + if (play[5] == 'M') turn.actions[turn.numActions++] = TRAP_MALFUNCTIONED; + if (play[4] == 'V') turn.actions[turn.numActions++] = PLACED_VAMPIRE; + if (play[3] == 'T') turn.actions[turn.numActions++] = PLACED_TRAP;
Places.h
Time updated: 2020-08-03 21:09
Line ~168- const char *placeIdToAbbrev(PlaceId pid); + char *placeIdToAbbrev(PlaceId pid);
Places.c
Time updated: 2020-08-03 21:10
Line ~398- const char *placeIdToAbbrev(PlaceId pid) + char *placeIdToAbbrev(PlaceId pid)
Game.h
and player.c
Time updated: 2020-08-03 18:33
Please change all references tovoid registerBestPlay(const char *play, Message message)back to
void registerBestPlay(char *play, Message message)
Objectives
- to give you experience in implementing Graph-based ADTs
- to give you practice in implementing a heuristic game strategy
Background
The aim for this part of the assignment is to write AIs that can play The Fury of Dracula. The interface for the AIs is very simple: the game engine invokes the AI, giving it an appropriate view (which you implemented in the previous phase of the assignment), waits for a certain amount of time while the AI thinks about its move (possibly suggesting several moves), and then takes the last move suggested by the AI. The game engine then records the move, updates its own game state, and then moves on to the next AI. The interface for your AIs is very simple: they take a view as input, and send a new move and a message as their output.
Setting Up
In your repository directory, create a new directory for the hunt phase.
If you're on the CSE system, change into the directory that you just created, and run the command:
unzip /web/cs2521/20T2/ass/ass2/hunt/hunt.zip
If you're working from home, download the hunt.zip file and unzip the files into the directory that you just created.
This will extract the following files in your directory:
Makefile
- a set of dependencies used to control compilation
player.c
- a very simple main program to drive your AIs
dracula.h
- interface to the Dracula AI
dracula.c
- skeleton implementation of the Dracula AI
hunter.h
- interface to the hunter AI
hunter.c
- skeleton implementation of the hunter AI
Game.h
- definitions of game constants; interface to game engine
GameView.h
- interface to the GameView ADT
GameView.c
- skeleton implementation of the GameView ADT
DraculaView.h
- interface to the DraculaView ADT
DraculaView.c
- skeleton implementation of the DraculaView ADT
HunterView.h
- interface to the HunterView ADT
HunterView.c
- skeleton implementation of the HunterView ADT
Places.h
- interface to the Places ADT
Places.c
- implementation of the Places ADT
Map.h
- interface to the Map ADT
Map.c
- implementation of the Map ADT
IMPORTANT NOTE
The GameView, DraculaView and HunterView ADTs supplied in this package don’t actually do anything; they’re the skeleton versions we supplied in the view phase. You should replace these with your working versions.
If you have working views from the view phase of the assignment that you’re happy with, use them. If you can't get the views working, or if you’d prefer to use ours, we will provide our views after submissions for the view phase have closed (i.e., after 23:59 on Saturday 1 August). You will be able to download them here or via the following command if you're on the CSE system:
unzip /web/cs2521/20T2/ass/ass2/hunt/provided-views.zip
This will provide you with updated versions of GameView.c
, HunterView.c
, and DracView.c
, along with some additional ADTs needed to get these working and a Makefile
that includes these ADTs in the compilation. Please note that our views are not written to be optimal, so you should prefer to use your views if they work reasonably well. Also, these views are provided as-is; if they break, you get to keep the pieces.
Note that many of above files are provided simply as a convenience, and you can replace them with your own versions if you want. The only interfaces that you need to honour precisely as given are those for the AIs (i.e. hunter.h
and dracula.h
). If you plan to include other ADTs with your code, you’ll need to add dependencies to the Makefile
to ensure that they’re compiled.
If you run make
after copying your own view ADTs into place you should see something like the following:
make gcc -Wall -Werror -c -o dracula.o dracula.c gcc -Wall -Werror -DI_AM_DRACULA -c player.c -o playerDracula.o gcc -Wall -Werror -c -o DraculaView.o DraculaView.c gcc -Wall -Werror -c -o GameView.o GameView.c gcc -Wall -Werror -c -o Map.o Map.c gcc -Wall -Werror -c -o Places.o Places.c gcc dracula.o playerDracula.o DraculaView.o GameView.o Map.o Places.o -o dracula gcc -Wall -Werror -c -o hunter.o hunter.c gcc -Wall -Werror -c player.c -o playerHunter.o gcc -Wall -Werror -c -o HunterView.o HunterView.c gcc hunter.o playerHunter.o HunterView.o GameView.o Map.o Places.o -o hunter
Ultimately, it produces two executable files: ./dracula
, which contains the Dracula AI, and ./hunter
, which contains the hunter AI. They both work similarly (not surprising, since they come from the same source code file): they create a view based on a pastPlays string and an array of messages, invoke the decidePlayerMove
function, and finally print out the last move and message that was registered. For example:
./dracula Move: CD, Message: Mwahahahaha ./hunter Move: TO, Message: Have we nothing Toulouse?
Note that we supply our own player.c
when we run your AIs in the tournament. It does essentially the same thing as above, but additionally knows how to communicate with the game engine, and enforces a time limit on the AI. You can modify the supplied player.c
as much as you want. In particular, you could change the pastPlays strings and messages that are used to build the views to test out how your AI will respond.
What to Do
The interface you need to deal with is very simple: there are two functions to decide the next move that a player should make:
void decideHunterMove(HunterView state); void decideDraculaMove(DraculaView state);
… along with a function to register potential moves:
void registerBestPlay(char *play, Message message);
The registerBestPlay()
function is already written for you, so all you need to do is implement the decidePlayerMove()
functions, along with any auxiliary functions and ADTs that they require. The play
is the two-letter abbreviation of the move (e.g., LO
for London, D1
for Double Back 1); the message
can be any text string of up to MESSAGE_SIZE - 1
characters.
First, think about a strategy for each kind of player and what information is needed to use that strategy. If that information is already provided by your existing view ADTs, simply use them; otherwise implement new functions to get that information. Then, use these view ADTs as a basis for implementing the two decidePlayerMove()
functions. Finally, submit your work to the Hunt. Repeat the previous two steps until you are satisfied with your AIs’ performance.
The Hunt
Periodically (at least daily), from Sunday 2 August onwards, we will run a batch of Fury of Dracula games, using whatever AIs have been submitted (this is what we call a "hunt" or "tournament"). These games will be monitored and marks awarded to the participating AIs based on (a) whether they work at all, (b) whether they follow the rules, and (c) how well they play the game.
How each tournament works:
- we copy all submissions from the submissions directory (for
give
) - we attempt to compile each submission, using:
- all of your supplied files
- our own copies of
player.c
,dracula.h
,hunter.h
,Game.h
- your
Makefile
(modified by us to have one extra library required by ourplayer.c
)
- any
./dracula
and./hunter
files are saved - for each (
hunter
,dracula
) pair do:- move the
hunter
anddracula
programs into the “game arena” - start the game engine, invoke the AIs to determine moves, record game progress
- move the
- we update tournament tables that show whose AI is performing best
Note that each game uses one ./hunter
from one group to play all four hunter roles (i.e. the same AI will be used to play Lord Godalming, Dr. Seward, Van Helsing, and Mina Harker). Also, we will ensure that your hunter AI always plays against a Dracula AI from another group.
Since the marks are based on performance in the Hunts, it’s in your best interest to submit working AIs as soon as possible. Even submitting an AI that simply moves to a random reachable location is worth something (not much admittedly, but better than zero, which is what no AI or a non-functioning AI will score). You can submit as many times as you like; the most recent submission will be chosen for each Hunt.
Submission
You should submit your Makefile
, along with all of the .c
and .h
files that are needed to produce your players. This will include, at least:
Makefile
dracula.c
,hunter.c
DraculaView.c
,DraculaView.h
HunterView.c
,HunterView.h
GameView.c
,GameView.h
If you change Map.h
or Map.c
, you should also include those in your submission. Also include any other ADTs that you develop that are needed for your views or AIs.
You will need to set up your Makefile
to ensure that it includes all of the appropriate files in the dependencies and rules. If your Makefile
doesn’t work properly, your players won’t be included in the next tournament, even if all of the code is correct.
All submissions are made on behalf of the group, no matter which member of the group makes the submission. If several group members make submissions, only the most recent submission will be used.
Dryrun
When you submit, a dryrun test is run to check that you've submitted sufficient files to at least compile the players. It does the following:
- Checks that you've submitted all the compulsory files
- Checks that you haven't submitted any files you shouldn't have submitted
- Brings in these files from our end: Game.h, Places.c, Places.h, dracula.h, hunter.h
- Brings in these files from our end if you haven't submitted them: Map.c, Map.h
- Tries to compile your program and produce dracula and hunter
If any of these steps fail, the dryrun fails and you will be asked to fix your code or check that you are submitting the right files.
The dryrun tests will delay your submission by a couple of seconds (or minutes if you have errors in your files and need to fix them). It is your responsibility to ensure that your submission occurs on time.
You are also able to run the dryrun tests independently. To do this, run the following command:
sh /web/cs2521/20T2/ass/ass2/hunt/dryrun/dryrun.sh files-to-be-submitted...
Note that running the dryrun itself does not submit your files. You still need to submit them via give cs2521.
Assessment
This part of the assignment is worth 6 marks, determined as follows. There are 3 marks for your Dracula AI and 3 marks for your Hunter AI. Each AI is assessed as follows:
- Tournament Participation (2 marks)
Each time your AI enters a tournament (i.e. is submitted) and compiles and plays all games without crashing, it is given 0.5 marks. These marks accumulate over multiple tournaments, so successfully playing in 4 tournaments like this gives you the 2 marks. There is no bonus for entering more times. AIs that compile, but crash in the majority of their games score 0.1 marks for that tournament. AIs that compile, and successfully play half their games, and crash in the others score 0.3 marks. AIs that don't compile don't score marks (use dryrun to check your AI before it enters a tournament).
- Performance (1 marks)
This mark is based on the ranking in the final tournament. The top 10 AIs in each pool (Draculas, Hunters) score 1 mark, the next 20 score 0.8 marks, the next 20 after them score 0.6 marks. Any lower AI that has a non-zero score from the tournament scores 0.5.