Forum

> > CS2D > Mods > New Bot System - Testing Version Released
Forums overviewCS2D overview Mods overviewLog in to reply

English New Bot System - Testing Version Released

89 replies
Page
To the start Previous 1 2 3 4 5 Next To the start

old Re: New Bot System - Testing Version Released

Zeik
User Off Offline

Quote
@user Dousea: It's true... I'll look for a solution now

But it's not so bad... you're not supposed to call new on an object. It would be a very rare mistake.

EDIT: You could create a copy of the Bot class and set its new key to nil, but you have to create that copy function by yourself...

EDIT2: Just realized there's a better solution, just add
1
new = 0
as an instance attribute.
edited 1×, last 20.06.17 08:36:51 pm

old Re: New Bot System - Testing Version Released

Hador
User Off Offline

Quote
user Starkkz has written
@user Pagyra: What would be actually fun is to train bots based on player actions via neural networks.


I have been thinking about solving the bot problem with ML for some time now and have discovered two main possibilities:
1. For a neural network to be trained on human actions you would need craploads of data. Basically, with current player numbers you would need to collect all data of all players playing on standard maps (mods and scripts could break the neural network), and still you would only have a bit that is average at best (but imagine the fun coding that).

2. Discard the neural network and let the bot figure it out all by itself with reinforcement learning. This would require setting out goals to learn one thing at a time do training would take a long time, but doesn't rely on player data.

This is however both rather utopian (think of the computation time involved, even the guys at Google DeepMind would groan), and, to my knowledge, beyond the current capabilities of Machine Learning.

In short: using ML to train bots is unrealistic but trying to could be fun, if you ask me

old Re: New Bot System - Testing Version Released

_Yank
User Off Offline

Quote
@user Hador: I've also planned to do something like that some time ago! I even started writing a player recording script (prior to the analyzing and learning process) however due to the lack of time and maybe, motivation, I halted the project. I may give it a look again in a distant future.. I've also thought about discarding the neural network and let the bot decide what to do with training but then I realized that there's a limited amount resources (performance wise) and that it would take a lot of time to make it comparable or superior to CS2D's current A.I.

By the way, why do you think that human training wouldn't work ? It wouldn't need to be a "fully neural network" system. You could just write a partial/hybrid one, creating a default A.I. and improving it with human data.
Starting with an empty dataset for each server, as players would play on the server, their gameplay data (their behavior) at the various different times and parts of the map would be inserted into the dataset and analyzed. This process would determine if that data would be something to avoid or try imitate.

@user Dousea: Your project seems promising! I'd love to use your A.I. on my servers! But, by the way, are you planning to make them be able to deal with buildings (for example, destroying an enemy turret wisely or heading back to dispensers when HP is depleted)
edited 3×, last 20.06.17 09:16:29 pm

old Re: New Bot System - Testing Version Released

Dousea
User Off Offline

Quote
@user Starkkz: I don't use repositories too often because well internet in here is bad.. real bad if you ask me. Another factor is I always change my code everytime I have time, and it's real tiring if I need to update it at that time.. but I'll look into it.
@user _Yank: Of course! It's part of the plans. Thanks for the kind words. It motivated me well.

I decided to use OOP with middleclass. It's fast but slow at class creations. But don't worry, I'll try my best as possible to avoid constant class creations on run-time. Currently class creations only happen when starting a server. For behavior tree, I use this but slightly modified for my using. Here's the code (real code) for the bots' behavior:
...
	self.behavior = Sequence{
		Bot.buy,
		Bot.look,
		Selector{
			Sequence{
				Bot.findTarget,
				Bot.hasTarget,
				Bot.isTargetValid,
				Bot.isTargetInRange,
				Selector{
					Sequence{
						Bot.isInFreeline,
						Bot.isTargetOnCorrectAngle,
						Bot.attack
					},
					Bot.huntWhenNotInFreeline
				}
			},
			Selector{
				Selector{
					Sequence{
						Bot.isBombDefuseScenario,
						Bot.hasBomb,
						Bot.inBombPlantingArea,
						Bot.plantBomb
					}
				},
				Selector{
					Sequence{
						Bot.isBombDefuseScenario,
						Bot.isBombPlanted,
						Bot.goToBombPlantingArea
					}
				},
				Sequence{
					Bot.isBombDefuseScenario,
					Bot.hasBomb,
					Bot.goToBombPlantingArea
				}
			}
		}
	}
...

It's still ugly and need some enhancements but it does its job. Currently it's doing good. But why only "good"? Because every second bot would stutter in a frame, so it's slighty unnoticable. I'll get down to it and see what's wrong with the implementation of the behavior tree.

Also buying is also up. It follows CS2D buying system but with a bit of spice poured to it. I reordered the buying steps to: equipment -> primary slot -> grenades -> secondary slot -> ammos -> switch weapon. It respects both cs2d lua cmd game's "bot_weapons" and "bot_skill". Highly skilled bots would always grenades, never buy secondary slot, and switch to knife at startround. Contrawise for the lowly skilled bots. Any ideas regarding to this area so the bots could be smarter at buying weapons?

old Re: New Bot System - Testing Version Released

Starkkz
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module("ClassName")

ClassName = {}
ClassName.__index = ClassName

function ClassName:new(arg1, arg2, etc)
	
	local self = setmetatable( {}, ClassName )
	
	return self
	
end

function ClassName:getTer()
	return self.ter
