dumb.js: a simple PSO based AI that stronger than bonecrusher

Did you create a mod, map, music, or a tool? Present them here and earn feedback!
Note: addon requests do not belong here.
Note, everything uploaded to this forum, MUST have a license!
wanjia1
Trained
Trained
Posts: 43
Joined: 01 Nov 2023, 06:05

dumb.js: a simple PSO based AI that stronger than bonecrusher

Post by wanjia1 »

It a AI based on PSO algorithm,and it can defeat any insane AI in 15 minutes,only in NTW T1 Fullbase.
It can also defeat 3 insane nullbot or 5 insane nexus in NTW maps.
It only have 255 lines of code.

It have no explicit tactic code,but simply cluster droids when attacked.
It have no memory.everything has to be calculated every step.
Its droid templates is hard-coded, it use cannons exclusive, and don't build factories or AAs.
Attachments
dumb.zip
(18.62 KiB) Downloaded 201 times
wanjia1
Trained
Trained
Posts: 43
Joined: 01 Nov 2023, 06:05

Re: dumb.js: a simple PSO based AI that stronger than bonecrusher

Post by wanjia1 »

license:CC0
screenshot (AI attached player vs insane bonecrusher):
Attachments
Screenshot_2023-12-02_10-46-02.jpg
wanjia1
Trained
Trained
Posts: 43
Joined: 01 Nov 2023, 06:05

Re: dumb.js: a simple PSO based AI that stronger than bonecrusher

Post by wanjia1 »

bugfix:
now the AI can build defense structure,laser satellite and AAs.This make it competent for T4 games.
it can defeat any hard AI in 45 minutes,in any NTW Fullbase game.
Attachments
dumb.zip
(19.2 KiB) Downloaded 162 times
wanjia1
Trained
Trained
Posts: 43
Joined: 01 Nov 2023, 06:05

Re: dumb.js: a simple PSO based AI that stronger than bonecrusher

Post by wanjia1 »

bugfix:
now the AI can build VTOL and oil derricks. its performance in ntw Nobase | Lowbase 1v1 game is above hard bonecrusher and below hard cobra.
also,it will build modules for structures.
it still fails on low oil map (even weaker than nexus). because all truck will move to a structure that being built and unable to get oils.
there is 497 lines of code in total.
Attachments
dumb.zip
(5.91 KiB) Downloaded 130 times
wanjia1
Trained
Trained
Posts: 43
Joined: 01 Nov 2023, 06:05

Re: dumb.js: a simple PSO based AI that stronger than bonecrusher

Post by wanjia1 »

better verion, not completed:

dumb-flamer: a full flamer made from dumb. have 120 lines of code, used to test bots. only works in NTW 1v1, can beat Insane Cobra in T1.

dumb12: new version of dumb. Its ONLY WORKS IN RO-1v1(or SnowTiny) and MUST PLACED IN NORTH.
It can beat Insane RatBot 0.9, Cobra, Bonecrusher, and average human player, in 12 minutes in T1
- attack when have more than 75 units
- make AA defense when attacked by VTOL
- VTOLs will attack enemy

they were coded in rush and have many bug

version for Ng-RO1v1Spec, because Its waypoints is hard-coded, also must placed in north.
dumb12a.zip
(6.59 KiB) Downloaded 140 times
to avoid overwrite, make sure older version of dumb.zip have been removed
Attachments
dumb12.zip
(6.59 KiB) Downloaded 125 times
dumb-flamer.zip
(2.5 KiB) Downloaded 116 times
wanjia1
Trained
Trained
Posts: 43
Joined: 01 Nov 2023, 06:05

Re: dumb.js: a simple PSO based AI that stronger than bonecrusher

Post by wanjia1 »

dumb10b.zip: a plasma cannon variant made from dumb10. can beat all previous dumb bot (except dumb12a) and cobra.
Attachments
dumb10b.zip
v2, also uses EMP cannon and HPV cannon, uses light body and have higher flamer ratio
(6.19 KiB) Downloaded 123 times
dumb10b.zip
v1
(6.04 KiB) Downloaded 121 times
Last edited by wanjia1 on 17 Mar 2024, 14:12, edited 5 times in total.
wanjia1
Trained
Trained
Posts: 43
Joined: 01 Nov 2023, 06:05

Re: dumb.js: a simple PSO based AI that stronger than bonecrusher

Post by wanjia1 »

dumb10b rushed by dumb12a
Attachments
Screenshot_2024-03-17_19-36-09.jpg
wanjia1
Trained
Trained
Posts: 43
Joined: 01 Nov 2023, 06:05

Re: dumb.js: a simple PSO based AI that stronger than bonecrusher

Post by wanjia1 »

Units now move in patrol mode, compare to dumb10,
it slight stronger against AIs, but weaker against humans.
still weaker than dumb12a, because it still can't cover retreating units.

Add chat commands:
say "w" to show all droids
say "r" to show `safeDest`
say "r1" to research Plasma Cannon and EMP cannon
say "r2" to research VTOL

also, split code into 9 files, which make it easier to read(?)
Attachments
dumb-src.zip
source file
(72.44 KiB) Downloaded 110 times
dumb11.zip
(11.81 KiB) Downloaded 110 times
wanjia1
Trained
Trained
Posts: 43
Joined: 01 Nov 2023, 06:05

Re: dumb.js: a simple PSO based AI that stronger than bonecrusher

Post by wanjia1 »

dumb20: dumb with memory
(removed recycle, AA and VTOL support, too complex and rarely used)

only works in T1, 1v1, >24 oils

