freeserf.net icon indicating copy to clipboard operation
freeserf.net copied to clipboard

[Announcement] Freeserf 2.0

Open Pyrdacor opened this issue 4 years ago • 17 comments

Freeserf.net has come to a quiet stable state now. There are some minor issues but overall it is in a pretty good shape. Around the 1st of June Freeserf.net 2.0 will be released. There won't be any big changes until then but maybe a few minor fixes and improvements.

After version 2.0 the focus will be fully on multiplayer implementation which is already started on a different branch. Freeserf.net 3.0 will then be the next big release which will fully support multiplayer games. The time schedule plans 3.0 for the year 2021 but we will see how things will go. The first test releases with multiplayer support should be out there in summer of 2020 hopefully.

Thanks for your interest and support.

Pyrdacor avatar May 11 '20 11:05 Pyrdacor

Freeserf 2.0 has been released just yet. Mainly I fixed some user experience issues like click position detection, road building issues minimap click detection and so on.

Hope you enjoy it. Now multiplayer development will be the focus. But I will fix bugs of course as well. Stay tuned. :)

Pyrdacor avatar Jun 01 '20 17:06 Pyrdacor

Some sign of life. This project will continue but my focus lies on my Ambermoon rework at the moment.

Pyrdacor avatar Sep 16 '20 17:09 Pyrdacor

Nice to see you are still working on this! I am just wrapping up my initial Freeserf (C/C++) AI code. I am now going to compare your AI to mine and see if there is anything I can improve & steal :)

tlongstretch avatar Oct 29 '20 04:10 tlongstretch

@tlongstretch Hey good to hear from you again. Nice to see that you still work on this too. Yeah sure check out my AI logic. You can steal ideas if you want to. But maybe you can give me feedback as well like what I could improve or do in another way. You are kinda the only other freeserf AI developer. 😁 Keep up the good work.

Pyrdacor avatar Oct 29 '20 06:10 Pyrdacor

certainly! I am trying to submit my code to Freeserf C/C++ project, but if I don't hear back from them I'll fork it and continue from there. I'll keep you posted

tlongstretch avatar Oct 29 '20 16:10 tlongstretch

