Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compilation ok (0 errors)
#1
What's the level of interest for something like this?:

[Image: CBotInclude.png?dl=1]
Path defaults to ai/ but also uses %cat%, %chap%, and %lvl%
codes, plus two others for the players program folders.

It uses current working directory if Colobot is not there.

Includes error codes, #pragma once, and some foolproofing.

It works exactly like CBotToken::CompileTokens() + file input.

Has it's own class with a simple interface, changes to the game are minimal.
#2
https://github.com/colobot/colobot/issues/238
I wanted to wait for CBot refactoring with this, as we may have a better idea on how to use functions from multiple files in CBot. Doing this now makes no sense as the editor doesn't support opening multiple files at once.
#3
To be honest, I don't like the idea of #include in CBot. CBot already supports public functions and classes, which provides pretty much the same needed functionality and can be easily extended in the future. There were discussion in the past about possibility of adding "program libraries" to some buildings for storage, so other robots can access functions and classes defined in them. #include would just duplicate a lot of code.
"After three days without programming, life becomes meaningless."
~The Tao of Programming
#4
Quote: a better idea on how to use functions from multiple files
That sounds interesting.


Yeah, a real editor that handles multiple files would be nice.
I'm using an external editor with line numbers, code navigation, and search.

The character limit was my main motivation here, 700 or so lines just aren't enough.
Loading 10 programs into the bot works, but they have to be compiled in a certain order.

I'm having so much fun with my huge code battle program, I just had to tell somebody.
#5
If you want larger programs, it's a lot easier to just change the constant that defines that limit Wink
#6
From the other hand, such program may won't work with official builds. Anyway, we'll have to manage something, Code Battles will have quite big files (imagine all these programs after a few years, when more and more complex AI will be implemented there) and 700 lines for whole program might be quickly a serious limit.
Spoiler :
[Image: unknown.png]
#7
The limit is actually 20000 characters or 1000 lines
#8
The last time I hit the character limit at 701 lines, the editor
cut off at 20637, which I thought was strange, I knew it was set to 20000.

It made my LevelController script look like crap when I had to
strip out comments, tabs, and LF, just to finish it.
It also forced me to do some DRY clean up, so that was good.
I wanted to do more but LevelController command takes only one script, as far as I can tell.

Other motivations were:
- code re-use.
- cleaning-up the program folder.
- writing large programs that are easy to navigate.
- random bugs when using the game's editor.(might be fixed already)
- virtually no limit to program length.
- just to see if the game would accept a large program.

- it was becoming impossible to improve my code battle program.
    fix or improve one part of code(recompile 10 programs).
    add a function, works good, start a new codebattle,
    <error> <error> <error> <error> <error> <error>.

After my first failed(& ignorant) attempt at #include,
the second version, written from scratch, is way better.
I've been using it for more than a month already.

Anyway, I'm not trying to promote the idea, I'm just communicating.
#9
Program length limit should be removed. Static limit is not a good thing. There's no theoretical limit defined in CBot itself so the editor and CBot compiler should be able to process big files if necessary. Still, very large programs are not a good idea.
"After three days without programming, life becomes meaningless."
~The Tao of Programming
#10
For reference, my codebattle program + shooter program are currently 46kb, & 9719 tokens.
I broke it into separate programs to be organized and avoid editor bugs(probably fixed already).

That comes with the strict limitation of only referencing functions and classes
compiled previously in program storage, in other words:

If I wanted to share my codebattle program, I'd have to number the files
and provide stupid instructions on how to make sure it works.

This puts your main program at the bottom of program storage.(a minor inconvenience)

I suspect that most codebattle programs wouldn't reach 80kb, including mine.


Forum Jump:


Users browsing this thread: 1 Guest(s)