Follow by Email

Friday, 26 December 2014

Development Blog #0005 - Exploration and WLNewmanBrainBasic

I spent this week upgrading the AI in Wool, this Rust simulator.


Recap

Last week we saw a video of newmans building bases, and ignoring each other.  They would move randomly until they happened across a resource, and subsequently gather it.  After gathering enough wood for a base, they would spend about 60s of simulated time building their wood shack, then set out again for more resources.  When enough had been gathered for wood weapons, wood armor (aka burlap), and wood tools, they would head straight back to their base, and craft it.  This was repeated until they had built T2, and a bugg kicked in and prevented them from moving on to T3 (metal base & accessories).

This Week

It was a rushed job to get base building included in last week's blog post.  Clearly, the AI needed some tender love and care.  Newmans now craft bases and accessories up to and including T3 (metal).  They now attack each other if it is worth the risk.  They respawn at their own base if they die, or respawn on the beach if they are homeless.

Improvements
After debugging last week's code, I started on improvements.  I created an exploration system.  So, instead of newmans randomly moving and bumping into resources, newmans look around in a 100m radius, and move toward their desired resource.  Pretty simple improvement, but newmans were immediately devouring the forests as soon as the game started -- which is great.  A lot of combat happens in the precious first hour, and it is cool to watch.
But then I did better.  Instead of moving randomly until a desired resource is spotted, a newman will systematically explore a region of the map.  The region is either the area immediately around them, or the area around their base.  This improvement caused newmans to actively search the map in pursuit of their desires.  It's a huge milestone because it marks the end of random movement.  That is, every decision became deliberate.  The newmans got scary powerful.

Issues
There was a minor issue with this though, as often one would see many newmans headed to the same invisible location, without any a priori reason.  It didn't look authentic.  So, I added noise to each of the locations, scattering the exploration points.  The scary newmans became individuals.


Scary WLNewmanBrainBasic

The Future


The goal of this project is to determine whether or not My Ideal Progression System is really all that great -- and if it isn't, come up with a better one.  I mapped out the future of this project this week.  It's going to take at least another month to produce some good looking, accurate, and understandable graphs out of this simulator.  I can't wait for that.  With enough support and feedback from the community, I'm set to see this through to the indefinite end -- so please leave me a comment :)

As for the next steps, it's pretty obvious there are too many bases scattered around, and no one is taking advantage of it.  It actually reminds me of how experimental plays right now, considering it takes 3 + people to (maybe) breach a tier 1 base.  It sucks.  So, I'm going to code the raiding system.

Raiding System
The plan is to give defending newmans a 20% bonus chance to win a fight.  They will have the option to sally out (open the doors and dare the invader inside) or to wait it out until the attacker breaches the walls.  Once the walls are breached, the defender will retain his advantage given his bunkered position and knowledge of his home.  However, the defender absolutely must fight once the walls are breached.  Upon successfully raiding a home, the raider will claim ownership, and must repair the base in order prevent other newmans from re-claiming it.  It will cost a hefty fee in tools to breach a base.  I've decided it should work this way, or mass raiding would take place.  It should be a bit risky raiding a base -- one should expect a profit (maybe) less than half the time -- with zero information about the base.  However, if a newman watches a base, and estimates the amount of resources inside based on the frequency of their enemie's visits, profitable raids will be attained.

Of course, after raids are in place, the AI will be next.  I'll include multiple base building as well as resource storing in the AI update.  Should be super cool to see newmans raiding each other.  It will cause a greater spread in the base distribution too, as no one wants to be close to a high level base :)
Later, I'll add an online / offline system to simulate player's limited ability to play Rust.  After that, I'll finally move away from WLNewmanBrainBasic, and move into something like WLNewmanBrainDecent.  It will be an overhaul of the AI system -- trying to come as close to a human rust player as I can. Soon as that is complete, I should be able to log some data, and process it in Matlab.

Food For Thought
I'm still on the fence about animals and food gathering.  On one side, it's super easy to gather animals to eat, far easier than it is to even build the first tier wood shack.  On the otherside, would this really be an accurate Rust simulator without food and starvation?  I guess that depends on whether or not starvation would be a significant factor in the survival of a newman.  When I look at my own plays of Rust, I absolutely never die of starvation.  It's just one more errand to run while I'm out gathering wood and stone.  However, it does usually force me toward a forest.  As I said, I'm on the fence.