thought stream while I look over your code...

  • I like the LastChance idea for trying to save your castle when an enemy is near
  • I see you have also implemented the concept of linking related buildings, nice
  • When considering flags to connect a new road/flag to, it looks like you are checking the area around the new flag to be connected. I was doing this and saw it resulted in suboptimal connections for flags that were far from their target building. I ended up determining the halfway point between the new flag and the target building/flag, then checking a circle around that halfway point. This works better for faraway flags and results in no change in behavior for nearby connections.
  • I like your StupidDecisions & HardTimes method to creating adjustable AI intelligence
  • I see you have a stub 'AIStateAvoidCongestion'. This is a tough problem to solve. Rather than directly trying to resolve congestion I have added a few methods to hopefully prevent it. Right now these are: 1) a BuildBetterRoads function that tries building roads to improve connections between important linked buildings. 2) a SpiderWebRoads function that makes arbitrary connections between flags at certain distances outward from the castle (if it results in a significantly shorter connection between those two flags), thus changing a "star network" into something resembling a typical spiderweb. This works very well, but eventually results in road clutter as the game progresses. I need to make it stop after a certain number of connections, or once road density reaches some threshold.
  • I agree with your TODO of not placing large civ buildings near enemy borders. I have the same goal (not implemented yet)
  • also agree with avoiding building near farms/foresters
  • I see you are using get random spot for finding map positions, while I am using a spiral. Just an observation, I'm not sure if one is better than the other
  • your AI is "cheating" by using AmountInArea to find fish (and minerals?) :) Mine is only looking for large bodies of water and hills. I am thinking this could be something tied to difficulty. Have a hardest-level AI that "cheats" to varying degrees by accessing normally hidden knowledge about map resources and other player's resources
  • it looks like your AI remembers mined-resource signs forever and uses that knowledge. My AI is using the same way I do it myself... by placing the appropriate mine type on top of good locations to permanently mark them, but not actually connecting them until they are needed so they are not yet constructed
  • your FindStones function looks to only consider a stone pile as a single unit. Stone piles have varying amounts of stone, I am counting the pile amount and using the actual value
  • when finding a castle spot, I see your are avoiding hills, desert, etc. I was planning to do the same thing but as a lazy shortcut I ended up just checking for a minimum number of positions there are where a small/large (non-mine) building could be built and using that. It works well enough that I never bothered counting mountains/desert/water!
  • your AI is using AmountInArea of mined minerals when placing castle. I know the game has a geologist estimate to support this so it isn't cheating. I simply don't like using it (and my AI doesn't use it) because I prefer having to explore... and get lucky. I should add using it as a difficulty-related option for my AI though
  • your AI checks distance to enemies when building castle. I intend to do this also, and have it tied to character personality when I implement that. Aggressive AI builds close, Defensive AI builds far away
  • there is an original game "bug" where stonecutters cannot access a pile of stones that is up-left of a building. I am factoring this when counting stones because I try to only have one stonecutter and it was game-breaking when this condition existed
  • I think you are randomly checking for a spot with minimum number of a resource to determine if it is an acceptable building spot? I am sorting by areas that have the most of that resource. This only really matters during this beginning of the game, I was seeing the AI build lumberjacks in an area with a handful of trees when a dense forest existed nearby that was clearly a better location. Same for stonecutters

random questions

  • have you figured out how to deal with re-connecting disconnected road segments to the main road network? I know this is a gap in my AI logic. It hadn't come up much because I hadn't implemented attacking, but once attacks are made it will quickly result in this condition
  • do you have random issues with serf logjams? Or serfs not transporting? I see this in Freeserf C/C++
  • did you implement your own "find X on the map over Y distance" or are you using the original game's spiral function? I discovered that the game's spiral function only goes up to a certain distance (9 or 10? 295 positions) and I had to create a new one that goes further out
  • I see all the expected AI state/functions, but I don't understand how you are deciding when to call each one. Are you simply randomly choosing (maybe weighted by Character traits) and constantly doing this? I am using a fixed loop and ordered execution of AI states.
  • are you splitting roads (i.e. building a new flag on a road to make an optimal connection)? This is a large improvement when building a road network. Also, I am preferring shorter connections to existing roads over building new (longer) roads by negatively weighting "new road length" when calculating the best road option.

tlongstretch avatar Oct 31 '20 18:10 tlongstretch

  • it seems your AI is only creating a single lumberjack in the early game? This is a huge bottleneck on low resource starts! I am building two initially, and then one more as soon as bit of progress is made.
  • my AI favors building knight huts next to any nearby enemy borders, as this seems to the optimal strategy when an enemy player is near. This is something that I expect you'd tie Character personality
  • the freeserf.NET graphics are smoother than the C/C++ one, especially at high game speeds. It looks very nice! Maybe because you are using a different graphics library?
  • I don't see much geologist activity, I think you should be sending them more often
  • your AI always seems to have minimum knight occupation even when it has a good amount of idle knights in the castle. I have some reserve value of castle knights, and once there are enough idle knights I start incrementally increasing the occupation levels

tlongstretch avatar Oct 31 '20 19:10 tlongstretch

Some AI aspects are difficult to assess because of the character personality differences. For now my AI only plays what I consider to be the optimal strategy, and once I am satisfied I will try to implement character personalities. I think that some of the original AI character personality descriptions are unworkable, though. For example "likes to attack food buildings" is just silly. I may simply do aggressiveness and intelligence, where intelligence would be a mix of whether or not to implement certain optimizations, and the frequency of StupidDecisions like you have done.

tlongstretch avatar Oct 31 '20 19:10 tlongstretch

  • there is an original game "bug" where stonecutters cannot access a pile of stones that is up-left of a building. I am factoring this when counting stones because I try to only have one stonecutter and it was game-breaking when this condition existed

My AI burns the stonecutter hut if only stones are left that are up left of a building. It also does not count them as a valid stone spot in the first place.

  • have you figured out how to deal with re-connecting disconnected road segments to the main road network? I know this is a gap in my AI logic. It hadn't come up much because I hadn't implemented attacking, but once attacks are made it will quickly result in this condition

From time to time each flag is checked for connections to any inventory. If there is none, it looks for a valid flag to connect to. So this should be handled.

  • do you have random issues with serf logjams? Or serfs not transporting? I see this in Freeserf C/C++

I think I had but I did a lot of bugfixes in serf logic and might eliminated those issues. But I am not 100% sure. I remember seeing those issues in the C# version too.

  • did you implement your own "find X on the map over Y distance" or are you using the original game's spiral function? I discovered that the game's spiral function only goes up to a certain distance (9 or 10? 295 positions) and I had to create a new one that goes further out

I added some finding methods but I think they all use the spiral function at the end. Not sure what stuff I added. Would have to look but maybe you can do so as well.

  • I see all the expected AI state/functions, but I don't understand how you are deciding when to call each one. Are you simply randomly choosing (maybe weighted by Character traits) and constantly doing this? I am using a fixed loop and ordered execution of AI states.

It is a state machine. It starts with the Idle state and then dependent on some values and chances another state is picked and activated. From there other states may be activated. The idle state is always the fallback state. States can push other states to a state queue and they can remove themselves etc. With this system the AI is permanently in a state of action or deciding which state to enter next. Each state performs some logic then.

  • are you splitting roads (i.e. building a new flag on a road to make an optimal connection)? This is a large improvement when building a road network. Also, I am preferring shorter connections to existing roads over building new (longer) roads by negatively weighting "new road length" when calculating the best road option.

This is planned and I think there is a Todo comment regarding this. There are many things to improve the AI. Most stuff is noted in comments and the Issues.md file here on github: https://github.com/Pyrdacor/freeserf.net/blob/master/Issues.md

In the AI section the first point is exactly that. ;)

