The program below presents a simulated barter session for a computer game implemented in JavaScript. To see the source code, visit http://thiscouldbebetter.wordpress.com/2013/08/23/a-barter-session-engine-for-a-game/.

To make a trade, use the buttons labeled with "<" and ">" to move items from each trader's "Held" list into their "Offered" list, and then click the "Trade" button to propose a trade. The total value of each offered set of goods is not presented anywhere in the interface yet, but each "Red Torus" is worth 1, each "Green Box" is worth 2, and each "Blue Sphere" is worth 5. Note that the trader represented on the bottom of the interface ("Merchant"), will not agree to trade at a loss.

It still needs some work. I'd eventually like to add a "Details" pane that shows information about the selected good, and of course something that calculates the total value of all the goods in an offer. On the plus side, the code happens to include an implementation of a simple user interface framework, more-or-less accidentally.