Opened 12 years ago

Last modified 5 years ago

#1024 new enhancement

Load javascript files in subdirectories for AI's

Reported by: Jonathan Waller Owned by:
Priority: Nice to Have Milestone: Backlog
Component: Core engine Keywords: AI
Cc: Patch:

Description

It would be nice to have this so that as AIs grow the code can be made a bit tidier. Since current script loading orders are not defined loading order should not be an issue. Any directories with a '.' prefix should be ignored to prevent possible problems with version control software.

Change History (4)

comment:1 by agentx, 10 years ago

I support this, especially because it seems Atlas is doing this anyway. A filter would be nice like *.js, *.json to ignore readmes etc.

comment:2 by Teiresias, 9 years ago

If this ticket is implemented, I suggest to introduce a new API function (e.g. Engine.IncludeTree(...) or similar) and keep the current Engine.IncludeModule function (as-is) as well. Judging by my AI experiments, I see use cases for not loading all .js files:

  1. Namespaces. I keep a separate namespace declaration js file in each AI directory and so the directories have to be loaded top-down to produce the proper name space structure. This could be fixed with some conditionals but looks ugly and might affect documentation generators like JSDoc. Additionally, some sub-directories might need an explicit loading order.
  2. Tests & Utilities: I keep additional js files for Jasmine unit-tests in a sub-directory tree below the AI root dir (and more sub-directories for other tools), which are not supposed to be ever seen by the engine. If all js files of the AI directory tree were loaded into 0AD, all kinds of weird behavior and errors would occur.

comment:3 by agentx, 9 years ago

Am I right following whitelist proposal meets all requirements?

1) The engines loads first/if exists <botname>.js, where botname is taken from name in data.son.

2) data.json gets a new property named like 'folder', containing an ordered list, read array, of folders to load alphabetically with filter *.[json|js].

I think this is just a remix of existing functionality, might be easy to implement and supports a whole range of bot development configurations.

comment:4 by Itms, 5 years ago

Component: UI & SimulationCore engine
Note: See TracTickets for help on using tickets.