Currently Online

Latest Posts

Topic: ai cheat sheets

king_of_nowhere
Avatar
Topic Opener
Joined: 2014-09-15, 17:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2014-09-30, 22:11

I've heard that there are ways to give bonuses to the ai. like, all ai soldiers start with a few promotions, or ai get some extra resources at fixxed intervals in their headquarters, or such. As the ai normally is far too weak for my tastes, I would like to use those options. Only, I have no idea how to activate them. Can anyone explain how it's done? thanks


Top Quote
wl-zocker

Joined: 2011-12-30, 16:37
Posts: 495
Ranking
Tribe Member
Location: Germany
Posted at: 2014-10-01, 09:30

I do not think that something like that exists and can be activated. You will have to write that yourself. Probably the easiest way is by lua scripting inside a map's directory. This works only for this one map and fixed tribes (with some effort, that can be changed). You need an init.lua file that gives the players a headquarters and that adds resources to their headquarters (that is the easiest thing). To get an idea what it has to look like, take a look at the maps that are playable as a scenario (Green Plateau, Trident of Fire, those in "MP scenarios" and the campaigns). The Trident of Fire contains the code for the choice of the tribes.

In the end, it should look like this:

include "scripting/coroutine.lua"
-- and the other includes, copy from somewhere

game=wl.Game()
map=game.map

function init_players()
prefilled_buildings(game.players[i], "headquarters", map.player_slots[i].x, map.player_slots[i].y, wares = ...
-- and so on, copy from the sc00 file in tribes/name/scripting
-- note that you use the tribes from the editor, which is Barbarians for all
-- i goes from 1 to the maximum number of players

end

function give_resources()
   f_i = map:get_field(map.players_slots[i].x,map.player_slots[i].y)
   -- repeat this for all i from 2 on
   -- this assumes you are player 1
   while true do
      if f_i.immovable and f_i.immovable.descr_name = "headquarters" then
         hq = f_i.immovable
         hq:set_wares("log", hp:get_wares("log" )+10)
         -- log should be the name for all tribes. For other wares, you have to check for the tribe
      end
      -- repeat the above for all i from 2 on
      sleep(60*1000) -- intervall lenght in milliseconds
   end
end

run(init_players)
run(give_resources)

This is not tested, but something along these lines should work. Unfortunally, I have no idea how to get the maximum player number, but since you have to copy this in every map you would like to test, you can easily adjust the number.

EDIT: And of course, you have to load the map as a scenario.

Edited: 2014-10-01, 09:51

"Only few people know how much one has to know in order to know how little one knows." - Werner Heisenberg

Top Quote
DragonAtma
Avatar
Joined: 2014-09-14, 00:54
Posts: 351
Ranking
Tribe Member
Posted at: 2014-10-01, 12:05

Alternately, start a 3+ forces game and put all the AIs on the same team. Suddenly, it's not so easy...

Putting everyone on Citadel Village instead of Headquarters seems to help, as the AI is more likely to build new troops.

Edited: 2014-10-01, 12:06

Top Quote
king_of_nowhere
Avatar
Topic Opener
Joined: 2014-09-15, 17:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2014-10-01, 15:35

thanks wl-zocker, my understanding of programming is virtually zero but i'll see if i can manage.

DragonAtma wrote:

Alternately, start a 3+ forces game and put all the AIs on the same team. Suddenly, it's not so easy...

Putting everyone on Citadel Village instead of Headquarters seems to help, as the AI is more likely to build new troops.

I already play 1v7 giving the ai the citadel start, and i still win with little effort. problem is promotions, i can promote my troops much faster and much better than the ai, so my soldiers can kill the ai ones wiith very little losses. plus, ai is not good at managing a long term economy. even if there are no military engagements, after 6-8 hours I generally have more military power than all the ai combined. See for example: map ice wars, me versus 7 defensive ai with citadel start. after 9 hours, my military power is 3330, best ai is 770, worst ai still alive is 550. I killed 290 soldiers and i lost 8. I should play against humans to find good challenges, but i like to play longer games and build up a lot, and my experience with internet players is that if the game last longer than one hour - two at most - someone will get bored and quit. Giving huge boosts to ai is the only thing i can do.


Top Quote
Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-10-01, 19:54

If you are linux user you can compile and test tibor-ai5 branch, would you?

I would like to have some feedback.


Top Quote
king_of_nowhere
Avatar
Topic Opener
Joined: 2014-09-15, 17:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2014-10-03, 22:29

Tibor wrote:

If you are linux user you can compile and test tibor-ai5 branch, would you?

I would like to have some feedback.

sorry, i use windows. my brother tried to convert me several times, but i gave up for good when i was doing my master thesis and some graph functions weren't exported correctly between windows (university pc) and linux.


Top Quote
Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-10-03, 23:05

face-smile.png

It might sound a paradox, but to compile the widelands on linux is 100x easier then compile on windows...

From time to time some volunteer recompiles the tibor-ai5 branch for windows and make it avaiable, but nowadays I commit new versions quite frequently so linux would be best for testing..


Top Quote
PkK

Joined: 2012-01-06, 11:19
Posts: 236
Ranking
Widelands-Forum-Junkie
Posted at: 2014-10-04, 17:27

king_of_nowhere wrote:

I've heard that there are ways to give bonuses to the ai. like, all ai soldiers start with a few promotions, or ai get some extra resources at fixxed intervals in their headquarters, or such. As the ai normally is far too weak for my tastes, I would like to use those options. Only, I have no idea how to activate them. Can anyone explain how it's done? thanks

See here for an example: https://wl.widelands.org/forum/topic/1489/

Philipp


Top Quote
Ex-Member
Avatar
Joined: 2014-09-12, 09:53
Posts: 184
Ranking
Widelands-Forum-Junkie
Posted at: 2014-10-05, 09:38

The line

soldiers = { [{0,0,0,0}] = 35,

sets the number of soldiers, in this case 35, the soldier description is a array that contains the level for hitpoints, attack, defense and evade (in this order). So you can increase the number of starting soldiers and they can all have a promotion if you wish. If you have more than one building that contains soldiers, such as in the citadel village script you can set different promotions for each set, or leave them at 0,0,0,0 of course.


Top Quote