Is food and starvation important? (for this simulator)

Friday, 19 December 2014

Development Blog #0004 - Huge Weekly Update

After a week of developing Wool, here's what it looks like:

What am I looking at?
This is an overhead view of a scale model of Rust.  

What do these symbols represent?
Each square represent 20 meters of in game distance.  
The white circles are players (newmans).  
If a white circle has a +, this indicates they have weapons of the coloured tier:
{Brown(wood) is 1, Gray(stone) is 2, and Orange(metal) is 3}.
A black square is a base, it will have a square filling if it is upgraded.
Dark green squares are trees.
Gray squares are stones.
Orange squares are metal.
Light Green squares are animals.

Here's a 5 minute video of the simulation over about 24 simulated hours



So how did you get here?
Well, after Saturday I went to work on making things look prettier.  So I upgraded how newmans look and are represented at the different tiers.  

Then I made combat work.  Combat happens when two newmans occupy the same 20m square, and declare they will attack.  The winner is determined at random.  A newman with better weapons and armor has a much better chance of winning any battle.  I let newmans with worse weapons have some chance of winning to account for times that players sneak up on each other, and land a few good blows.  I won't bore you with the details, I'll make a post about tuning the systems at a later date, and give you all the gory details.

Combat simulation test video



Cool, combat works.  Next came the respawn system.  After 10 seconds of being dead, a newman chooses a random spawn location from a specified list.

After the respawn system was implemented, the next clear direction to take was to recreate the spawn beach as seen in the current build of Rust.  I needed some way to mark a large number of locations as spawnable, and make that area look roughly like a beach.  I decided to come up with a map parsing system.
I really went all out with the map parsing system.  I can now take any map plan image and render a completed, textured, detailed, playable Wool map.  

Sample map plan

The parsing system then takes that map, analyses the colors, spawns resources, creates biome textures, and... 
V-wa-la

It'd be cool to make it look like this
But I've only so much time.

I'm so happy exams are over, I can just pour time into Wool, with the exception of my full time job as a mobile developer.
After getting the map parser in place, and looking nice, I focused my efforts on the crafting system.  Again, I won't bore you with the details, but just know that newmans can craft food, weapons, armor, and tools up to and including tier 3 (Orange metal).
With crafting working, I got the base system up and running, just in time for this post.  For a ton of wood, or stone, or metal, a newman will base himself.
The AI
In order to get newmans to build bases,  I had to give them some meager intelligence.  Thus WLNewmanBrainBasic was born.  It follows a strict goal priority list:
@[goal_attack_prey, goal_craft_all, goal_base, goal_gather_resources]
First, it will attempt to attack anyone on its square if the prey is significantly weaker that it.  Then it will attempt to craft tools, weapons and armor.  However, in order to craft any weapons, a newman must be inside his base.  Thus, failing to craft, the newman will goal_base, and do all required things needed to build a base.  Once the base is completed, crafting happens, then upgrading the base, until the highest tier weapons and armor are had.  Then it will just wander.

Cool, what's next?
I'll be updating this blog every friday, in union with the devblog update.
Next up, I figure the AI could use some love.  I'll make them hunt the resources they need instead of just randomly bumping into the resources, and then gathering.  This should allow me to tweak the amount of resources required for everything, so that the timeline for newmans falls more in line with my ideal rust progression system.
After that, I'll implement the raiding system.  That will be fun.

Please follow by email (box at the top of the page) if you're interested in seeing me complete this!
I read all the comments on both Reddit and Blogger, so don't be shy!




Saturday, 13 December 2014

Development Blog #0003 - Optimization

After scaling the simulation up to Rust's standard 4000mx4000m map, and adding 100 newmans, things slowed down a lot.  I re-did the visualization system.

Watch 100 newmans eat away at a full size map.  The map is 200 tiles across, where each tile is 20m.




Blue - newmans
Brown - trees
Gray - stone
Orange - metal
Yellow - animal


Great, they can eat the map now.  I'm going to invest a bit of time into making this look a bit prettier, so I can see when one square has both wood, stone, and a newman on it. 

After that, I'll implement the combat system.  Like the rest of the simulation, I'll do my best to estimate the value of weapons and armor, then calculate a newman's chance of winning a fight.  It's going to be pretty cool to see newmans eat eachother too.

