Hello again, a little update to my previous post on claiming stash on TerraCore.
<p dir="auto">Rather than claim every 4 hours I thought I'd try pulling the leader board statistics and claiming when I reach the 'danger zone' of being attacked, this gives me flexibility to increase or decrease my mining rate (engineering) by switching gear. <p dir="auto">Of course I'm using ChatGPT again, other than fiddling with a few values and variables it's all AI coded! Boy I wish I'd explored this concept sooner! 🤣 <p dir="auto">Basically the script pulls data using HTTP API in JSON format, parses it, displays some info on screen and triggers the previous function to claim. <p dir="auto">One other change, rather than set active key using 'set' from command line I've used Windows environment variables as for some reason the data would get lost, causing errors and exiting the script! 😭 <p dir="auto"><img src="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/frugal-fun/23t76brxPBZxLh7bKzqQGNoLcZEVCEmnhZamgyMp8yezSWesHe3kfkm3VqZmsLq52GqQ4.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://files.peakd.com/file/peakd-hive/frugal-fun/23t76brxPBZxLh7bKzqQGNoLcZEVCEmnhZamgyMp8yezSWesHe3kfkm3VqZmsLq52GqQ4.png 1x, https://images.hive.blog/1536x0/https://files.peakd.com/file/peakd-hive/frugal-fun/23t76brxPBZxLh7bKzqQGNoLcZEVCEmnhZamgyMp8yezSWesHe3kfkm3VqZmsLq52GqQ4.png 2x" /> <p dir="auto">Code as follows: <div> <pre><p dir="auto">const myusername = 'hive_username';<br /> const amountToClaim = 100; <p dir="auto"><span>const client = new Client('<a href="https://api.hive.blog" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://api.hive.blog'); <p dir="auto">function clearConsole() {<br /> // Clear console<br /> console.clear(); <p dir="auto">// Print current timestamp<br /> console.log(<code>Timestamp: ${new Date().toLocaleString()}\n);<br /> } <p dir="auto">async function claim(player, amount) {<br /> const privateKey = PrivateKey.fromString(process.env.ACTIVE_KEY);<br /> const publicKey = privateKey.createPublic(); <p dir="auto">const op = [<br /> 'custom_json',<br /> {<br /> required_auths: [],<br /> required_posting_auths: [player.username],<br /> id: 'terracore_claim',<br /> json: JSON.stringify({ amount, 'tx-hash': generateHash() })<br /> }<br /> ]; <p dir="auto">const result = await client.broadcast.sendOperations([op], privateKey, [publicKey]);<br /> console.log('Transaction broadcasted:', result);<br /> } <p dir="auto">function generateHash() {<br /> return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);<br /> } <p dir="auto">function displayLeaderboard() {<br /> clearConsole(); <p dir="auto"><br /> .then(response => {<br /> const players = response.data;<br /> const myusernamePlayer = players.find(player => player.username === myusername);<span>axios.get('<a href="http://terracore.herokuapp.com/leaderboard" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">http://terracore.herokuapp.com/leaderboard') <pre><code> if (!myusernamePlayer) { console.log(`Could not find ${myusername} in the leaderboard.`); return; } const filteredPlayers = players.filter(player => { return player.stats.defense <= myusernamePlayer.stats.defense && player.scrap > myusernamePlayer.scrap; }); const sortedPlayers = filteredPlayers.sort((a, b) => b.scrap - a.scrap); const top10Players = sortedPlayers.slice(0, 10); console.log(`${myusername}:`); console.table({ Player: myusernamePlayer.username, 'Stats Engineering': myusernamePlayer.stats.engineering, 'Stats Defense': myusernamePlayer.stats.defense, Scrap: myusernamePlayer.scrap, Claims: myusernamePlayer.claims, Attacks: myusernamePlayer.attacks }); console.log(''); console.log('Top 10 players with defense equal to or lower than ' + myusername + ' and higher scrap:'); console.table(top10Players.map(player => ({ Player: player.username, 'Stats Engineering': player.stats.engineering, 'Stats Defense': player.stats.defense, Scrap: player.scrap }))); console.log('\nTotal players matching the criteria: ' + filteredPlayers.length); // Run claim function if claims is greater than 0 and total count is less than 8 if (myusernamePlayer.claims > 0 && filteredPlayers.length < 8) { claim(myusernamePlayer, amountToClaim) .then(() => { console.log(`Successfully claimed ${amountToClaim} rewards.`); }) .catch(error => { console.error('Error claiming rewards:', error); }); } }) .catch(error => { console.error('Error retrieving leaderboard:', error); }); <p dir="auto">} <p dir="auto">// Display leaderboard initially<br /> displayLeaderboard(); <p dir="auto">// Set interval to refresh leaderboard every 30 seconds<br /> setInterval(displayLeaderboard, 30000); <span> const axios = require('axios'); const { Client, PrivateKey } = require('<a href="/@hiveio">@hiveio/dhive'); const { exec } = require('child_process'); <p dir="auto">It's been great fun working with ChatGPT on this, highly recommend people give it a try, not just coding, ask it anything! <p dir="auto">I really want to try building my own AI, there are plenty of open source resources but it looks like I would need a decent graphics card which is expensive and there are too many things I want to spend money on 🤑🤣🤓 <p dir="auto">Again, I hope this helps someone. <p dir="auto">Next up I want to script Boss fights which should be fun too as there are no examples of code! (not that I've looked that hard yet) <p dir="auto">Till next time,<br /> Stay FrugalUpdate to TerraCore claim
last year in #blog by frugal-fun (57)
$1.67
- Past Payouts $1.67
- - Author $0.84
- - Curators $0.83
25 votes
- sbi2: $1.26
- terraboost: $0.18
- leosoph: $0.17
- bobaphet: $0.02
- sbi-tokens: $0.01
- splinterboost: $0.01
- surrealis: $0.00
- thedailysneak: $0.00
- sneakyninja: $0.00
- terracore: $0.00
- cryptoknight12: $0.00
- mastergerund: $0.00
- meltysquid: $0.00
- babysavage: $0.00
- yozen: $0.00
- scraptrader: $0.00
- danideuder: $0.00
- wahlterwhite: $0.00
- ravensavage: $0.00
- sketching: $0.00
- and 5 more
My previous @v4vapp proposal has expired. I have a new one which is running but unfunded right now. I'm still running @v4vapp and all my other services.
I've just updated v4v.app and I'm getting ready for some exciting new features after the next hard fork.
Please consider asking your friends to vote for prop #265 or consider unvoting the return vote.
For understandable reasons in the current crypto climate it is harder to get funded by the DHF, I accept this so I'm asking a wider audience for help again. I'll also add that I power up Hive every day and usually power up larger amounts on 1st of the Month. I'm on Hive for ideological reasons much more than for only economic benefit.
Additionally you can also help with a vote for Brianoflondon's Witness using KeyChain or HiveSigner
If you have used v4v.app I'd really like to hear your feedback, and if you haven't I'd be happy to hear why or whether there are other things you want it to do.
Interesting. I tried using this AI (https://huggingface.co/chat/) to write some Blender python scripts for me (I have 0 codding skills). But it soon started to get confused and spit out some totally unrelated nonsense so I gave up. Maybe I will have another go with chatgpt or something else.
Yes, I found ChatGPT also sometimes went down a funny path, responding with 'sorry, I meant xyz' usually resolved the issue.
Definitely keep trying bud.
I'm going to try GPT Engineer soon, also from HuggingFace
Wow that GPT Engineer thing looks amazing. I won't get any of my work done if I jump into that rabbit hole now :D
Congratulations @frugal-fun! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)
<table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@frugal-fun/upvoted.png?202306230019" /><td>You received more than 1250 upvotes.<br />Your next target is to reach 1500 upvotes. <p dir="auto"><sub><em>You can view your badges on <a href="https://hivebuzz.me/@frugal-fun" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">your board and compare yourself to others in the <a href="https://hivebuzz.me/ranking" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Ranking<br /> <sub><em>If you no longer want to receive notifications, reply to this comment with the word <code>STOP