Dating game architecture for the Heuristic Problem Solving course at NYU (Fall 2016)
The architect.py file is the main entry point for starting the game. Execute the following in a shell to start it.
python architect.py <PORT-NO>Change the variable ATTRIBUTES to inside architect.py file to change the number of attributes each candidate can have.
The test scripts can be executed by
python test_person.py <PORT-NO>
python test_matchmaker.py <PORT-NO>- The architect communicates the number of attributs (
n) to Person (P) via socket. - P responds with a vector
w, of lengthnwhose positive components sum to1and negative components sum to-1and sends it to the architect who verifies it. P also sends 2 binary arrays indicating the ideal and anti-ideal candidate which are also verified. - The architect communicates
nvia socket to Matchmacker (M). - The architect computes the dot product of the
s_i = (w.x_i)for1 <= i <= 20wherex_iis a binary random vector. He sends all 20s_iandx_ito M. - For 20 turns
- M guesses some
x, such that all components ofxare between0and1. - Architect computes
s = w.x, and storess. It then sendsxto P. - P modifies
w, while not deviating more than 20% from the initial value ofwand changing only 5% of the weights. - Architect sends
sto M and requests for a newx. The architect records the best scores, and if it was ever 1, it records the number of turns taken.
TCP/IP communication is not guaranteed to be atomic. To resolve this issue we have fixed the message length of every message
over the socket, so that every read call is guaranteed to contain the entire message sent. We use , to seperate values
and \n to denote end of a message.
- At the start receives exactly 4 characters. The last character is
\nand the first 3 characters are digits which denoten, the number of attributes. For example
056\n
- The architect then expects a response containing exactly,
6ncharacters, denoting the initial set of weights. Each component of the weight vector should contain, a +/- sign, followed by one digit before the decimal and 2 digits after the decimal. If you are not using any digits, you should set them to0. Components are separated by,and\ndenotes the end of the message. For example, forn=5.
+0.20,+0.80,-0.68,-0.00,-0.32\n
You can use the dating/utils.py:floats_to_msg2 function to do so.
3. The atchitech then expects the ideal and anti-ideal candidates, with the ideal candidate expected first. Each candidate
is exactly 2n characters of binary digits. For example
0,1,1,0,0\n
- Subsequently the Person will receive 20 guesses made by Matchmaker over time, each of which will contain
8ncharacters. Each component will have a +/- sign, followed by one digit before the decimal and 4 digits after the decimal. For example
+0.2303,+0.8095,+0.1366,+0.9295,+0.4915\n
- For each of the 20 candidate proposed by the matchmaker, the person has to reply with modified weights with 20% of the
original weights from step 2 and only 5% of them changed. Once again, the weights should be communicated by exactly
6ncharacters.
- Same as person, receives n, via exactly 4 characters.
- Immediately after that, M receives 20 binary vectors along with their scores. Each (score, vector) tuple is exactly
(2n + 8) characters long. The first 8 characters are the score, followed by a
:, followed by a comma separated binary vector. For example
+0.9900:1,1,0,0,1\n
- M is expected to give an estimate of weights during each of the 20 iterations. The architect expects a message of exactly
8ncharacters, where each component contains one digit before the decimal and 4 digits after the decimal. For example
+0.3038,+0.1525,+0.9334,+0.6368,+0.4921\n
See function dating/utils.py:floats_to_msg4
4. After sending an estimate, M will receive a score, of exactly 8 characters. For example
+0.1356\n
Compress all your files into a single zip archive called teamname.zip. Make sure it has 2 bash files teamname_player.sh and
teamname_matchmaker.sh. Please load all your modules you need in your bash files. The bash files will be called as follows
bash teamname_player.sh <PORT-NO>
bash teamname_matchmaker.sh <PORT-NO>Send all your submissions to vnb222@nyu.edu