Hacker News new | ask | show | jobs
by gus_massa 3337 days ago
Is this code equivalent to the current code?

IUUC the current code accumulate the payment to each pixel and whatever color has more accumulated money is chosen.

IIUC your code only consider the last payment and to replace the old color you have to outbid it, without any consideration of the previous payments.

Another strategies:

Penny auction: Whatever color received the last payment is the chosen one. This is more similar to /r/place

Generals.io: If someone adds money to the current color, then increase the accumulated money in that color. If someone adds money to another color the amount is discounted. Unless the result is negative and the color changes.

1 comments

It's not equivalent to what OP made, the logic is slightly different. It took 5 minutes and it was just to demonstrate how easy it would be to make something similar. If you wanted to mirror OP you could build out the pixel struct to have a color to value mapping.

The penny auction one is even easier:

  bytes3[10000][10000] board;
  function colorPixel(uint x, uint y, bytes3 color) onBoard(x, y) { 
    board[x][y] = color;
  }
Users would only have to pay the gas cost of using the ethereum network, the contract wouldn't hold any funds itself. Again, it's pretty much whatever you make out of it. You're not really constrained when it comes to building in logic into these contracts, anything (logically) you can do with any other languages is possible here.