Come-from-Beyond (OP)
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
November 25, 2013, 06:01:20 PM Last edit: December 06, 2013, 10:08:38 PM by Come-from-Beyond |
|
1st Nxt Slot MachineHow it works:1. Send from 10 to 1000 NXT to [DELETED]2. Wait for 1 confirmation 3. Look at the last 3 digits of the block id that confirmed the bet 4. If 2 of these digits are the same then you get 3x amount back. If all 3 digits are the same then you get 10x! If you lose you'll get 1 NXT. Winnings are paid from [DELETED] every 2 minutes. House can run out of money, so before making a bet check that http://88.198.210.245:7876/?request=getBalance&account=3994117300242888518 shows at least "1000000" in "unconfirmedBalance"!DISABLED
|
|
|
|
kylie.v
|
|
November 25, 2013, 06:20:16 PM |
|
Tried it oute
Sent about 12 transactions ..no luck :/
|
█ █ ██ ███ ███ ████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ ███ ███ ██ █ ██ █ ██ ███ ███ ████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ ███ ███ ██ █ █
|
|
|
Come-from-Beyond (OP)
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
November 25, 2013, 06:21:09 PM |
|
Tried it oute
Sent about 12 transactions ..no luck :/
As the 1st player u get all ur coins back. I'll send them in a min.
|
|
|
|
kylie.v
|
|
November 25, 2013, 06:25:29 PM |
|
Thank you still willing to test my luck
|
█ █ ██ ███ ███ ████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ ███ ███ ██ █ ██ █ ██ ███ ███ ████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ ███ ███ ██ █ █
|
|
|
klee
Legendary
Offline
Activity: 1498
Merit: 1000
|
|
November 25, 2013, 06:35:42 PM |
|
Nice to have something to gamble with Nxt! I wil try it
|
|
|
|
eid
|
|
November 25, 2013, 06:46:37 PM |
|
House can run out of money......
ROFL, good one.
|
|
|
|
Come-from-Beyond (OP)
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
November 25, 2013, 08:00:08 PM |
|
but i am facing the same problem here, you can't put workload on this, as soon you do, the client freeze.
What do u mean "the same"? I see nothing about API problems in this thread. Check that u work with 0.2.7 version.
|
|
|
|
Come-from-Beyond (OP)
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
November 25, 2013, 08:34:35 PM |
|
same in context to freeze. don't know how often i restarted a freezed client the last 24h.
test it yourself, traverse (getBlock) from genesis block (2680262203532249785) up to the current one on your local machine and see what happen. just one connection with 1.000 repetitive request and your node is gone. this workload is normally nothing and every node should handle this easily.
My gambling service doesn't store any data. Every 2 minutes it scans the whole blockchain and sends winnings. It even sets deadline to 1 minute, so usualy it take several times to send a transaction, coz it expires before confirmation. Make sure u use the recent version which is 0.2.9 ( https://dl.dropboxusercontent.com/u/67242472/Nxt.zip).
|
|
|
|
Come-from-Beyond (OP)
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
November 25, 2013, 08:46:04 PM |
|
For those who may be interested here is the source code of my Slot Machine: // (c) 2013 Come-from-Beyond
import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.HashSet;
public final class Tri { public static void main(String[] args) { while (true) { System.out.println("Time = " + System.currentTimeMillis()); try { Thread.sleep(120000); } catch (final Exception e) { return; } try { final ArrayList<Bet> bets = new ArrayList<>(); final HashSet<String> payments = new HashSet<>(); String block = "2680262203532249785"; // This is the genesis block id while (true) { String blockData = sendRequest("getBlock&block=" + block); int i = blockData.indexOf("\"transactions\":["); String transactions = blockData.substring(i + 16, blockData.indexOf("]", i)); while (transactions.length() > 0) { final String transaction = transactions.substring(1, transactions.indexOf("\"", 1)); final String transactionData = sendRequest("getTransaction&transaction=" + transaction); // Beginning of the game logic i = transactionData.indexOf("\"sender\":\""); final String sender = transactionData.substring(i + 10, transactionData.indexOf("\"", i + 10)); i = transactionData.indexOf("\"recipient\":\""); final String recipient = transactionData.substring(i + 13, transactionData.indexOf("\"", i + 13)); if (recipient.equals("4427320429393039971")) { i = transactionData.indexOf("\"amount\":"); final int amount = Integer.parseInt(transactionData.substring(i + 9, transactionData.indexOf(",", i + 9))); if (amount >= 10 && amount <= 1000) { bets.add(new Bet(block, transaction, amount, sender)); } } else if (sender.equals("3994117300242888518")) { i = transactionData.indexOf("\"referencedTransaction\":\""); final String referencedTransaction = transactionData.substring(i + 25, transactionData.indexOf("\"", i + 25)); payments.add(referencedTransaction); } // End of the game logic if (transaction.length() + 3 > transactions.length()) { break; } transactions = transactions.substring(transaction.length() + 3); } i = blockData.indexOf("\"nextBlock\":\""); if (i < 0) { break; } block = blockData.substring(i + 13, blockData.indexOf("\"", i + 13)); } // Beginning of the game logic for (final Bet bet : bets) { if (!payments.contains(bet.transaction)) { final String request = "sendMoney&secretPhrase=REMOVED&recipient=" + bet.sender + "&amount=" + getAmount(bet) + "&fee=1&deadline=1&referencedTransaction=" + bet.transaction; System.out.println(request); System.out.println(sendRequest(request)); } } // End of the game logic } catch (final Exception e) { System.out.println(e.toString()); } } } public static int getAmount(final Bet bet) { final String digits = bet.block.substring(bet.block.length() - 3); final int digit0 = Integer.parseInt("" + digits.charAt(0)); final int digit1 = Integer.parseInt("" + digits.charAt(1)); final int digit2 = Integer.parseInt("" + digits.charAt(2)); if (digit0 == digit1 && digit0 == digit2) { return bet.amount * 10; } if (digit0 == digit1 || digit0 == digit2 || digit1 == digit2) { return bet.amount * 3; } return 1; } public static String sendRequest(final String request) throws Exception { final HttpURLConnection connection = (HttpURLConnection)(new URL("http://localhost:7876/?request=" + request)).openConnection(); final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); final String response = reader.readLine(); reader.close(); connection.disconnect(); return response; } public static final class Bet { final String block; final String transaction; final int amount; final String sender; public Bet(final String block, final String transaction, final int amount, final String sender) { this.block = block; this.transaction = transaction; this.amount = amount; this.sender = sender; } } }
It uses only Nxt blockchain, no need to store anything locally. Pay attention that it uses "referencedTransaction". If a betting transaction cancelled due to blockchain reorganization, then the transaction that pays winning will be cancelled as well.
|
|
|
|
nexern
|
|
November 25, 2013, 09:08:02 PM |
|
thanks for sharing.
looks like i am to many hours in front of my computer. my previous post was for the nxt main thread, not for your game thread. have to reduce my browser-tabs.
from your source (i am not a java coder) i can see you are parsing the blockchain file directly? are there any specs about the internal storage format?
|
|
|
|
Come-from-Beyond (OP)
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
November 25, 2013, 09:09:42 PM |
|
thanks for sharing.
looks like i am to many hours in front of my computer. my previous post was for the nxt main thread, not for your game thread. have to reduce my browser-tabs.
from your source (i am not a java coder) i can see you are parsing the blockchain file directly? are there any specs about the internal storage format?
No, I don't parse the file. I use HTTP API and get JSON data back. Then I just parse JSON by myself, without a JSON library.
|
|
|
|
nexern
|
|
November 25, 2013, 09:17:23 PM |
|
ok, thanks, will update to 0.2.9 and test again.
|
|
|
|
bahamapascal
|
|
November 25, 2013, 09:51:48 PM |
|
Hmmm, send 12 nxt, but did not even get one singel nxt back
|
|
|
|
Come-from-Beyond (OP)
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
November 25, 2013, 09:58:41 PM |
|
Hmmm, send 12 nxt, but did not even get one singel nxt back
Ur bet lost, my script is trying to send 1 NXT but it's connected only to a few nodes and mining nodes don't see it. This is a great possibility to investigate what happens, so I don't restart the client. Eventually u'll get this coin anyway.
|
|
|
|
bahamapascal
|
|
November 25, 2013, 10:15:09 PM |
|
Hmmm, send 12 nxt, but did not even get one singel nxt back
Ur bet lost, my script is trying to send 1 NXT but it's connected only to a few nodes and mining nodes don't see it. This is a great possibility to investigate what happens, so I don't restart the client. Eventually u'll get this coin anyway. OK, cool....I don´t worry about the loss, just wantet to let you know
|
|
|
|
Come-from-Beyond (OP)
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
November 25, 2013, 10:44:15 PM |
|
I will leave the script working for the night. If it crashes I'll launch it next morning and u'll get ur winnings. U can easily check if u won by looking at the last 3 digits of the block id.
|
|
|
|
dr_yan_yan
Member
Offline
Activity: 98
Merit: 10
|
|
November 27, 2013, 11:23:39 AM |
|
well atleast the 1 coin comes back if you lose.
|
|
|
|
dr_yan_yan
Member
Offline
Activity: 98
Merit: 10
|
|
November 27, 2013, 11:31:20 AM |
|
and, i lost many. BUT then i sent a 10, it had a 99 in there, and it paid me 30.
So the scrypt works. But I am not quite sure about the chances of winning.
|
|
|
|
Come-from-Beyond (OP)
Legendary
Offline
Activity: 2142
Merit: 1010
Newbie
|
|
November 27, 2013, 11:39:43 AM |
|
and, i lost many. BUT then i sent a 10, it had a 99 in there, and it paid me 30.
So the scrypt works. But I am not quite sure about the chances of winning.
Chance is 28% (27% for 3x and 1% for 10x)
|
|
|
|
dr_yan_yan
Member
Offline
Activity: 98
Merit: 10
|
|
November 27, 2013, 11:42:09 AM |
|
Lose 410... to win 30 hehe gambling sure sucks!
|
|
|
|
|