1. Harwell
  2. News

Harwell News

Development Showcase

Development Showcase: The Mars Market
[p]Hello! I'm Caleb, creator of Harwell, thanks for checking out the game. It's still a work in progress but development is moving along nicely and things are starting to take shape. It's a huge passion project and a dream game so there will be a lot more of these coming in the near future.[/p][p]Follow these development showcases to see what I've been up to and what's coming next. It's pretty exciting stuff if I do say so myself![/p][p][/p][h2]The Mars Market?[/h2][p]This first showcase is of the market menu - this is the core of the game and it's where you'll manage the goods you can buy and sell. You can stockpile goods while they're cheap for your factories to use, or sell your high quality products on the market.[/p][p]It's also where you'll see your current funds, your debt, and your credit rating.[/p][p][/p][p][/p][h2]The Algorithm[/h2][p]Everything about the market is influenced by the players/AI in the game. The most important thing for me was to have it deliver a realistic simulation of a planetary market. Instead of being 'gameified', the market is close to a true simulation as I can get it.[/p][p]In order to achieve this, I used an algorithm similar to real-life economics; each good has a base price, price, desired price, supply value, demand value, and a price elasticity value.[/p][p]Warning! The following gets pretty technical and might be a bit boring to some, but I think it's quite cool.[/p][p]The base price is pretty straightforward, it's a set price that the good should be based around. The target price will be calculated based on this initial value. The starting prices also utilise this price, but are randomised by plus or minus 20% to create slightly different starting conditions within each game.[/p][p]The supply and demand values are pretty self-explanatory as well. The supply value representing the amount of sales of a particular good, and the demand value representing the amount of buy orders for a good. At the moment, implementation isn't directly 1:1 with the number of buys and sells in the market. This is because with extremely low supply/demand values the algorithm is wildly more affected by price elasticity, causing huge price swings with a couple of purchases. To avoid this, each good starts on 1000 supply and demand. This also means that supply won't run out right at the start of the game. This isn't set in stone, and it needs more testing, once more of the game is in place these values can be changed on the fly until it feels right, and the game will aim for as close to real-life as possible in terms of calculations. If I can have this be 100% based on in-game supply and demand without the buffer, then I will make it so.[/p][p][/p][p]The price elasticity value is a measure of how much the price changes based on the ratio of supply/demand. A less elastic good (base resources such as food, water, oxygen, power, etc.) will have it's price move much less when supply or demand changes, it's not as affected by changes in the market due to them being necessities. On the other hand, a more elastic good (such as electronics) will have it's price swing much more when supply or demand changes, this is because they are more advanced goods with a more complex production system so pricing is very dependent on the market. I'll see how this fares when testing the game properly, but the goal is to add some variance between the goods so they act a little differently. Players will be forced to learn the goods, not just the market, if they want to succeed.[/p][p]Don't worry - I haven't forgotten about the price and desired price values. The desired price is the price shown on the market that players will buy and sell based on. The Market Controller system within the game calculates this value live using the following calculation:[/p][p]desiredPrice = good.basePrice * (1.0 + good.elasticityFactor * supplyDemandRatio)[/p][p]This sets the price that the good should cost. This doesn't update straight away however, the game will slowly migrate the price towards the desired price. This means that changes aren't instant so players may have to consider how the price may continue to move and can't spam sell or spam buy goods at the best price. [/p][p][/p][p]I'm not set on this being the way the market works, and it might be that this is removed in future so all changes are instant. As is the case with the whole market, things may change. I'm also very open to feedback! I'd love to hear what people think about this. [/p][p][/p][h2]Design[/h2][p]I'm a lover of information-dense, extremely functional UI. In another life I'd be an accountant with my love of spreadsheets. The UI is pretty heavily influenced by those preferences, I focused on something that tries to be both extremely functional yet pretty at the same time. I really wanted the UI to be satisfying to use, whilst delivering the most information in as little clicks as possible without being too much. I'm pretty happy with it so far - though I've stared at it so long I'd love to hear what other people think![/p][p][/p][p]The goods in the game aren't completely set in stone, there's additional goods I wanted to add, and the organisation of them in the menu might change. There's some things that still need to be added (current balance, net profit, etc.), but I'll show those off in the buildings showcase coming soon (stay tuned).[/p][p]It's a pretty strong representation of what the final UI will look like though, and other UI elements will follow a similar style, of course adapting to feedback and testing as development goes along.[/p][p]The design for this is something that continues to evolve as new features need adding and values keep being added. It took some trial and error to build the UI in such a way that it would adapt to any screen size or scaling, yet still deliver everything in a space-efficient way. It's pretty adaptable now though, and I can add new goods easily and the UI will adjust accordingly.[/p][p]Audio is something that isn't yet finalised either, but there's clicky and satisfying effects that play when interacting with it. Sometimes these have been too clicky, so I'm still working on it. I'll discuss this further when I do a sound effects Development Showcase.[/p][p][/p][h2]Player Integration[/h2][p]In order for the UI to be truly dynamic, it of course has to link in with the player data! One good decision I made early on in development was to consider how this may play with multiplayer. [/p][p]I worked on building in Steam integration and learning the basics of GodotSteam. This was a great decision, as rather than tacking on multiplayer later, I can build elements of the game and know how it will work in a multiplayer setting. I'm still new to GodotSteam and have much to learn, so there may be some hiccups along the way. One thing after learning which I forgot to consider - multiplayer spawning - it's not something I thought about and took some more learning to properly understand but I'm getting there. I need to reshape how my game is organised in order to have what I need spawn across all players, but I'll think about that more later. For now, I just need something playable.[/p][p]One thing I did fully implement was player spawning. This means that now when starting a game, it initialises a player node and stores the Steam ID and Steam username of the player to that node. It then initialises an inventory for that player. It will do this for each player that joins the lobby.[/p][p][/p][p]I've built in integration so that the market can buy and sell based on player funds, as well as store inventory values and update the market UI client-side so that all of the information is shown live. It works very well and I'm extremely pleased with it. Building this for a singleplayer mode initially would probably have caused me to build it in a way that wouldn't translate very well when made for multiplayer.[/p][p][/p][p]That's me for this week, thanks for reading! I shall bring you more updates soon.[/p][p][/p][p]Ciao,[/p][p]Caleb[/p][p][/p][p][/p][p][dynamiclink][/dynamiclink][/p]