Dark Forest: Beginner’s introduction to creating plugins in javascript
EthStaker Workshops and Technical Guides · January 2021 · 1:28:06
This EthStaker workshop gives beginners an introduction to creating plugins in JavaScript for Dark Forest, a zero-knowledge space strategy game built on Ethereum. The session places plugin development within the broader onchain games landscape where players extend gameplay through code.
Speakers
Topics
From EthStaker Workshops and Technical Guides, hosted by Eth Staker.
Transcript
05:20 - Introductions / Overview
uh one second you call yourself co-founder of prismatic when i introduce you yeah thanks that would be great okay and you can go ahead whenever you want we are recording now all right um correct yep okay because uh hey everybody uh i'm super fizz i'm um from the east acre community and i am here with two of my friends today uh first uh michael geeson who you know is
embedica he's gonna provide our dev support today and we have preston van loon who is a co-founder of prismatic labs the kind of thing we all have in common is we are part of the ethereum beacon chain or what you call eth2 the staking community and so preston has is has been spent in the past couple years developing uh with his team prismatic our prism client um and michael and i uh kind of run the or what we support the east acre community at reddit.comr easttaker and discord invite dot gg stinger and
the reason we're here today is because we share an obsession we have been hooked on dark forest uh the uh let me view my we've been hooked on dark forest this wildly awesome game and so what we want to do today is kind of give you just a really brief intro to the game but more than that we want to dive into this neat feature that was released a couple weeks ago that is javascript plugins for the game which basically allow you to script the game and so i don't want to do all the talk hey so preston do you want to tell us can we talk a little about what is dark
forest yeah so dark forest is this um online it's like a web web-based game powered by ethereum that's running on on the xdi uh staging network um but the cool part about it is that it's kind of like a you know it's a space exploration game um where there's this kind of fog of war um and it's all discovered or everything is uh found through using zero knowledge proofs um so it's kind of like no one really knows
what is out there until you go prove that it's there so it's kind of a really unique game uh very different from anything else i played and it's it's strangely extremely addicting so it's it's really fun game i'm excited to talk about it yeah and so i'm not a gamer um i i find that if i if i push myself i can play a game i did play uh that big um nintendo switch game what's that one called uh but the point is i'm not a gamer but playing this for like 15 minutes i have just been completely obsessed
with it and i am at the point where i am skipping responsibility and avoiding life just so i can play so that tells me you know it's got great value to it [Music] so yeah you have the basics of the game and right now they're they're still in alpha and they just released um so they're opening up this version five alpha for public play they're gonna drop three thousand keys um here in the next few days and i guess this weekend which is now and part of that goes along with a plugins contest and so there's a link for the plugins the best place i should encourage you to
get started is on their discord they opened up a discord about two weeks ago and uh the discord is really hopping if you look at the pinned post under plugins you'll find a bunch of information but there's a new blog post today that describes a contest where the community can create plug-ins and earn dive rewards uh that's ex like die as in dollar rewards for uh creating the best plugins from the player perspective like when you start playing dark forest you start clicking on your planets and you start doing things but the moment uh are you will you be doing a screen share is that okay is that yeah i can start too but i know it's
going to be it's going to come up at some point um let me i just want to show real quick um when you discover this plug-in tool up here you open up a plug-in library and you can see now what i already have installed and these are really easy to run plug-ins they're open source so basically you find them on the internet and the place to find them right now so right now the best public repository is plugins.zkga.com and i'll tell you a lot of people are
29:00 - Overall Dark Forest Gameplay Explanation
also writing these privately and using them for their own benefits and so what what i'm what we're hoping to do today is to bridge that gap for new users to kind of give you even give me because i'm curious a foot in the door to begin creating plug-ins and so most of my jabber is over i want to hand it over to preston to see kind of what you can help us figure out about how to use these plugins yeah let me share my screen and we can start talking about it and what i want to do so i've got the
screen just loaded here from this is what you do when you log in so it's zk dot ga dot me so it's zero mileage game basically and again it's an online web-based game and it's multiplayer and it's all running on ethereum on the xdi staging network and it's super cool so let's dive in are you sharing yet because i'm i'm having trouble finding it if you are oh you're not seeing it um well my share window still seems to be up it could be my fault my flaws michael whose share stream do you see do
you see one yeah i'm seeing uh uh preston's i believe yeah okay so i need to figure out what i'm doing wrong okay well i'll keep going then uh okay yeah so once you enter the game you're you're greeted with this prompt and if it's your first time it'll i think it'll ask you to maybe create an account i already have one so i'm gonna choose option a and this is account one um to join this game you have to have an invite key or token i've already been
whitelisted so i've already had that key entered so now what it's doing is downloading all the information for this game from the x5 staging network and it takes a little while because it is a pretty big universe already so it's just loading now anyway so i got my i was on the mailing list for this game because i played in an earlier round i think i played in uh
version 0.2 maybe uh earlier this earlier last year probably six months ago and even then it was a really fun game but since then they've added things like plug-ins and now it's on x-tie network so it's much faster than running on rigby or robstein or whatever it was and i got my invite team through the mailing list i got it on saturday and that weekend i just started hacking together uh plugins and sort of messing around because there was uh a prize if you're in the top 15 and i
really wanted to be in the top 15. so i started hacking around have you tried running the x die chain locally i did yeah i did so i ran into a few problems um on my on my laptops i used a think pad for for work with my work laptop and it's just like uh just a lot of times trashed basically because i've i've just been like basically grinding it to into the ground building e2 and doing all these things and then now when you're trying to do all these zero knowledge proofs and and confirm these transactions
uh it takes a toll on on the cpu and especially when you're using like a shared um x die node everyone who was using it it was i was finding that my transactions were timing out so i used a second computer i have this other this really old gaming machine that i had and i set up my exercise server on that and i was connecting to that on my local wi-fi and that really helped um with my transactions getting through yeah i was very impressed with that performance boost sorry it was off topic from plugins but just a curiosity yeah it's not a requirement but it it if you're finding that your transactions are failing to go through
or timing out it might be a good idea to run your own and if you're just interested in that it's a fun thing to do all right so let's take a look at my game i did make it into the top 15. i got 10th place so that was really cool what you have here is you have this giant universe this big circle where as a new player you're going to randomly pick your home planet and hopefully you're not near a bunch of you know power players and throughout the game you're exploring each little block using your um
you're like like a minor so it's actually looking at a piece of the universe and then running through the zero orange proof and then putting the data onto your onto your map and the objective of this game or at least what it was for for the contest was to to get a high score and the way the scoring works is they take your top ten planets they take the score of your top 10 planets all the points and they add those up and they also take the your silver score or how much silver you own and how much silver you spent and they
take 30 of that and they attacked under your to your score your total score so next question is like what is silver so silver is well first of all you have planets right so when you start with your home planet you're probably going to get a small planet uh like this one for example okay so i have this planet um this one is rank one or rate zero so it's it's one of the lower level planets and what i can do here is i can send my planet's energy to basically conquer another planet
um so i just dragged that along from one planet to another you can see over here it's doing that move calculating the zero knowledge things it needs to do the witness and the proof and then it's going to send that transaction out to the x by network and then we'll see the energy move very slowly along this line so okay so just went through this wall and you'll see that that line will turn solid yeah that line turns solid as soon as the confirmation or the transaction is confirmed exactly so now you can see this is going through the energy or like the forces if you want to call in that
are traveling through space to come onto this new planet called collapse search and it's unclaimed not claimed by myself or any other player and now if i only had this one planet and now i'm about to have a second one that's going to increase my top 10 score and so on so we the goal here is to capture these high value planets they have different ranks the ranking and more importantly the energy capacity is what influences the score of a planet all right in 10 seconds it's going to reach and then i will
have claimed this rank 0 and it's worth noting in real gameplay some of those transfers of power can take several hours moving across great distances so a lot of waiting yep yeah it's a very slow moving game it almost feels like a turn-based game except that you know everyone's kind of on their own timeline um so you can you can check on this every once in a while it's not like uh a fast action game or if you like went to go get a cup of coffee you came back and someone's taken all your planets you'll have lots of time to for you know real life activities like work and
eating and stuff like that so this next aspect of the game is this uh these asteroid or or yeah these are asteroid fields and asteroid fields generate silver so you can see here we have silver this is the silver mine you use the silver now to then upgrade your planets so if your planet is i think rank two or higher or rank one or higher you can use silver to buy upgrades to taking a look at an upgrade i can
upgrade the defense of this planet make it harder for other players to capture i can increase its range which is how far the energy will will go uh and then and then the speed of the energy traveling throughout the universe and then and then again when i spin the silver it it still counts towards my silver and the silver score again is 30 30 of that increases my total score so with my silver mine or my asteroid belt i can send let's try to send some silver to this planet and then we could then upgrade it once that gets
there so this is just like we did to capture this planet but this time we're also sending uh silver which is represented by this yellow or or gold text at the top of the asteroid field okay so it's submitted the transaction to x die and then it it confirms very quickly there it goes so now the map will update probably there it goes okay so now we see this move is happening and it's going to take over five minutes
and it's sending silver and it's sending energy and it's going to my own planet so it's going to increase this planet's silver capacity and once it gets there we're not going to wait for it just right now but once it gets there i would have the 62 silver i need to buy the first upgrade and i think you can upgrade these three or four times it makes your plan a stronger increases the energy and then of course increases whatever attribute we selected defense range or speed and so what you're ultimately doing is you're expanding your reach so i have all these white planets here
purple and other colors represent my neighbors and you can see this is a neighbor sending some long range look at that one four thousand seconds of long-range attacks they're they're capturing this unclaimed planet here this unclean planet has uh pirates on it you need to send uh you need to have your forces arrive with at least four to conquer this planet that has pirates on it and this one is particularly high defense so it has 800 defense and you can think of this as a percentage
so you need 800 percent of whatever energy is here so you need eight times four right so you're not just going to need four four units you're going to need um extra i didn't realize that i i want so i always send way too much but i didn't realize that that equation yeah exactly i mean that's a big part of deciding which planets you want planets here in in the uh this dark blue space have higher defense and your home planet is always going to be in this dark blue space these planets are much harder to capture so if you see one like this this looks like a rank 2 planet that's a good one
starting out because it's going to be harder for other players to take it so look at this one it has 1 800 percent defense so i would have to send a lot of energy to conquer that one it's basically going to be not even worth it or very difficult this guy doesn't have enough he needs 10 times that he's got to arrive with 80 000 energy pretty much which is funny because that's a level 3 rank 2 which is not a significant planet but it's nearly impossible to take so that's kind of neat yeah it's going to be harder to take than this giant one right here almost yeah this one only has 75 so you need less than this 150 000 energy
okay interesting so these red circles have just appeared um what it means is that i can see on my map that there is an attack coming from somewhere from someone to this planet and the origin planet that that attack is coming from i haven't discovered it in my fog of war so it's showing up as a red circle because i don't know who sent it or or where it's coming from and that's likely because we're live now and people are seeing your your game play is it possibly yes so it could be this purple guy here um mr
agent k could be trying to take this planet in real time right in front of us and he may have his planets up here in these un discovered blocks that might fargo wars or it could be this green guy sending sending energy to himself we don't know who sent the attack so it just shows up red because we don't know who it's coming from where it's coming from but we know it came from this it's currently this far away so it's likely that it's someone in these dark spaces over here that i have not uh uncovered my fog of war yet okay so
no it's worth pointing out that that's 2400 seconds away so it's going to take 40 minutes is that right 60 yeah something like 40 minutes for that red circle to zoom in on a planet that's the pace of the game yeah and some planets have this super long range like look at this one this one can go really far and if just that circle takes you know 40 minutes sending all the way down here to takes hours and it did i mean i had this is my my my best silver mine and it has the it has doubled the range so sometimes you find planets that have a stat that's randomly doubled and that's really good to have especially
this one it's it's a rank 6 asteroid field so range 7 is the highest you can get rank 6 is really great and it has a ton of energy and i'm able to fill i mean silver and i'm able to fill my big planets with silver increasing my silver score and also upgrading those planets so oh cool another thing we can look at here is you can uh you can buy these hats and put a hat on your planet it just looks cool um i think it costs one die the funds go to the development team or the prize pool or something like that so if you're a big fan of the game and you
want to support the developers buy a hat for your planet you have this little hat icon yeah so he's bought each level the the hat cost increases so the next one for this would be 32 die and i only have i don't have enough so i can't help out there but if if you're a big fan you have extra dye definitely consider supporting the team through the hats because it kind of gives a cool little novelty to your favorite something i'd like to add to that is um these these types of interactions are historically the types of interactions that if dark forest ever decided to reward
players in some way this is the kind of interaction that they would look for so basically if you support them now and i don't know anything i know no no back story about how this works but historically when players participate in this program like buying silly hats it's it increases the likelihood that if dark force says hey we want to give back to players with this token or this airdrop or whatever that that's the database they would use for that so just keep that in mind as you think hey it might actually benefit you in the long run to support them just my thought yeah definitely because this is a really fun game and and they're doing things like incentivizing
the plug-in contest and the top 15 players and just making it really really appealing um i think that if if there wasn't that prize i probably wouldn't have spent so much time on this um but it still it is a fun game i would have played it either way so i i started here somewhere and just kind of expanded my circle to be about this big which took a good part most of a week um and i didn't do it manually right i didn't go
like looking around and dragging that line everywhere on my laptop trackpad i wrote plugins to do everything to make everything to my life easier to find the best stuff to find the artifacts which we haven't talked about yet which are nfts that you can put onto your planets that boost some of the stats i automated all that through plugins the plugin functionality is amazing and i can't wait to see what comes out this plugin contest and i hope that by the end of this call you're able to start hacking away on plugins and kind of writing your own stuff
okay so let's take a look at artifacts real quick there's four levels of rarity you have legendary epic rare and common and this really just influences the power of the boost of those artifacts uh if i go click on one let's uh take a look at uh the tome of steve that sounds like a good one this one increases defense by 40 and lowers some of the other stats by 10 to 30 so we have energy energy growth the range and the speed so if
say for example someone was trying to take one of my favorite planets i might put this artifact on there to boost up the defense so it makes it harder for them to attack it conversely if i had one that boosted the energy i would want to put that on one of my top planets so that it boosted its score and if if we look at my soda undesirable my biggest planet it has an energy booster of 80 so this one's going to be really hard to take because you need 370 energy a thousand energy uh of course that's multiplied by just
76 78 so but you still need a lot and this this has ended up giving me a huge score boosting me into the top 10. artifacts are really cool to find they're really neat and then they're nfts so when this game goes live to midnight you can trade them on open market or or use them on your planet there's it's worth noting that the there are classes of artifacts so like statues idols um and those different classes have different relative attributes um and so some of them uh increase speed so tombs i know increase armor um
i i don't remember many off the top of my head but you can almost kind of guess what an artifact is going to do by looking at the type of artifact it is yeah that's a good point yeah there's these four classes of of artifacts and a little bit different stuff and there's also like regional stuff so it's like a forest type which is like a influencer on the stats and then then the the class which is like colossus or monolith or whatever okay so let's take a look at some of my that i've written and what they do
45:30 - Overview of Preston Van Loon's personal plugins
so most of mine are are entirely written by me or at least modified in some way from the plugin repository so everyone starts out with the readme which kind of just is is a demonstration of what the plugins can do we'll take a look at it a plugin pops up this dialog box and then you can just display information here and you can add buttons that do do stuff and i've also seen sliders and different different things so if i were to click this
uh it does a little confetti and it made me think that i was going to get a free artifact which is really cool but it was all a lie it doesn't give you an artifact it's uh yeah my game is really grinding really slow because there's so much information going on here and this is my laptop and we're on zoom so if you don't have a like a nice computer your game might be a little slow like mine is all right we don't have to wait for that let's dive into the next thing so quick upgrade this is one that it was based off of the was based off of the um open source
plug-in that's out there that you can basically upgrade all of your planets uh at once and for me it was getting to be too expensive because i had too many planets and a lot of planets i didn't care about anymore like some of the lower ranked ones so i modified this one to only upgrade rank four and above and i'm not much of a ui person so all my plugins are like super simple they kind of describe what it does and what it means to me so this is do i want to upgrade the planets and then i have a button to click that makes it happen so let's look at uh we'll look at how they work after i just want to show what
what i was using to get into the top 10 first so i had the one that would upgrade all the planets the first one i had written was this auto conquer which is basically looking for uh planets that i thought would be high value that is highly ranking planets plant uh asteroid fields that generated silver and then planets that had artifacts on them and then certain players that i didn't like so neighbors who tried to take my they ended up on my uh destroy list basically and then i would annihilate um which is fun part of the game like
it's it's multiplayer and there's there is sometimes huge wars that go on and it's it's exciting and it's fun and it's it's a little crazy so i've also seen some twitter truces where your neighbor you and your neighbor are both tagged on twitter and you're like hey um please don't hurt me and it's like hey okay let's be cool and let's go somewhere else so i guess it goes both ways yeah exactly when i was first starting uh i started getting into mr agent k's space here and my plug-in started attacking like this planet and i was on the discord and he says what why are you doing that i'm like it's a game yeah yeah i'm like oh dude it's my plug-in like whatever it's just what are you gonna do about it
basically and i couldn't see what he had or what place he was in and he's he sent like two attacks from really far away and onto my best planet and he was gonna take it right away so i was like okay i can't mess with this guy anymore he called the warning shots i had to like scramble to figure out i had to put the right artifact on that to stop the attacker i was going to lose my best planet so um sometimes she formed truces that way i never took one of his things again even though now i'm i think a higher rank than him it would just it's not worth it to start a war with this guy because he's going to end up taking a lot of my stuff and i'll be here watching all day trying to
defend it so i left him alone uh okay so the next one i did was this one's called rebalance and what it does is it looks for my silver mines or my asteroid fields that have at least 80 full and sends the silver to the planets that need it the most and of course the point of this was to increase my silver score by putting by maxing out the silver on planets and then upgrading them and maxing it out again uh so this one is one i used a lot to um mostly for this guy who's got a ton of silver to spread it out through
through all of my planets and then we have the artifactory which is a mostly stock plug-in amazing plug-in helps you manage artifacts so here i have an artifact on this desert planet and to find like you can see there's an undiscovered artifact on a planet uh see if i click on this i think it'll take me there right so it has this like uh gift box on it you can see let me get this out of the way if i zoom in you can see it on the planet so this gift box means there's an unfound artifact and you have to have 95 energy to find it so this plug-in helps
you locate those it also auto-find them so this is super super helpful and i'm gonna do it now so we can see what we get from this planet called sag toss which is kind of weird name but it's i think it's all random randomly generated so it's calculating the snark um zero knowledge stuff for this artifact then okay it's submitting it and then it's gonna reveal to me in the ui what it was hopefully it's a legendary one let's see okay you might have to click it okay cool so it's um
a triangle one i don't know what that's called one of the defense ones and okay this is a pretty nice one so boosted my defense by 60 but lowers the energy and this is uh an epic one so cool that was a great a great find now once you find an artifact or put an artifact on a planet it's actually has a cool down before you can move it again before you can withdraw and that's 12 hours so i can see here all the artifacts i'm eligible to withdraw and now something i didn't like about this plug-in is that when i put strategic artifacts on here
and i had this auto withdrawal enabled it would take them off of my planets where i wanted them to stay so i modified this code a little bit to only withdraw from planets that were lower than rank four which was pretty easy to do we can dive into that in a bit uh that's right very much what i'm excited about like like we have a plug-in but we just want to tweak like one little parameter so that's that's great exactly yeah we'll dive in that one first because that's a good place to start uh another thing i did was or this is another one i used very extensively was this remote
explorer so as you saw at the beginning of the game there's like um an explorer or a miner basically that is grinding through all these zero launch proofs and as i said before my laptop really sucks from years of abuse in developing eth2 that i i am running a a a remote explorers on my net my other gaming pc on my home network and this is running a rust based it's written in rust the programming language and it's much much faster than the javascript one so even if you don't have a second machine you might consider running this on your local machine because with this laptop
i'm getting like 300 hashes per second with this computer i'm going to use 6 000 some people have gotten like 30 000 um using the digital ocean these other things so i use this a lot it's kind of hard to set up but once you get it set up you're going to be glad you did it so this is where it's mining some new new space that i haven't discovered yet that's a little there it goes it moved and just discovered like a little bit there so the neatest thing about that too is is if you have several miners um even if they're relatively weak miners you can point them at different areas so if you want to see like you know you're curious about multiple areas you can run each miner in a
different place that's that's really uh really useful yep and you can run there's two different types of patterns so this one is running in a spiral based on wherever i had put the marker and but you can also do this like swiss one which is like kind of swiss cheese and it does like every other block so here you can see this and this is to help you find areas of of the universe you want to explore more so you mostly want to be looking at dark this deep space that's where the highest ranking planets are and the high and the best asteroid fields so using the swiss explorer algorithm i guess is
can be helpful to help you find that that stuff uh you have to keep it open for it to continue working i'm gonna close it because i'm not i don't really care to expand my map right now um one thing i did edit about this is the default the default uh starting point is zero zero so in the center of the map uh which i thought was kind of kind of goofy i set it to my home planet origin which is over here somewhere so whenever i started the game it wouldn't mind this circle anymore i don't really care about over there too far it would mind closer to the center of my there's another one i tweaked a little
bit targeter this is another public one i think this is nick johnson's plug-in where you can choose i haven't used it much but you can choose a planet like this one here and you can look at all the planets that you have that are in range and what it what it's supposed to do is schedule these attacks in terms of time so they all arrive at the same time uh which is helpful for those planets you that cannot be taken by the energy one of my planet so if i'm sending from this guy
over here it might take an hour for that to get there this one might take 15 minutes to get there so this plug-in can help you time out your attacks better and capture planets that otherwise would not be feasible to do i love that plug-in by the way it's so wildly powerful like almost dangerously powerful yeah thankfully i haven't engaged in too many uh pvp wars or player versus player wars and haven't needed it i think another cool plug-in idea would be like a defender of some kind so if you're under attack from from this plug-in you can schedule uh and maybe you can use it for this you
can schedule the attacks to your own planet to give reinforcement energy to help defend it that's a great idea and that's a good time to point out um i know everyone knows about it or as hearing about it that dark force released that blog post today talking about the plug-in competition um defender sounds like a real yep that would be neat uh and then the last one here is targeted and load everything up sorry they have logged out and so if you've got defender you're feeding energy into that at the same time someone's attacking you um it's kind of neat yeah and then the last plugin we have
here is uh something that's missing from the default ui is the ability to gift a planet to somebody um the the functionality is all there from the api perspective but it's just not possible to do in in the ui so maybe i want to maybe i accidentally took my neighbor's planet and i want to give it back uh i can go through the list here and choose somebody i want to give it to um superfiz what's your handle on here i'll give you this plan i'm i'm under logic at logic underscore beach okay i wish this was sorted okay that's not actually me
but yeah okay well just to demo this i can give you this and now another thing about this game though is that it may not i don't think it notifies you that you have it and if you haven't discovered this space you know you wouldn't even know it either so yeah now you now you have i wonder um let me see uh can you show the coordinates for it i know you're in the southeast oh actually i don't know that's a pixel though the coordinates here they are uh oh got it
yeah i see nothing 98 351 yeah yeah you can i can click this button i thought that i might possibly just see like the planet block and nothing else but i don't see it yeah that's the thing is that um what what you see in the game is this location like hash and you need to do the zero knowledge basically to do zero knowledge snark proof to be able to translate that to the dislocation coordinates so you're not gonna see it until you discover this so i guess you could put
your minor here and start mining around it but that's kind of how how the fog of war works great so those are the things they use i'm sure there are more more helpful things but the point was i wanted to expand my my control of planets as far as i could and collect as much silver as they could as quickly as they could and then also punish people that tried to take my stuff so the okay the what i say the okay so the artifactory one let's take a look at uh when you look at a plug-in it's just javascript and and these components are
based on the react framework so if you've ever written anything in react then you're gonna you're gonna love this because it's just gonna it's just gonna work um let's see so where was it it was with the withdrawal that i i added this like modifier so see and you know this like ui is not great for editing so what i'm going to do is i'm going to copy and paste it into visual studio and i can read it i'm going to call it plugin okay so can withdrawal
01:18:17 - an in-depth breakdown of Dark Forest Plugin
here's what i did is there's this withdrawal artifacts function and i basically filtered out any planet that was lower i filtered two only half planets that were lower than rank four because i didn't want to take the artifacts off my good planets that i was using to defend so that's a pretty easy example of something you can tweak really quickly um let's go into my big one here this auto conquer this is the one i spent the most of my time on and so the the basic skeleton here is you have this this class uh thing and you have a render function and these
are really the two things you need to at least that i worried about is like i want to display some information and register my plugin and so when the when the plugin loads is going to call the render function you get this container object which you can use to call render which is like the react uh thing not much of a ui guy anymore so i don't know and i've never written anything react so this is new to me but what it's doing is rendering some html and then loading this app function in there and the app function returns some html html says do you want to conquer everything and it shows my button
and when you click the button it calls on to my big conquer conquer everything function and of course i haven't yet opened open sources to put it publicly but i will now the contest is over and it's really not that secret sauce you know it's it's what i would have done or what you would have done uh manually it just saved me a lot of clicking um so taking a look here i added this uh like little debugging thing where i didn't want to stack my ui with too many moves because my computer sucks and if you get a lot of moves that are like still processing
you'll run out of memory and the game will crash so i had this like functionality here for debugging the first thing i wanted to do uh and can you maybe i'll make this bigger i don't know if you can see it first thing i wanted to do is i wanted to find out which of my planets were under attack and because i didn't want to move energy away from planets that were under attack so you have this global option our global thing called df and df is course stands dark forest it has all these like helper methods on it uh basically how you interact with the game and i don't know if there is like a written documentation on the api what i
did was i went into the javascript console and i i wrote it here i wrote df and then i would look at it and i look at this proto thing and this shows all the methods you can call and i kind of just read all of them to see what i'm supposed to do so for example we wanted to get voyages i think is what we just looked at uh wait what was it get all voyages and so i can look at this and i can click here i'm sure there's a better way to do it but this is what i did i clicked on and this is the game manager file and i
read the code to figure out what's going on um i wish there was an epi site and if there is this crate i don't know about it though i i looked the same way you did i can interpret as well as you did but that's that's the first obvious logical and of course it's typescript which is um such a relief over javascript so i knew what was coming back here without having to read the exact implementation of this entity store so it turns an array of cued arrivals so using javascript array uh functionality i added a filter so i wanted a filter for all of these
uh voyages which are attacks i want to filter out any of the attacks that are not like attacks that don't um originate from me so v dot player the voyage player is the person who uh initiated the attack and i just said okay if it's not coming from me uh to myself we're not going to consider that a tax so df.account is my account and then i'm add the planet data so the voyage doesn't have planet data on it i have to call it here so i do a map uh thing which takes each each voyage and then will return
the value of this so it's basically mapping voyages to planets and i'm doing another filter basically only filtering out plants that i own and then mapping it again i only want the location id so it it's uh it gets a little complicated but it it kind of brings you back to the basics of like iterating through data and mapping arrays and kind of messing around with arrays so when you wrote this i did you write the the filters consecutively because i would write one to try to get it right and then i would test it and i'm curious what your testing procedure is yeah so you usually would run it in the console so i would
have pasted this and then wrote it i would write most of the stuff in here and then see what came out so of course i'm not under attack right now so it's not very helpful but i would outright get voyages and this is um all of the attacks going on in the game right now that i can see i think uh there's almost 600 of them so i could look at each of them and see what kind of data was there and that helped me write my filters and my maps my map functions and stuff like that okay that i think that's the big hang up for me like i i can write very small snippets but i need to
i have to test a lot and check and recheck and redo um because you know there's not a lot i don't have a lot of skills so it's there's a whole lot of testing i i guess i need to find some way to have um useful output from testing on the console to say yes this did what you wanted to do or no you're totally lost um yeah and i made a ton of mistakes doing this so usually when i'm at work writing code i i write a test first a unit test and it's usually like well scoped logic um but when we're working here it's like
fast and loose and like sometimes i'm under attack and and and going crazy so i'm trying to get my plugin working as fast i can and i i got so much boolean logic inverted where i stuff like i don't want to attack any players so i'm going to add a thing here and i got it backwards so it was only attacking players i clicked the button and it launched 100 attacks on everyone around me and i'm like oh my god i'm going to upset everyone again so i like to try it out in here and see what comes out before i do it so the javascript console and then writing it in vs code that's how i was doing my workflow and then then i would run it in
actual plug-in in the actual plug-in and what you can do and what i did a lot was i just like copied and pasted my whole plug-in into my javascript console um and it would complain okay plug-in is not everything everything else worked so i can call my conqueror function from here and it will do all the same stuff that just like just that one function to tell you where you're at it okay yeah yeah if you would call this and it would it would work i mean and that's what the plug-in is doing so if we went back to the plug-in um app when you click the button it's calling this function yeah so i could shortcut this and just do it from the console and that
was the fastest way i uh iterated so i'm gonna have to paste it in here and then load it again and click the button i just did it in the console something i don't quite understand um why isn't why isn't code you paste in the console not executed in the game so the i i didn't i didn't actually execute anything in the console i just pasted all the definitions okay so it's just basically like this function i added you're checking the function not actually calling it in in real life yeah exactly so okay this is interesting here i have this beep thing um so what i could do is i could paste this beep and i have this uh b function
uh you probably didn't hear it but it beeped we did and then i was doing this uh set interval um thing so and i would set it to three seconds whenever i wasn't making a move every three seconds it would beep at me to do to do something so i could schedule a bunch of moves and then go back to work and then my computer would start beeping and say oh it's time to play again that's pretty awesome yeah so that's another thing you can do for a plug-in contest is a plug-in that's showing all of your unconfirmed moves a plug-in that beeps at you when
when all your transactions have gone through and you're ready to schedule some more work i would have used that a lot uh i didn't write it but yeah i'm still never clear when all of my when my transaction queue is finished or not like i'm i kind of wing it a lot yeah this thing was scheduling like hundreds of moves at a time and my computer being very slow takes a long time to grind through all those proofs so it could take 10 minutes or longer before i was ready to click the button again yeah okay so planets under attack we have that i don't want my planets that are
under attack i don't want to move energy away from them uh but i want to find now planets that i can make a move with are ready to make a move okay so i get all of my planets with this df.get planets and i start applying my filters uh and now what i like to do is just one line per filter right so i have a filter and i take a and i do something with it so you can see the first one so i only wanted to mess with planets that had a planet level greater than one and you could chain these filters together um ultimately i put it into one big long
like line which is really gross but it i think it was better on performance so it didn't have to run through the filter multiple times it just did it in one so what it's doing here is uh for each filter to planets that have a level greater than one planets that uh don't generate silver so i didn't want to mess with my uh my asteroid fields because i wanted to use those to move silver around not to conquer planets i wanted to filter to planets that had enough energy so basically i took the planet's current energy and then i was looking at
also the the moves that were not confirmed yet so this was taking the current energy minus the unconfirmed departures sum this is basically a sum function so it sums all the energy of the of the unconfirmed moves and then i wanted to make sure that that was 75 percent of the energy cap so i divided it by the energy cap and made sure that's above 75 the reason with that is i didn't want to take a planet that was already low on energy and make it even lower it it wouldn't have a great range and it could put it at risk of being captured
so i wanted to make sure i had at least 75 percent uh range i made sure that the planet that we're looking at also was not currently under attack so planets that were rank one are higher than rank one didn't generate silver had at least 75 percent energy left and weren't already under attack and then i sorted those by planets at the highest energy first so my best plan is basically uh i looked at planets i was currently attacking so similar to planets under attack but um these are ones that were coming from me instead of the ones that weren't coming from me and then i reduced that to um this like
map um that i was tracking the count of all the planets and then the energy that was already attacking so this was helpful for like combo attacks so if there was a big planet that i didn't have enough energy to conquer with one planet i would send multiple attacks there um this is the total moves again so okay now we get into the juicy stuff so for each planet that i found was eligible to attack we're going to look at what now what planets can that planet attack get into the good stuff so we have candidates which are defined as using the dark global object get all the planets in
range of the planet that we're looking at under consideration with 50 percent energy so when we're looking at the circle here you have this 50 percent line it is basically giving me all the results that are in this second circle here so i used that data to then filter out planets i actually cared about so i didn't want to attack my own planet obviously um and i wanted to attack planets that had a planet level higher than two
or had an artifact on them because i was mostly interested in increasing my score or getting artifacts um and then i sorted those by the highest energy capacity because i wanted the highest i want to capture the highest value ones and then i map that um oh this is like a hack i mapped it to a basic array for some reason oh because i used to have it it used to be sorted by attacking the closest planets first and i was lazy so i made it in the same format
okay so for each candidate that i i've identified so every planet that was in this second circle that was above planet 2 or had an artifact i wanted to attack but if there was over 100 100 unconfirmed moves i would stop trying to attack because my game kept crashing extract the candidate out of the array i hacked together here um and then i checked okay is this target that i want to attack uh can i attack it anymore then it's already at so looking at that function if the number of attacks that were pending
or in flight to that that target if it exceeded the number six the transaction would fail i think there's like a concurrency limit that i heard about in discord i don't know if it's true but i did notice that if i tried to send like a dozen attacks or more to one planet then they would start failing uh i didn't want to waste my x-tie so i added that there i also checked that the uh the sum of the arriving energy uh if it was less than amount of energy required to take that that's when i would want to send it if it was more if it was greater than that like this
um greater than the planet power then i don't need to send any more attacks because it's already going to be captured at some point so if if the planet was at capacity i'm not gonna i'm not gonna send another attack i continue on to the next one in this for loop uh or if this was um unowned let's see unowned and greater or less than okay so if it was uh an uncaptured planet that was less than planet level two also ignore it which i think that is kind of redundant i think we filtered it out already
so that's kind of done it that makes me think about filtering planets by um i've been interested in filtering out uh pirate planets i guess um they probably have a unique owner id that could be filtered by i just wasn't sure how to do it yet yeah pirate planet you can define a pirate planet as a planet whose owner is the zero address and has an energy greater than zero ah that's yeah perfect that's how you define uh planet with pirates and then i also had a white list or safe list of people that i liked and did not want attack anymore so like mr mr agent k i
put him on my white list and and said uh don't bother that guy because he's going to destroy me so so if it meant any of those conditions i would skip that target and go on to the next one all right now we need to figure out we've we've identified a target that we want to uh capture we need to figure out how much energy we need to send uh because you don't you you kind of only want to send what you need you don't want to send all your energy because you want to waste energy and you want to make yourself vulnerable to first thing i identified was what is the minimum energy to get from my planet to the target and then arrive with one energy remaining this is the minimum you need
to get there in my mind and then i also wanted to figure out what is the number of forces number of energy i need to get from this planet to the target um to capture it and have ten percent left because the way the energy growth works in dark forest is it's on an s-curve or like a bell curve kind of so if if you have zero energy it's going to take a long time to ramp up to that peak energy production so i wanted to give it at least a little bit of boost and give it at least 10 percent to start that's what i was thinking so if i determine that okay i need
this many forces to do that but that's more than my planet has obviously i can't send more than my planet has a transaction would fail so what i did was i said all right well if if i can send and at least enough to do some damage the minimum energy and stay within 80 percent of my 85 percent of my energy cap then i'm going to do it so if if the minimum energy is less than my 85 capacity i want to do this if i have currently if i have over 90 i don't want to exhaust all this so i will make sure that i had at least 90
and that the target is unclaimed and then later in the game i added i only want to do this for high level i'm going to do it so i can determine i'll send 85 of my forces to do at least some damage to that planet and help capture it so i did that and then i added it to my tracking array so if if i wasn't attacking that planet already i'm going to add an empty entry i'm going to increase the count and remember we wanted the count to be less than six otherwise it would fail i added the energy that we saw how much energy is going to be arriving once once it gets there the forces decay
over over a distance so when i send a thousand for energy when i send a thousand energy only 100 might get there so i needed to track i i i wrapped the move in a try catch block and what this does is this can throw an error i didn't want to i didn't want to stop attacking with my other planets if this failed uh this would fail sometimes when uh i had discovered a planet that was uh actually out of bounds so let me zoom out a little bit here and you have this like radius of the planet uh radius of the universe and sometimes your minor will clip a little bit outside and it will
show a planet there and this guy might have tried to attack a planet out of bounds and it would throw an error and i didn't want to stop all the other attacks because of one planet aired out so i put it in this tricatch block and then i indicated that planet is now attacking um because i had a second layer of things to do so if i had a planet that was eligible to attack but there was really nothing else it could attack i wanted to give its energy to support one of my um better planets so if i had a planet like my best planet if it was only like
let's say this planet like was really low on energy i want to just send over some forces there to build it up and so i could do another attack with that one sooner can i back up and ask a question yeah um your your try catch where the planet was out i the the case where that would occur i didn't i didn't quite understand it yeah so okay so you have a right a minor that goes and explores the yeah right and that's the boundary within the boundary but but there was a bug uh with the remote explorer that it it would it would look four planets right here on the edge
and it would do so in a in a big block so of that block would would actually discover space outside of the radius and it would show a planet so you can like maybe this one for example and stuff would try to capture it like we knew it was there but this line uh you can't travel outside the line do we know what creates that boundary i mean i know what the boundary is but what what creates it what maintains it um i so the line changes uh the radius increases based on the number of players that are in the game so you can see how my minor my explorer
has mine this like step pattern here because the line used to be right there and then more players joined so it expanded a little bit so that's a really key advantage if if you are like somewhere closer to the center of the game try to move to the outside because when this expands i basically get first dibs on whatever planets are there yeah we were doing the same thing trying to create a wall um right there so that we could have dibs my two friends and i were playing together we could have dibs at the uh the edge of the wall i just i didn't know what pragmatically controlled that boundary um i guess it's it's probably a formula that that considers the number of players and
yeah i i don't know how it is in the contract but it's like df.world radius or something something about radius yeah world radius uh this this is i'm i'm assuming this is a read uh variable value on the smart contract uh and that it increases at it's like probably influenced by the number of players so you can see there's says there's 954 players currently playing i'm guessing when the next one comes
this radius increases by a couple points i'd have to read the code to be sure but i think that's how it works all right um yes like i said this part uh we'll go into it into too much detail um but it would it would give energy to us supporting planet basically because there's nothing else that i could do and i only did it with planets i had a thousand extra energy it didn't really help a lot and i probably definitely removed it sometimes you can see i had disabled it i did like this and so it would never work because it was kind of just wasting
uh wasting money so um that's the meat of this plug-in and i have a lot of like helper functions here uh and then my my a safe list um and then i one at one point i wanted to get revenge on agent k so i wrote down the plans he attacked me from but i never i never followed up on it there's a lot of code in here that i'm not using but i just had written and then um figured out already distracted from other plugins i see it going easy on bitcoin louie up there oh yeah bitcoin louie and me were you know being close friends we actually shared our maps so um one thing you can do here is you can you
can like export your map and then someone else can import it so this is all like bitcoin lewis space that he gave me um these other two blocks are just areas that someone had posted on discord and i imported it ah and then all this is stuff i discovered if you form an alliance with someone which i'm i'm gonna guess that in the next round of this game this alliances are gonna be pretty big uh way to win you're gonna want to share maps and things like that so you can go to your like settings button here and copy your map to the clipboard save that to a file send it to your friend they copy it to their clipboard and then import it and
they got all the math there yeah i i found that my uh my map is something like 98 megs now and it's it's too difficult to handle on my clipboard um but there are some console commands that will i think there might even be a plug-in now for map exporting to file um yeah the bigger they get the more difficult they are to manage yeah exactly there's a plug-in that will allow you to export parts of the map so maybe maybe you're i think this is what someone did on discord is they say hey this guy over here i i'll give anybody a level seven planet if they wipe him out and then he exported this part of the map and uh cool he's still there so it it didn't work but uh that's one thing
you can do is you can just export a little piece if you wanted okay so to recap what this plugin does we have this class it called auto conquer uh resets some parameters in the constructor so this is always run when when you call new and then this plugin is going to call this render function and display some html and if you're familiar with react you can do a lot of stuff with that you can you can have dynamically changing data i never figured it out yet uh you can have like sliders and like custom ui buttons um me i was all about trying to get this
optimal algorithm to conquer everything as quickly as i could so i just did like a fast and dirty conquer function um and same thing with my other plug-in where i wanted to spread out the silver so it's using some of the same functions and filters i was um looking at silver mines that were 80 full and spreading it out to my planets that had low silver and then upgrading those and so on um i think walking through that one would
would be a lot of the same stuff and take a long time but i will share these after it's a really good overview like um for me the most helpful part of it has getting that so i was using the the console to find the functions but i i didn't quite make it to make the progress to use the console to test them to test what i had written um so that that just makes so much more i don't know why i didn't make that obviously um yeah like this is probably one of the first ones i wrote is get my planets and and then look at the first thing that
came back and wondering like what's what is a planet in terms of the api like what yeah information do i have i have all the metadata here about about hats and energy and then i have an array of see of outgoing moves and and artifacts and and upgrades and all this stuff um and i spent most of my time in here just messing around with this df object and seeing what's what's out there look at all this stuff i was doing that's really you know how i was able to debug and like find things let's try it
on the console first you can even make moves in here you can make the move in here if you wanted to you can do everything everything you can do in the plug-in you can do it from your console and then when you're ready you can package it up as a plug-in and then you don't have to open the console anymore you just click you just click the button um you just click it and then it starts doing the stuff you want to do awesome um i wonder if people in on youtube who are watching have any questions yeah it's it's definitely a great foot in the door like there's so much wild potential for this game and i predict that in a month or so it will be more or less
automated play versus automated play it's i mean it's moving in that direction so rapidly yep it's it's all about at this point in the game who's got the fastest computer and who's got the best plugins yeah i love that remote the remote crawler like you don't even have to have the fastest you just have to have enough like i i put every machine in my house on it for a while just because i like i had to um except my staking note yeah this one that i was running this old gaming pc it has like an intel i5 in it and i built it like eight years ago so it's only running with four cores it's
01:28:00 - Open Questions from stream / Brief Q&A with Preston Van Loon
really not a good machine and it's getting a very impressive six thousand seven thousand hashes per second um yeah and when you're starting out that's huge as well one of our friends has a ryzen nine and we connected to that and we're i think it's we're getting 40k um hashes so it is it's wild yeah um so uh someone asks where we can or i guess you haven't published your plugins but you said you had considered it i will put them on github uh right after this uh call or i mean i can do it now i guess and then i can share it let's see so i want my
what did the other one want the auto conquer one was good auto conquer oops i i've heard you mention you know like you can't share this while you're playing because these are so valuable in the game like um it's it's difficult to share your strategy while you're competing or you know you don't want to give it away to the people you're competing with yeah exactly like i i haven't shared this with anyone and they weren't really um meant for public consumption so like there's like comments in there that probably don't make sense um functions i don't use anymore
or whatever but if if um if it helps like yeah pick it apart take parts that you want uh do whatever you want with it um it's on github now i don't know how to share this with maybe put in the zoom chat i don't know uh yeah if you put it in zoom then one of us can put it uh paste it over to uh the youtube but i'm so so thankful that you took this time to share with us like i i have a much better picture of of where to uh what direction to work in now like i know that i'm not going to be a great plug-in author but i
i'm more able to manipulate what is already there and and tweak it to my purposes yeah i'll tell you what this thing here uh has been the most helpful uh thing i've used so far so one thing you can do with javascript right you can import import um utilities or functions that are already used and these are ones just be pretty common in the plugin of public plugins but what this one does is it's it's a wrapper around df.move and it's like a q on top of a q and this this helped me from from my game crashing so i could i could schedule hundreds of hundreds of moves uh where
before i could only do like 50 or so but once this came out it made it much much better for performance so definitely use this move instead of the df.move um and then the side effect uh bonus is if i use my plug-in to schedule like 100 100 moves um the moves i made manually would actually take priority over those secondary cued moves so it's just all around like one of the best things that i've been using is this uh that's an awesome feature yeah all right um yeah thank you so much preston and so i'm glad you posted those uh
this video is going to be really valuable uh that contest is january 18th do you think you're gonna submit anything i know it's not about winning but are you thinking about throwing your head in the game um probably not i mean just because i i i uh i wrote this for me and i i hope it has value for somebody but it it's it needs a lot of work and um i kind of i time boxed myself to like i'm gonna i'm gonna play this game for one week and then i gotta get back to work so yeah um i i haven't made that commitment yet so yeah i
i have uh i shouldn't admit it but i've like i've really like been derelict in a lot of things like i'm i i'm sneaking you know 15 minutes here and 10 minutes here because it's a you know that that whole waiting thing so you can submit some transactions and then you can go do a thing and then come back and i'm like um excusing myself from dinner to run up and make some moves and then coming back yeah i mean i was still working the whole time because most of it was like every 10 minutes i come in here and push my buttons and like look at see what's going on but it's a it's a big time sink because it's just so fun like i i couldn't step away the first like a couple days i mean
i would look and it was like 9 p.m and i would look again and us two in the morning yeah exactly hey so i i do appreciate this but i while you're here i'm really curious um anything you want to share with us about uh progress on prism uh sure so so prism is uh e2 client that um i work on with prismatic labs um we've got uh a lot of changes coming up from over the holiday we we haven't done a release since mid-december and we've got some nice performance improvements and things coming out so uh stay tuned for that um and then we're working on phase one
stuff in the meantime um i'm kind of hoping that will come out soon i i i hear this talk coming up with you and danny ryan yeah we'll get some nice details from yeah i'm very optimistic like we it was it was such such an impressive push for everyone to get e2 launched in 2020 so that december first thing that's just incredible and congratulations thank you we haven't really talked since then so i prism led the charge uh from the clients and so uh you all did just fantastic work so thank you for that um thanks and so since then i've just been kind of like
recovering and you know catching up with my own life and so now i'm i'm ready to like find out what's next in the future for eth2 so um very exciting stuff yeah me too i'll be tuning in and i bet i'll learn something because this the phase one stuff's moving pretty pretty quick and of course uh spec is still being refined in in all areas so um i'm looking forward to it hey so um you know prism led with the client test nets um before there were multi-client test nets um do you have any inkling about whether that model will repeat or
um is that is it too far off too far out to really consider so in prism we started uh running our own test nets very early and the idea was to get the code in or get the software in the user's hands and get feedback early we we may do that again but i would prefer to do it as a coordinated testnet so so grouping it with lighthouse and nimbus teku whoever else is ready that would be preferred but if it comes out that we have an early prototype we'd like to test we very likely will do a small
prism only test net to to demonstrate uh our phase one functionality and to get feedback from users that's cool yeah kind of our model is to get feedback fast so and it worked really well like uh in terms of like developing a strong following and i i loved the opportunity to test those products so early on um but yeah i also recognize the view that it's it's better if it can be a coordinated multi-client that's not so yeah i guess we'll see what happens yeah definitely i mean it's it's uh last year was amazing and really fun and this year is going to be the same with terms of
e2 development all right thanks for your time and uh michael it was i'm glad to have you thank you for uh michael handled our poep in the background and i i know um he was sort of a silent partner but he got all those co-apps distributed yep all good youtube so thanks both of you for coming out and uh have a great day all right see ya