A Game on L2
ETHCC 4 · July 2021 · 25:21
Ronan Sandford recounts the experience of building a fully onchain game on a Layer 2 network.
Speakers
Topics
From ETHCC 4, hosted by Ethereum France.
Transcript
hello everybody thank you for coming i was prepared for 20 minutes so i think we have a lot more time than i thought so i look forward to your question and i will take it a bit more slowly so yeah i'm presenting here a game i'm building and the goal is to launch it on l2 so we just year of upcoming l2 so it the game could run on multiple of them so really looking forward to try them out uh just a bit about me uh being in the space since 2016 explore various ideas work for a various project
and some of them are shown here so heter play was was what is a company now that i relaunched to build this game that was uh back in the day in 2016 building uh basically one of the first block like metamask metamask-enabled game on ethereum and then i built like mystery market eternal world and mandalas recently so this is a picture of of conquest which is the game i'm presenting today and how it uh it will run on layer 2.
so here is a picture of basically every little square here is a player-owned planet and the game is basically a social game of strategy and diplomacy and i emphasis diplomacy especially and i think what most likely be the future of crypto game are going to be diplomatic for one simple reason is that bots are going to beat humans in every other field and we can see that with conquest which is a in some way a very simple game and so to describe it is basically a game where you take tokens to make planets produce
spaceships and you attack the other player to capture their stake with with these spaceships and it what make it a diplomatic game is a simple equation it's like if you are alone your risk equals your power so your stake is your power so if you are alone that will always be that as soon as you partner soon your risk becomes lower than your power so it's a game that in the end scale because you could have someone going in with millions of dollars he's going to have a million dollars of power but he's always also going to have one million dollar at risk
it's based on the game that i enjoy playing that is closed so it's this game is called conquest i discover it through linux and it's based so that i learn actually looking a bit deeper it's based on the older game i think in the 70s called galactic conquest and it's it's quite simple you have a grid you have planets around and you set a game so it's a it's a completely closed game uh players have a so it's a fun start at three players and so you have let's say three players each other planet and the planet for the spaceship is turn-based
uh and yeah so every turn they have more planets and they choose where they attack they know everybody else planets and how many spaceships are located on this planet but what they don't know is where they are sending these spaceships so obviously you can imagine like making alliances hey like it happened always basically as a three-player game as soon as someone takes the lead the only strategy viable for the other is to come together and to kind of use the spaceship to beat the other but because the spaceships the fleet are unknown
you never know if the guy is actually the other person is actually stabbing in your back and you discover that probably too late so the idea was like okay it's a very simple game how can it fit in on the blockchain so blockchain game are basically mmos so how to make this game open-ended and where players there is no limit of players and they can journey any time so that was a challenge to how to fit that into uh into a blockchain and that's what the the game is about and then of course to make it fully decentralized it needed to run uh on on the evm itself and so when it was designed back then
the goal was to run it on mainnet like the operator on my net with the gas cores that it imply and i still think today it could run even even if the gas price was multiplied by android he could still run on the mainnet but obviously the demographics will be different it will be only people or entities like dao will who could participate in it yeah so that's why i mentioned about the idea of alliances and also of betrayal so i put a question mark here because i'm pretty sure it will happen but in the alpha so i we launched an alpha in um yes i was mentioning before uh where there was 160 player probably like maybe 30 40 very active
and they were creating alliances in the discord the game was not encouraging public alliances so this is a next version working on they will player will have to so they will have an advantage to publicize their alliances um yeah i forgot what they were saying yes so the betrayal in the alpha didn't show up so we could see alliances but no no betrayal so but i'm sure it will go and so this game runs fully on the vm as i mentioned it's built in solidity and as i say it can scale so and that's why you can run on l2 because l2 is is still it's not like a
big order i mean it's still an improvement but we there's still a question on how much uh we could say okay we'll divide by 100 but maybe we'll be divided the cost of mainnet by only 10 for example but because his game can scale um i have a strong conviction that he will be able to to run there so as i mentioned like yeah like conquest the planet state ownership is known but the the attacks are unknown and it's usually reveal and commit a commit is simply required simply a commit and reveal scheme and so obviously it is introducing in complexity for for the user and the front end so that's
kind of the main work uh that is done on the front end so currently yeah it's a work in progress the goal is to launch on may net when i say monday a layer two main net could be optimism arbitrary air mass for example or whatever but or it could it would be multiple in the end and so the currently is working on better ux better graphics and as i mentioned the alliances and uh adding some extra rule with nfts in uh to give more mechanics of capture so and the next alpha is planned for october so as i mentioned it was designed for mainnet
so the first version was every single action requires only one storage slot once read one right and every planet state so for that exact same reason are described with only one storage slot and another optimization was like every stat so there is power another production attack defense native so there is few extra characteristics and all of them are just generated randomly so pre-generated because the rash is basically done up front and it's just a hash one nash operation so but obviously
if you start dig deeper you realize there is some issues and we had to sacrifice some gas one of them is a front running issue it's simple so i mentioned the fleets are unknown but you have a committed reveal scheme so you commit your move you say where you are going and then we are talking about a game where uh when you send spaceship it can take three days you can take seven hours or you can take even ten days if you are attacking someone uh at the far away place in the galaxy and so you have to come back there or you have to have something running for you that will that will do that but when you reveal
um the obviously the defender can see the transaction on the network before it gets finalized and so while the attack is inevitable the defender could just say okay i'm going to die anyway let's save my spaceships and save them so it's not it's not perfect it means the attacker don't have the choice of telling them because the attacker always could say hey i'm going to attack you you should go away and and that's fine that's part of the game but if if there was this front running issue then it will not be a choice every defender will know and you could have a service that do that for you you always send your spaceship away if you know that they are going to be destroyed
so we require an extra storage right and and so you can if you receive an attack during the 15 to 30 minutes you can't escape it so the world game run on l2 and the way we the game make revenue so the idea is to build up a studio behind it to build more games and improve on the game so we choose to use dye as a so the way it works you go on the l1 you deposit die into the airplay token contract
you receive at airplay token and this enterprise token you transfer them to l2 and you use them to stack on the planet so if if i if you can imagine that as a player doing it you'll probably not play so obviously as soon as we can move to l2 we we can do that ourselves so we can just deposit our own 10 000 die in the on l1 and then transfer them on l2 and then simply sell the token on l2 so it's mean as a player you don't even need to know that there is a real one you just come you purchase your token you stake and you play now while the die is on l1 it's not the reason for it to be there is that
the country data play token contract will auto invest in the d5 ecosystem like yearn to generate revenue generate revenue so as more players come the more revenue the company get and so yeah there is various solutions being worked on and we are there is no reason to to not go on all of them so there is different implications on l2 so an irms actually like timotherms mentioned that a bit is that there is different gas cost semantic between what we are used to on l1 and what we will
see on l2 and also it depends on which solution whether is using their knowledge proof or arbitrary i've defined basically a gas cost but overall the same logic applies the more optimized you are the better and there is also of course the delay of transaction inclusion which depend of either whether how much it cost or how much it batch and so it affects the front running time so when i mention 15 30 minutes we might need to adjust that depending depending on the network and again like while l2 uh plan to reduce the gas cost we are still dealing with a gas cost that is non-negligible
and so then the design of the game need to account for that and we believe that conquest is such a game and there is future issue with uh data scalability uh with polygonating that issue for example but there is also what was mentioned about data availability if we want to remain fully decentralized there is also the issue that most of these l2 are in this stage of progressive decentralization so that was basically it so the the game there is a website for the game and you can subscribe to the mailing list to get uh to get to know when the the next one will run we also set up a dev vlog where
we kind of uh describe what we are doing uh there is also um a website for for the company so i think there is a lot of time ahead of us i don't know if you have any questions hi um you said that in-game resources are directly linked to how many tokens you stack isn't there a risk of someone just coming in with like 10 times the number of token of the biggest player and just like destroying everyone and exiting with um like everyone resources yeah so it's definitely it's hard to
to imagine without launching in some way but as i mentioned like the more you have the more you have at risk so what's the risk sorry if you are the biggest one like in the game what's what's the risk for them so it's so it's you have to divide you cannot you don't choose to put all in one planet so each planet have different value so you are spreading your your basically your empire and then so it means that at the age you are basically vulnerable and it also means it's it's a bit interesting because you never know if someone has more than you and so it's kind of um you probably want to put bit see how it
reacts with more i don't know it's a it's a kind of question that i think we will have to see in um in real with real money and the test net was in i mean we launched an alpha and but it was free money uh so it i mean it was just free so it was hard to it will be hard to see that yeah so as you said there's a an issue with having everything on chain it brings a lot of issues uh have you considered doing some sort of proof-of-play off-chain that the player would push and that could get challenged by the rest of the network so i mean for for all the game in the past i've been exploring what you can do but there's a lot of issues that come with it for i
would we ensure that there will be follow etc so i think especially with a move now with l2 coming and i think the the future look uh very bright for like basically smart contract uh with full capability of course we have to start somewhere and i think the design of the game is basically for that for this kind of limitation but we'll see how we go i think like for example we had a one player i pick among uh was spend 200 million gas for three weeks of play so if we divide that by 100 with like 100 of a grey of it will cost two maybe four four dollars
for three weeks and i think it's reasonable but then if if it's ten times more then we are dealing with forty dollars in three weeks which is still fine but then we are dealing with a different kind of a bit different demographics and we are also dealing with uh the price of planets that we have to change for example now the in the alphas of four dollars the minimum planet and if we deal with higher costs we can just increase the gas cost so that relatively the action are yeah hey so for me as a player to form uh programmable diplomacy do i require to have a solidity knowledge
so i mean so there will be i think it will be interesting to see what you can do after on the contract side to manage alliances etc so that's one thing part of the work that we are working on for alliances is to try to make pluggable alliances so you can define some rules but in general the diplomacy aspect will be really a human communication so you don't need you will not need solidity and yeah no knowledge of solidity will be required maybe there anywhere we can see uh the diplomatic primitives that already built so for now there is no such thing as just people so in the alpha it was just
people like chatting in private and [Music] deciding to not attack each other and they basically won the alpha and there was some other alliances less less big less strong i think that i mean uh to to make this for what do you say to knock attack each other to make it programmable like we signed a smart contract so if you attack me or another member of this uh agreement attack another member he's going to be punished by somehow and he's programmable and insecurized yeah so yeah that's when yeah this you will need solidity and we might start to do some simple primitives
but ideally people will build so so what i expect is that as a player you might find other players already building that or even maybe open sourcing open making europa source for order to to reuse that to create to manage alliances yeah um so you were just talking about uh like unchained alliances and and how that could work so how do you think that would work with like the whole commit reveal scheme like if you can see what your alliance is doing on chain then like how yeah how how would you keep that a secret really yeah so i think you you want to keep it
as a so there is a an issue here like where when you want to do alliances you that's why you might want to have an unchained uh slashing mechanism for your alliances so that you still allow you to keep your move secret but if you wear to betray you will punish by another mechanism so this is something i'm looking like at what we can do to help doing this kind of mechanism but i think it's possible like to have a way to ensure that you have still the freedom to betray but there is a higher level where you say okay you betray but you now you are slashed by some other token that you created and um
so would there be like coordinated moves then like where you as an alliance want to make the the same move where you could because um let's say you all want to attack another alliance maybe and you want to have some slashing mechanism maybe for that as well that everyone needs to follow the same sort of strategy but then you can't really encode that strategy on chain because then it would be known as well is that something that you've thought about as well or like do you have any thoughts yeah not really i think a lot of it will be off-chain coordination and there will be an element of trust but what you can do on chain is to say hey you attacked me
and so then that's where you can slash so right yeah okay that makes sense thank you uh if you play on one l2 can you meet players on another l2 or not no it would be the game will be isolated the token the later play token though will be will be shared across actually all l2 but also all other games in the future and so if i want to meet a friend that is playing on optimism and i'm on arbitrary can i bridge from the l1 or will you put i mean there is all the
solution like but yeah it will be outside of the scope of of the work we do but you will be able to yeah technically stand your token but it won't be in game there will be no in-game connection across l2 okay and you plan to support every l2 or so no i'm actually i mean l2 is our main focus but we'll definitely go to sidechain like uh xdi matic actually this would be interesting for us because there will be different demographics with some side chain we could go a far lower price for the planet um yeah we could go even less than a dollar and
yeah i think maybe yeah so that we will definitely explore that thank you no other question okay thank you [Applause] you