Topic: LLM-backed AIs

carli2
Avatar
Topic Opener
Joined: 2023-08-17, 20:13 UTC+2.0
Posts: 42
OS: Linux
Version: git
Ranking
Pry about Widelands
Posted at: 2026-02-14, 21:40 UTC+1.0

Hi,

I have some experience with local running LLMs.

I would like to try a LLM-based widelands AI that gets an overview of all player stats as well as possible actions (e.g. build building X)

I worked on previous patches which improved AI capabilities in Widelands but they are all hardcoded algorithms to make decisions. What is missing was a fine-tuning of the weights.

Such an AI could also use the chat to tease the enemy :D

What are your ideas?


Top Quote
tothxa
Avatar
Joined: 2021-03-24, 12:44 UTC+1.0
Posts: 567
OS: antiX / Debian
Version: some new PR I'm testing
Ranking
One Elder of Players
Posted at: 2026-02-14, 22:32 UTC+1.0

We should certainly consider creating a fully neural network based AI player if we can. FTR the current AI also uses a very small neural net, but that requires way too much handholding from specialised code.

I'm less keen on human language LLM in the chat, both because I'm afraid that it would increase the hardware requirements too much, and because I doubt we can find one with clean, legally obtained training data with cleanly GPL compatible licence. In multiple languages.

Edited: 2026-02-14, 22:47 UTC+1.0

Top Quote
carli2
Avatar
Topic Opener
Joined: 2023-08-17, 20:13 UTC+2.0
Posts: 42
OS: Linux
Version: git
Ranking
Pry about Widelands
Posted at: 2026-02-15, 00:01 UTC+1.0

My favourite would be to register AI players as separate network clients, so they can run on suitable hardware.


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07 UTC+1.0
Posts: 2241
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2026-02-15, 10:43 UTC+1.0

I also think that going all-in on machine learning for the computer players would be great to have. However even the current state involved lots of effort on the code side and lots and lots of contributor time to oversee the human-guided training sessions. We'd have to come up with a concept for a fully autonomous self-supervised AI training mode, in addition to the actual major changes to the 14000+ lines of existing AI code. So an absolutely worthwhile thing in my opinion, but which will also require enormous effort.

-1 for making AIs network clients, because we absolutely don't want to force players to connect to some server to play Widelands. Playing offline must never be penalised compared to playing online.
Also -1 for chat LLMs, because of 1) hardware requirements for an unnecessary piece of eye candy, 2) personally I find chatty computer players annoying, and 3) like all commonly available generative ML models the elsewhere discussed ethical and legal problems.


Top Quote
carli2
Avatar
Topic Opener
Joined: 2023-08-17, 20:13 UTC+2.0
Posts: 42
OS: Linux
Version: git
Ranking
Pry about Widelands
Posted at: 2026-02-15, 14:52 UTC+1.0

So to keep my effort in comparison to merge chances balanced: What's the desired/mergeable way to do it?

a) network-AIs (if someone dosen't want to use it, he would just not pick it!, requires either a local AI or a cloud server to connect to) with minimal engine code

b) internal pytorch- or tensorflow based fully local implementation on GPU base (runs locally, can train from replays) - both libraries have C++ bindings for executing the model. The training would be based on python code.

I would keep the "normal AI" as-is and introduce 1-2 new modes (a and b)

Edited: 2026-02-15, 14:52 UTC+1.0

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07 UTC+1.0
Posts: 2241
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2026-02-15, 15:55 UTC+1.0

Just my thoughts:

If we use a local AI for Widelands, we would/should not need a very large model. I.e. we could use a small model that can run in realtime on a typical CPU with a runtime performance not worse than the current computer players. That way we would be able to provide this locally to every user without raising our (currently very lenient) hardware requirements1, which is the best possible outcome.

We could use pytorch or tensorflow as they also support CPU-based inference2.
Using python for training is fine; our regression test suite runner is also written in python, so some interfaces to run Widelands programatically already exist.

We'll probably need to train a model from scratch just for Widelands though, unless there's a guaranteed-ethical pretrained model that would fit for our use-case.

If this works out, then in the long run it might ideally replace the existing computer players. Our computer player interface is modular so it is trivial to add new modes alongside the existing ones. The real work Widelands-side would be to define and provide an interface that the ML model can use: It will at least need to be able to query game state (map fields, map objects and their details, player statistics, global statistics, …), and have interfaces to send each type of player command, and should be automatically extensible so it won't panic when new features are added or the internal command syntax is changed.


  1. I think a lot of players also use Widelands on older hardware, which is a plus point for Widelands, so we absolutely should not require a modern GPU. 

  2. For example, the experimental IRC moderator bot runs a local classifier on CPU to assess several types of toxicity for each post made on IRC or in the metaserver lobby. The 3rd-party model we use was trained on a dataset of public Twitter posts. 


Top Quote
carli2
Avatar
Topic Opener
Joined: 2023-08-17, 20:13 UTC+2.0
Posts: 42
OS: Linux
Version: git
Ranking
Pry about Widelands
Posted at: 2026-02-16, 01:47 UTC+1.0

In the moment, I am working on a "correct" AI algorithm and dropped the LLM idea for now.

The idea: Priority inheritence!

Capabilities of the new AI mode ("Planning AI"):

  • hard objective fixation: play for points? AI will collect wares. Endless game? AI will expand peacefully before it starts attacking. Destroy other players? The AI will hit your warehouses first.
  • wood and stone clearing
  • microing the production site input priorities
  • dismantling buildings if the space is needed for military
  • plan ahead of future ware needs
  • solving bottlenecks and readjusting the economy throughput
Edited: 2026-02-16, 01:48 UTC+1.0

1
Top Quote