end

function ClassName:setTer(ter)
	self.ter = ter
end

return ClassName

This is the simplest method I've used to create object oriented in Lua, so that I don't have to rely on libraries for that.

old Re: New Bot System - Testing Version Released

Dousea
User Off Offline

Quote
@user Starkkz: Thanks for the code but I already know how to create class-looking tables, but for the sake of simplicity and credibility for people that already the libraries for that particular area, I use a library. It doesn't really hurt, does it? It does its job wonderfully so I could focus more on the surface (AI stuff). Also my code would be prettier to see.

old Re: New Bot System - Testing Version Released

GeoB99
Moderator Off Offline

Quote
I totally agree the current AI system is not so consistent. Not saying that I blame user DC for it, indeed developing an AI system is hard however there are some flaws in the bot's behaviour which I find it just weird.

For the behaviour tree, you could create a list of main categories based on a handful of cases and situations such as Fight & Engage, Surviving, Communication and Teamwork, Understanding of a 2D Environment and Orientation and Decision Making.

For teamwork I was thinking about cooperation and fulfillness of objectives on Bomb & Plant mode. If a bot carries the bomb and plants it, other terrorist bots should hold the point of the bomb plant and counter-terrorist bots should cover the bot who's defusing the bomb. At the current AI system once the bot sees the bomb and defuses it, there's a 50% chance that the other bot, when he sees it, will going to defuse it too instead of protecting the bot who's already defusing the bomb

old Re: New Bot System - Testing Version Released

Dousea
User Off Offline

Quote
@user Mora: Absolutely. It's part of the plans after all. (shit I didn't notice your post, my bad)

@user GeoB99: Sure, but it takes time to create a "tree" because there're a lot of cases that could happen in this game. And I'm aware of that problem and want to address that in the near future.

Also,
user Dousea has written
Any ideas regarding to this area so the bots could be smarter at buying weapons?
edited 1×, last 22.06.17 01:18:03 am

old Re: New Bot System - Testing Version Released

TimeQuesT
User Off Offline

Quote
Calculate the average money a team owns and let bots buy from classified sets. While a bot with good aim and motivation will buy a devastating rifle, a lower skilled bot might tend to buy MP's. Also the choice of buying kevlar on low money should depend on the bots skill.

You can also add some chance to make a high motivated bot to disfollow logical buying to simulate its feeling of superiority - might causing fatal outcome in teamplay.

Since, programming a bot to drop a weapon for a teammate (and making it pick the weapon up) is extra work, you might consider making it just transfer the money - causing the teammate to buy the weapon on it's own (of course for AI only!). : This situation is triggered whenever a bot is far away from average team money.

old Re: New Bot System - Testing Version Released

Dousea
User Off Offline

Quote
Finally the sound system is up! Thanks to user TimeQuesT for his beloved sound library, it really helps a lot. Don't worry, these sounds aren't classes, rather I use local table for a slight faster access:
...
local sounds = {}
...
function Sound.emit(...)
	sounds[#sounds + 1] = {...}
end
...

Sounds will be emitted on various occassions and weapon modes are taken into account. The maths done for the volumes and the likes are still kinda primitives but we could work on those later. Sounds are flushed every 100 ms. And after testing, sounds that were created by 2 bots were around 10 sounds (only moving) every 100 ms. From that we can assume that there'd be ~5 sounds each frame that'd be processed by a single bot. I'll dig more into it later on.

Now the tree is huge and I'm still far away from completion. I kinda worry about performance if the tree is this huge. You can see the tree inside the spoiler.
Spoiler >

There're problems here and there as well, but I'll fix them ASAP.

old Re: New Bot System - Testing Version Released

Avo
User Off Offline

Quote
user Starkkz has written
you should open a repository and work on there.

It could be helpful (for you) yet educational (for others).

user Dousea has written
I don't use repositories too often because well internet in here is bad.. real bad if you ask me. Another factor is I always change my code everytime I have time, and it's real tiring if I need to update it at that time.. but I'll look into it.

Well, you don't have to commit everyday.
---
Quote
Do something with the npc too, make them a bit like the bots.
Programming universal AI would make it ineffective. I mean, it's better to design dedicated (designed to play defusal maps for example) AI instead of general-purpose one.

old Re: New Bot System - Testing Version Released

Dousea
User Off Offline

Quote
@user Avo: Yeah, I've been thinking about that lately. I guess I need to host it after all, huh? But I don't know how to use repository's capability to its fullest.. so I'll try to make it really simple.

old Re: New Bot System - Testing Version Released

Dousea
User Off Offline

Quote
@user Avo: Sure. Will put my hands on it later.

Hiding spots system is up! This mod would load the spots file of the map, and if it doesn't find one, it fails to continue. Everytime a bot moves to another tile, it scans the entire hiding spots in the map for the spots that are within the virtual screen of the bot (850x480 px). Bots will aim the hiding spots accordingly. Click on the spoiler for our current behavior tree.
Spoiler >

There are 2 severe problems that occured during testing. First, the way of finding hiding spot to cover when panic (basically when health below 50) was weird because the bots weren't going to cover but they were going FOR their targets. Second, after a few rounds played, some bots stopped moving while the rest played, but the rest played the game weirdly. I'll have to fix them right away.
To the start Previous 1 2 3 4 5 Next To the start
Log in to reply Mods overviewCS2D overviewForums overview