EDIT: A first test is now available below: https://www.lfs.net/forum/post/2114646#post2114646
Hello programmers.
There is a mod waiting for publishing, for the purpose of being "driven" by AI, but all it would actually do is drive along uncontrolled. But I don't really want to support such a bodge mod that bypasses all realism purely so it pulls away all by itself.
But I don't want to prevent something that could be fun so I've come up with a simple idea for just a few hours of work, to allow InSim to control a local car, in a very crude way. I've done a proof of concept and can now drive an AI car from an external program. Actually it disables the AI completely and you just set values, like Steer, throttle, brake, shift, etc.
EDIT: This is only for local AI. It would be far more complicated to do it from the server - that would require new multiplayer packets and I'm not getting into that.
EDIT2: To be clear, it can work for AI that are online, but the InSim must be connected to a local computer that has its own AI on it, and those are the only AI that can be controlled by this new simple packet.
I want to confirm if this could be useful.
It's just like this:
struct IS_AIC // AI Control
{
byte Size; // 8
byte Type; // ISP_AIC
byte ReqI; // 0
byte Zero;
byte PLID; // Unique ID of AI player to control
byte Input; // Select input value to set
word Value; // Value to set
};
// Input values from from CS_NUM in Inputs.h
// Special values
// 254 - reset all
// 255 - stop control
enum
{
CS_MSX,
CS_THROTTLE,
CS_BRAKE,
CS_CHUP,
CS_CHDN,
CS_IGNITION,
CS_EXTRALIGHT,
CS_HEADLIGHTS,
CS_SIREN,
CS_HORN,
CS_FLASH,
CS_CLUTCH,
CS_HANDBRAKE,
CS_INDICATORS,
CS_GEAR,
CS_LOOK,
CS_PITSPEED,
CS_TCDISABLE,
CS_FOGREAR,
CS_FOGFRONT,
CS_NUM
};
I think you might need some minimal feedback from the car, via a request info packet, and it could tell you some things like the lights and ignition status. I suppose you can get speed / position, etc from other packets like MCI? Or maybe you need something like an MCI for one car, which you can receive on request for a local AI, and maybe it has a little more date in it?
I want to keep it simple as I don't want this to go on more than this afternoon as I have other things that I am working on.
Hello programmers.
There is a mod waiting for publishing, for the purpose of being "driven" by AI, but all it would actually do is drive along uncontrolled. But I don't really want to support such a bodge mod that bypasses all realism purely so it pulls away all by itself.
But I don't want to prevent something that could be fun so I've come up with a simple idea for just a few hours of work, to allow InSim to control a local car, in a very crude way. I've done a proof of concept and can now drive an AI car from an external program. Actually it disables the AI completely and you just set values, like Steer, throttle, brake, shift, etc.
EDIT: This is only for local AI. It would be far more complicated to do it from the server - that would require new multiplayer packets and I'm not getting into that.
EDIT2: To be clear, it can work for AI that are online, but the InSim must be connected to a local computer that has its own AI on it, and those are the only AI that can be controlled by this new simple packet.
I want to confirm if this could be useful.
It's just like this:
struct IS_AIC // AI Control
{
byte Size; // 8
byte Type; // ISP_AIC
byte ReqI; // 0
byte Zero;
byte PLID; // Unique ID of AI player to control
byte Input; // Select input value to set
word Value; // Value to set
};
// Input values from from CS_NUM in Inputs.h
// Special values
// 254 - reset all
// 255 - stop control
enum
{
CS_MSX,
CS_THROTTLE,
CS_BRAKE,
CS_CHUP,
CS_CHDN,
CS_IGNITION,
CS_EXTRALIGHT,
CS_HEADLIGHTS,
CS_SIREN,
CS_HORN,
CS_FLASH,
CS_CLUTCH,
CS_HANDBRAKE,
CS_INDICATORS,
CS_GEAR,
CS_LOOK,
CS_PITSPEED,
CS_TCDISABLE,
CS_FOGREAR,
CS_FOGFRONT,
CS_NUM
};
I think you might need some minimal feedback from the car, via a request info packet, and it could tell you some things like the lights and ignition status. I suppose you can get speed / position, etc from other packets like MCI? Or maybe you need something like an MCI for one car, which you can receive on request for a local AI, and maybe it has a little more date in it?
I want to keep it simple as I don't want this to go on more than this afternoon as I have other things that I am working on.