CS313 PROJECT1
AUTOMATED NEGOTIATION

You are to work in MIXED-background pairs.  This project should be ready
for progress-demonstration as noted below, and for final submission in
three weeks.

----------------------------------------------------------------------
revision revision revision revision revision revision revision revision
----------------------------------------------------------------------
TWO NOTES ON SPECS!  Thu Sep 23 01:45:50 CDT 2004
	i am now writing a players file every time i start
	the processes.  also the start time in systime() seconds.
	here is what it looks like:
% cat players
player1 = randomplayer
player2 = otherplayer
1096440178

	and i am also recommending that we write the systime()
	after the string-form of the date, so people can calculate
	elapsed seconds easily.  note also that the offers file
	will probably have an empty first line (from being created
	using echo).

% head offers

player1 prop 1 9	from randomplayer Thu Sep 23 01:54:10 CDT 2004	1095922450
player2 prop 1 1	from otherplayer Thu Sep 23 01:54:12 CDT 2004	1095922452
player1 prop 1 3	from randomplayer Thu Sep 23 01:54:13 CDT 2004	1095922453
player2 prop 1 10	from otherplayer Thu Sep 23 01:54:15 CDT 2004	1095922455
player1 prop 1 1	from randomplayer Thu Sep 23 01:54:16 CDT 2004	1095922456
player2 prop 1 3	from otherplayer Thu Sep 23 01:54:18 CDT 2004	1095922458
player1 prop 1 2	from randomplayer Thu Sep 23 01:54:19 CDT 2004	1095922459
player2 prop 1 4	from otherplayer Thu Sep 23 01:54:21 CDT 2004	1095922461
player1 prop 1 5	from randomplayer Thu Sep 23 01:54:22 CDT 2004	1095922462

I DO NOW terminate on the first offer made by one player that was
previously made by the other player (we no longer require an accept
act).

if you force twice, i take the latter one.  as soon as the other
party responds to a force, we quit.

at the end of a run, the result is written to the offers file.
----------------------------------------------------------------------
revision revision revision revision revision revision revision revision
----------------------------------------------------------------------

   September 2004
 S  M Tu  W Th  F  S
12 13 14 15 16 17 18
         ^assigned
19 20 21 22 23 24 25
         ^progress 1
26 27 28 29 30  1  2
         ^progress 2
   October 2004
 3  4  5  6  7  8  9
         ^final submission
10 11 12 13 14 15 16

You will be writing a program that takes input like this
from a file called "payoffs":

                player 1's payoffs
   (2)     1     2     3     4     5     6     7     8     9    10    11 
(1) 1:     15    19    15    23    30    26    37    60    59    53    58 
(1) 2:     12    24    17    38    56    43    46    66    42    75    85 
(1) 3:     15    30    25    34    42    51    53    60    68    55    81 
(1) 4:     15    31    38    37    42    58    59    58    66    81    79 
(1) 5:     34    38    42    59    50    46    64    85    64    88   100 
(1) 6:     36    37    49    53    63    74    76    66    90    86    89 
(1) 7:     48    44    49    56    52    64    72    62    68    77    87 
(1) 8:     43    53    34    60    77    83    62    72    91    92    88 
                player 2's payoffs
   (2)     1     2     3     4     5     6     7     8     9    10    11 
(1) 1:     75    65    82    60    60    81    50    44    45    40    32 
(1) 2:     83    62    71    66    44    68    45    52    49    23    23 
(1) 3:     85    64    56    71    48    58    42    38    31    38    21 
(1) 4:     74    67    59    45    54    44    41    22    28    21    29 
(1) 5:     74    55    52    63    32    47    45    16    25    15     9 
(1) 6:     72    53    53    32    43    41    31    22    26     6     5 
(1) 7:     52    42    39    38    31    34    22    16    18     1     3 
(1) 8:     43    54    30    34    35    18    16    10    11     3     0 

and which receives either a "1" or a "2" from stdin.