After combat, I'll create the respawn system for newmans.  I'm choosing to go with the current build's spawning system, placing the newmans on the beach.  Wait, I don't have a beach yet!

After spawning is implemented, I'll make the map spawn look a lot like the current build.  It should be recognizable.  I'll also add background tiles to make it look like a proper model of Rust.


I'd love to make things look just like this:


But it's probably going to look more like this:



I'm not sure which direction I'll take from there.  I could do crafting, leading into base building, or I could do some simple AI - where the newmans would pick targets, and pursue a path to them.

When crafting and base building is in place, I should be dedicating all of my time to the AI.  That's going to be the hard part.  Luckily, I'm a computer science undergraduate with a high interest in AI, so we'll see if I can come up with a newman brain that models the average player accurately.

Friday, 12 December 2014

Development Blog #0002 - Resource Gathering

Resources can now be gathered by newmans.


The newman in the video is just using T0 gathering equipment (ie. the starting rock).
It will take him:
30s - 1 tree (15 wood)
60s - 1 stone (30 stone)
90s - 1 metal (45 metal)

So that works.  How about 16000km^2, and 100 newmans? (Actual Rust map size)


Damn, that's slow.  I'll have to upgrade the display system.

I can't wait till they attack each other.

A note about the resource spawning:
Resources respawn somewhere in the same biome after an hour of being depleted.
I chose these settings so that one is only really tempted to gather wood.  After T1 tools are crafted, things become faster to gather.
Some stats taken from the source code, in case you're interested in calculating the times for each resource. 

//============================================================================
//| Resources
//============================================================================

#define WLResource_amount_wood 15
#define WLResource_amount_stone 30
#define WLResource_amount_metal 45
#define WLResource_amount_animal 15

//360 = 1H
#define WLResource_respawn_wood 360
#define WLResource_respawn_stone 360
#define WLResource_respawn_metal 360
#define WLResource_respawn_animal 360

//============================================================================
//| Gathering Tiers
//============================================================================
#define WLTool_rate_T0 5
#define WLTool_rate_T1 8
#define WLTool_rate_T2 15
#define WLTool_rate_T3 15

Tuesday, 9 December 2014

Development Blog #0001 - WLNewmanBrainRandom

Having spent about 4 hours upgrading the resource spawning code to include rudimentary biomes, here's what the simulation looks like:

Brown - Wood
Gray - Stone
Orange - Metal
Yellow - animal
Blue - newman

With another 2 hours work, I implemented the A.I. interface -- something that will let me choose a type of AI for each newman.  Also, I coded the vision system, so the newmans have limited knowledge of the map.  WLNewmanBrainRandom is the file name of the first AI to function in Wool.  It's not smart.  It chooses a random direction to walk in at each time step, and soon will gather resources.




Next steps - I'll be upgrading WLNewmanBrainRandom to pick up resources, which will allow me to test the resource respawn system, and stress test the map with lots of newmans.
After that -  I'll be too tempted not to implement the combat system, a fairly simple dice game where newmans get bonuses to their win chance with higher tier weapons and armor.  I can't wait to see the mayhem unfold at that point.

Some details you might like to know about the simulation
- each icon represent a space of 20 meters.
- I estimate it would take about 10s to jog that distance in Rust, thus each turn takes place over that long.
- I've designed the game engine to allow for high-speed simulation.  This should allow me to generate lots of data for good looking graphs.  Graphs I'll be interested in looking at include time alive vs. number of players, average time alive, average weapon tier.  My aim is to tweak things so that the average time alive is about 2 hours, with a large deviation.

How do you clean Rust?

With (steel) Wool.

I'm building a Rust simulator.  Check out rust at http://www.facepunchstudios.com/
 
It will have AI players running around.
You can watch an overhead view of the map.
There will be programmer art.
There will not be dick.

Why?
To see if my ideal rust progression system would look like fun from above. See this post for what I'd like Rust to be: http://redd.it/2o1e72
 
How much is done?
I've spent about 8 hours on it. The designs are complete, the UI is in place. The random map generation is functional. I've a few things to do related to the map and display of it, then I'll start on the AI, and produce some cool videos of my ideal Rust.

If there's an artist out there, I'd love to hear from you.