I focused on multiplayer support and left AI as it was as it was decent enough to have a bit fun. And now I spend most of my time with my other amiga game clone Ambermoon.net.

Pyrdacor avatar Oct 31 '20 22:10 Pyrdacor

  • it seems your AI is only creating a single lumberjack in the early game? This is a huge bottleneck on low resource starts! I am building two initially, and then one more as soon as bit of progress is made.

This is not intended. But I know there is a lot to improve.

  • my AI favors building knight huts next to any nearby enemy borders, as this seems to the optimal strategy when an enemy player is near. This is something that I expect you'd tie Character personality

The personality decides which military buildings are preferred. But this is poorly implemented yet.

  • the freeserf.NET graphics are smoother than the C/C++ one, especially at high game speeds. It looks very nice! Maybe because you are using a different graphics library?

I use Silk.NET which is a very nice and fast library. And drawing is performed with modern OpenGL techs like VAOs, VBOs and of course shaders. Rendering uses baselines for the z-ordering and draws many objects in one go. So this is much faster than going from tile to tile and render everything there in a loop.

  • I don't see much geologist activity, I think you should be sending them more often

Yeah I know. This has to be improved.

  • your AI always seems to have minimum knight occupation even when it has a good amount of idle knights in the castle. I have some reserve value of castle knights, and once there are enough idle knights I start incrementally increasing the occupation levels

The settings of castle kkights, occupation, etc isn't really used much I guess. This will be improved later.

Pyrdacor avatar Oct 31 '20 22:10 Pyrdacor

About personalities. I added them. And also "attacks food buildings" is implemented. I have some enums for preferred AttackTargets like "FoodProduction", "LowMilitary", etc and TargetPlayers like "Weakest" or "Random". Each personality has different values and attacking counts them in. Aggressiveness only influences how often a player attacks.

Pyrdacor avatar Oct 31 '20 22:10 Pyrdacor

Ah, yes, I hadn't seen your Issues page. I will look over it, and the code, and playtest a bit more

tlongstretch avatar Nov 01 '20 16:11 tlongstretch

FYI I posted my code here: https://github.com/tlongstretch/freeserf-with-AI-plus

tlongstretch avatar Dec 02 '20 04:12 tlongstretch

hah, it looks like the reason my Freeserf seems so slow is because I'm always building in Debug mode. I did a Release build and its way faster! I had no idea until now. I never thought much about it

tlongstretch avatar Dec 04 '20 02:12 tlongstretch

Glad to hear that your AI made good progress. I will have a look into it but at the moment I focus on another project of mine.

Thanks for sharing your AI.

Pyrdacor avatar Dec 05 '20 09:12 Pyrdacor

Hello Pyrdacor, there is now a Discord server for Freeserf projects: https://discord.gg/m4C9v9DEZK

JSettler avatar Dec 05 '20 13:12 JSettler

Thanks for that.

Pyrdacor avatar Dec 05 '20 14:12 Pyrdacor