Here is another example of "payoffs".  You do not know in advance the
number of rows or columns, but you may assume each is less than 20.
You may assume they are positive integers less than 200.  You can expect
the payoffs to be somewhat ordered in row and column, and to produce a
conflict of objectives almost always.

		player 1's payoffs
   (2)     1     2     3     4     5 
(1) 1:      4    15    19    26    30 
(1) 2:     18    24    18    25    32 
(1) 3:     21    31    37    41    34 
(1) 4:     27    22    29    30    47 
(1) 5:     26    38    49    63    40 
(1) 6:     43    51    52    50    60 
(1) 7:     34    41    48    27    66 
(1) 8:     46    50    51    60    49 
(1) 9:     48    59    55    67    66 
(1)10:     60    50    51    71    65 
(1)11:     53    95    53    82    70 
		player 2's payoffs
   (2)     1     2     3     4     5 
(1) 1:     50    78    62    48    44 
(1) 2:     69    71    71    45    43 
(1) 3:     57    71    35    26    33 
(1) 4:     42    58    39    33    29 
(1) 5:     52    41    40    40    20 
(1) 6:     44    32    50    24    22 
(1) 7:     47    43    21    19    19 
(1) 8:     38    36    18    25    19 
(1) 9:     34    30    16    15     5 
(1)10:     23    24    19    12     8 
(1)11:     23    13    13     6     0 

Your program will continuously poll the file "offers" which contains
statements of the form:

player2 prop 1 1	from 192.165.145.247 Wed Sep 15 15:23:42 CDT 2004
player1 prop 11 5	from 192.165.145.247 Wed Sep 15 15:23:45 CDT 2004
player1 prop 11 4	from 192.165.145.247 Wed Sep 15 15:23:48 CDT 2004
player1 prop 11 2	from 192.165.145.247 Wed Sep 15 15:23:51 CDT 2004
player2 force . 1	from 192.165.145.247 Wed Sep 15 15:23:53 CDT 2004
player1 force 11 .	from 192.165.145.247 Wed Sep 15 15:23:56 CDT 2004

where this is the complete list of possibilities:

   "accept x y    accept the proposal <x,y> (x is the row)"
   "prop x y      make (or repeat) a proposal"
   "threaten . y  threaten breakdown with column y (player2 only)"
   "threaten x .  threaten breakdown with row x (player1 only)"
   "force . y     unilaterally breakdown (player2 only)"
   "force x .     unilaterally breakdown (player1 only)"

Once one player forces, the only player may only respond with a force.
If a player accepts a proposal that has been offered by the other side,
then the interaction ends with the payoffs according to that row and
column.  Similarly, when two force moves are recorded, the interaction
ends.  The record of your interaction is available as a log for any
program to see, in files called old.payoffs.xxxx and old.offers.xxxx
(the names of the programs will be in old.players.xxxx).

Your program may append to the file "offers" to make new offers.  

Programs can be expected to run for about five minutes, before and after
which time they might be unexpectedly terminated.  If they are terminated
in this way, they receive some unspecified (large) proportion of the lower
left payoffs.

Programs will be paired in a simulator, or will be interacting with a
human through a web interface, on repeated trials, with randomized
"payoffs" files.

Students who are able to generate interesting negotiating behavior, and
who are able consistently to secure for themselves good payoffs will
receive the high marks on this project.

Your programs should be "turned in" by placing a subdirectory on
k9.cs.wustl.edu in the cs313 account "04-01" directory, with your last
names in lower case.  Your program should be called "neg", and should be
able to read and write the files "payoffs" and "offers" (and "old.*") in
their PARENT directory, or should be able to read "payoffs" and "offers"
from symbolic links in your subdirectory, which link to the parent
directory.

For example,

	cd ~cs160/04-01
	mkdir loui-moore
	cd loui-moore
	ln -s ../payoffs
	ln -s ../offers
	vi neg (copy in the program, <ESC>, :wq)
	chmod a+rx neg
	ls
		my auxiliary files, including source files
		neg*
		payoffs (a link to ../payoffs)
		offers (a link to ../offers)

For the first week, all we need is some kind of behavior that is well-formed,
even if it is not very intelligent behavior.

Don't forget that you need an html file describing your work when you do
the final submission.