It use schmitt trigger to control defence or attack.
Input variable:
Name Range Description
enemyDistance (24, 36) to repair centre
limitRatio (.5, .8) countDroid(DROID_ANY,me)/getDroidLimit(me)
repairRatio (.1, .5) ratio of droids that health<40
When enemyDistance<24 || (limitRatio>.8 && repairRatio<.1), it will attack enemy with most droids.

Better droid control:
health>80: rush into enemy
health<80 && health>40: hit and run
health<40: return to repair

It can rush all insane built-in AI in 12 minutes with K/D>8:
Time K/D
SemperFi 11 minutes 313/35
Cobra 10 minutes 357/26
Bonecrusher 8 minutes 212/13
Nullbot 7 minutes 133/0

It can beat previous dumb-bot(about 80% chance), usually with needle gun:
Time(average) Win
dumb5 32 minutes 6/7
dumb10 30 minutes 12/15
dumb12a 31 minutes 8/11

It weak against flamers:
Time(average) Win
dumb10-flamer 8 minutes 1/5

Against other bots:
Time K/D
Ratbot(Insane) 10 minutes 266/39
Attachments
dumb20.zip
(9.36 KiB) Downloaded 128 times
wanjia1
Trained
Trained
Posts: 43
Joined: 01 Nov 2023, 06:05

Re: dumb.js: a simple PSO based AI that stronger than bonecrusher

Post by wanjia1 »

dumb21: rocket varient of dumb20
can beat all insane AI previous, includes dumb20, in 18 minutes.
it can also beat insane dumb10-flamer in 25 minutes.
Attachments
dumb21.zip
(12.77 KiB) Downloaded 97 times
wanjia1
Trained
Trained
Posts: 43
Joined: 01 Nov 2023, 06:05

Re: dumb.js: a simple PSO based AI that stronger than bonecrusher

Post by wanjia1 »

dumb22: Integration of 5 weapon lines, Better micro and unit counting (still for 40 oils T1 1v1)
to select weapon, chat s[0-4]:
s0: MG(default)
s1: Cannon
s2: Rocket
s3: Mortar
s4: Flamer
or sett last digit of name (in challenge file):
"player_2":{
"name":"dumb22-1",
"ai": "multiplay/skirmish/dumb22.js",
"difficulty": "Medium",
"position":1,
"team":1
}

it will also attack when have 1.35x or more units
when start at T2 or higher, if enemy product VTOLs, it will build AA tank about 1/3 amount of enemy VTOL
it can even beat insane Cobra and Bonecrusher in easy difficulty, with MG or Cannon
dumb22.zip
license: CC0
(16.74 KiB) Downloaded 126 times
Attachments
(yellow is win, test by 5 games)
(yellow is win, test by 5 games)
dumb22.py1.png (18.44 KiB) Viewed 3170 times
wanjia1
Trained
Trained
Posts: 43
Joined: 01 Nov 2023, 06:05

Re: dumb.js: a simple PSO based AI that stronger than bonecrusher

Post by wanjia1 »

analyse shows, for cannon game against previous version, dumb22's weapon use rate is about 130% of enemy,
by Lanchester's laws, it can destroy enemy of sqrt(1.3) (about 114%) size:


map: 3c-Ng-RO1v1Spec

x: 1 second / pixel, 60 seconds / grid
y: 1 unit / pixel, 50 units / grid

up(normal): reloading unit count
up(pale): action==DACTION_MOVEFIRE(17) unit count

down(normal): unit count
down(pale): health count (e.g. unit with 30% health counts as 0.3)

green: dumb22-1(cannon)
blue: Cobra(cannon with MG)
0-12 min
0-12 min
dumb22-cobra.png (20.29 KiB) Viewed 3041 times
green: dumb22-1(cannon)
blue: dumb20(cannon)
6-18 min
6-18 min
dumb22-dumb20.png (24.66 KiB) Viewed 3041 times
User avatar
Tzeentch
Trained
Trained
Posts: 324
Joined: 14 Oct 2012, 14:24

Re: dumb.js: a simple PSO based AI that stronger than bonecrusher

Post by Tzeentch »

May I ask, what is the purpose behind creating and developing this AI bot?
Do you have an end goal as to the use cases for players?

As I see you started this in December 2023, so it has been around 6 months now of work.

The other AIs do need some work, but some are reasonably kind of good.
wanjia1
Trained
Trained
Posts: 43
Joined: 01 Nov 2023, 06:05

Re: dumb.js: a simple PSO based AI that stronger than bonecrusher

Post by wanjia1 »

The purpose is to create a AI that better than all previous bots and most players, at all case (current it only works at 40 oil map)
The use case is NTW 1v1 bot, currently
The final target is to reach the theoretically optimal (100% weapon usage, 0 unit loss, shortest truck path)

Compare to other bots, it have high improve rate:
for every version, it can beat all previous normal bot (it can beat all built-in insane bot at NTW 1v1 since dumb5)
for every major version, it can beat all previous insane bot

Other bots have higher coupling between modules, and hard to be improve without side effects
User avatar
Tzeentch
Trained
Trained
Posts: 324
Joined: 14 Oct 2012, 14:24

Re: dumb.js: a simple PSO based AI that stronger than bonecrusher

Post by Tzeentch »

Many other scenarios to think about, it isn't easy to achieve. ( think VTOL, Hover or Cyborg only games too ) Or having constrained building room etc.

When I looked across all historic forum posts I have seen some great ideas implemented across some AIs that weren't introduced to the game ultimately.
Ideally what we will need is all the AIs to be roughly equitable in skill level across each difficulty setting. I have been working on this in the background...

Many times I have seen the common trap of, let's make this one time only best unbeatable AI ever, for it to then be dropped or forgotten about.
Post Reply