Modify physics -get rid of viscosi -underwater model

Need help testing contributed art or code or having trouble getting your newest additions into game compatible format? Confused by changes to data formats? Reading through source and wondering what the developers were thinking when they wrote something? Need "how-to" style guidance for messing with VS internals? This is probably the right forum.
Post Reply
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Modify physics -get rid of viscosi -underwater model

Post by klauss »

BEZ_BASHNI wrote:Eve online have 100% python engine....Only gfx functions are done in C++...
Eve online is online, hosted on a cluster of elastic scalable hosts. VS works on a single host, they player's computer. Not The Same.

Eve-online is also highly I/O bound (because of the online part), where python and other scripting languages shine.

Furthermore, we're not talking about highly optimized AI routines, we're talking about modder-friendly AI routines, probably far from optimal. If they were to be CPU-bound, which they are in VS, writing them in python makes them around 100 to 1000 times slower.

Given VS architecture, the issue is compounded. There is no multithreading, so when VS is running AI graphics and everything else freezes. This means AI has to run very very quickly to remain smooth, and it simply cannot do that in pure Python.

I've been thinking long about the issue. I too would like python or python-like AI scripts, but the current architecture does not allow it. It would need extensive refactoring.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
BEZ_BASHNI
Merchant
Merchant
Posts: 53
Joined: Wed Nov 16, 2011 7:00 pm

Re: Modify physics -get rid of viscosi -underwater model

Post by BEZ_BASHNI »

I was making python scripts to earn money in Eve long time ago and still have somewere it's decompiled source....
The physical model of the local 'room' in eve was computed inside client as well as the server - the gfx of missilers, lasers, turrets was totally on clients side....The model was a 'ballpark' -all objects treated as spheres... And python worked suprisingly fast...Python have fine multithreading libs wich works well...Ideally I see a separate AI script thread for each NPC unit in VS . In python it is possible to make humanlike behaior for NPC -so they will mine asteroids or transport cargo from station to station and in case of danger try to dock to nearby station...
pheonixstorm
Elite
Elite
Posts: 1567
Joined: Tue Jan 26, 2010 2:03 am

Re: Modify physics -get rid of viscosi -underwater model

Post by pheonixstorm »

If you still have that code let me know, would like to take a look at it :)

On the eve AI though.. its not a very complex AI system. Pick a target and attack. Calculate hit percentage adjusting for skills etc. Nothing as complex as the AI for say an RTS or some other flight sim.

I don't know if the client uses plain ol python or stackless, but I know the server side uses a lot of stackless python as well as C++ to run everything. See my stackless thread here. Need to keep digging see what else I can find.. wish I know if they ever let stacklessIO run free, that could be a nice item to poke at for a bit.

I think if we look at anything we may want to more look at X3:TC as it is closer to what we are creating (and would make a damn good mmo imo)

Anyway.. need to boot into xp tomorrow so I can tinker with the gravity patch and get the experimental branch uploaded to include the gravity and planetary flight. Something nice for people to play with for a few weeks while we get other things worked up.
Because of YOU Arbiter, MY kids? can't get enough gas. OR NIPPLE! How does that mkae you feeeel? ~ Halo
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Modify physics -get rid of viscosi -underwater model

Post by klauss »

Eve's client, IIRC, only simulates the immediate surroundings. VS has to simulate the entire system, and several other adjacent systems. Plus, VS has a lot more ships in a system (well, I'm not sure, I'm just judging from screenshots, I didn't play eve).

In any case, the biggest issue is VS architecture. It's not designed to handle slow AI. AI has to run in a snap for what I told already, so python and other interpreted languages are a poor fit.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
pheonixstorm
Elite
Elite
Posts: 1567
Joined: Tue Jan 26, 2010 2:03 am

Re: Modify physics -get rid of viscosi -underwater model

Post by pheonixstorm »

A C-like language such as NWScript or the script language used for Warzone2100 would work for AI. Though of the two we only have access to the latter, and the former would be the best overall choice as a complete python replacement.. damn you neverwinter nights... hmm.. wonder if I can still find any of the open source script compilers that was once posted on nwvault. That would give us a bit more of an idea of its internal workings. Oh well, enough daydreaming.

Since you havent played eve I will tell you this much, you can ram a pc or npc ship and the most you will do is knock it around. No damage from collisions. A lot of the objects in game you can fly through (which is down right annoying). When warping you can warp through pretty much any object. Planets, suns, stations... The most advanced part of the game is the server itself which has to break everything into grids and handle 40k players at one time as well as 5-50 npc ships per running mission. This doesn't include large player fleet battles that can reach (from what ive read) 500 v 500 pilots on each side.

Overall Eve is a fun addictive game. Download it and I will email a link for a 30 day trial. Let me know when you join up and I can run you around showing off the best and worst of eve so you can get an idea of the overall picture. From combat to mining. Who knows.. maybe you will get some ideas out of it. I still say X3:TC is and should be a closer cousin that we should spend time looking at though, but thats my opinion.
Because of YOU Arbiter, MY kids? can't get enough gas. OR NIPPLE! How does that mkae you feeeel? ~ Halo
BEZ_BASHNI
Merchant
Merchant
Posts: 53
Joined: Wed Nov 16, 2011 7:00 pm

Re: Modify physics -get rid of viscosi -underwater model

Post by BEZ_BASHNI »

Pythoin is not too much slower than C++ sometimes
the benchmark shows that calculating pidigits is almost the same C++ speed

http://shootout.alioth.debian.org/u32q/ ... s&lang=all

when it starts dealing with matrixes, random numbers and enumerations python can be 300 slower.
But you can find sometimes the python version not too much slower than C++ if look into alternatives....
But t programming in python 10 times faster than C...at least for me....
Simle logic and trigonometry required by AI is the area of python perfomance were we sacrify speed about 3-times comparing to c++ ,but get advantage in development time and flexability..

If we go back to Eve example - btw - heres some old commented source of it http://www.bez-bashni.com/EVEINT.rar - I really enjoued making python scripts for it : you have your game window opened -write a script - start it- and the unit in game moves...Something goes wrong - you stop the script - see logs -fix it and start again...No compilation - no restarts and reloads... As I remeber that times it was more fun making scripts than EVE ugly 'click and follow' gameplay.. My first character was banned, because I never noticed that the client sends the server the debug logs of the running scripts in case of error.. Then I fixed the mistake :) , and quickly become extremly reach in eve - more fun appeared hiding the income and buying extra chars with ingame currency.-but when I bought and tried most of eve toys it become really dull - I never login eve anymore...No arcade fun at all...
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Modify physics -get rid of viscosi -underwater model

Post by klauss »

BEZ_BASHNI wrote:Pythoin is not too much slower than C++ sometimes
the benchmark shows that calculating pidigits is almost the same C++ speed

http://shootout.alioth.debian.org/u32q/ ... s&lang=all
Let me pull you from your dream:

Code: Select all

from gmpy import mpz
from sys import argv
gmpy is Gnu's multiple precision library. It's written in C.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
BEZ_BASHNI
Merchant
Merchant
Posts: 53
Joined: Wed Nov 16, 2011 7:00 pm

Re: Modify physics -get rid of viscosi -underwater model

Post by BEZ_BASHNI »

C ++ uses libraries written in ASM..
So what?..Let me pull you out of your dream...C++ is slow-asm is fast...

The functions that translate python bytecode to machine code are C-built also...as well as interpretator itself..
travists
Expert Mercenary
Expert Mercenary
Posts: 893
Joined: Thu Jul 08, 2010 11:43 pm
Location: Sol III North American Continent

Re: Modify physics -get rid of viscosi -underwater model

Post by travists »

Well, I suppose if it's raw speed you want ignore command interpreters altogether and write it in pure machine language. Every compiling and interpreting step it goes through slows it down. Want to brush off your COBAL? Go older? Not sure of the speed, but most of what you can do in C you can do in Java, and Java is already cross platform. They are called python scripts for a reason: they need a secondary program to run them. As such they will always be slower than a "true" programing language.
BEZ_BASHNI
Merchant
Merchant
Posts: 53
Joined: Wed Nov 16, 2011 7:00 pm

Re: Modify physics -get rid of viscosi -underwater model

Post by BEZ_BASHNI »

The problem I see we really need python for high-level AI programming and it looks like AI python scripting was cuted out of vegastrike together with a console...
If you tell me that was done to make vegastrike faster I will not beleive it because as I look through the code I see everywhere (inside main cycle and subs ,called plenty times during the maincycle) the shit like this:
static bool draw_unit_on_chasecam =
XMLSupport::parse_bool( vs_config->getVariable( "graphics", "hud", "draw_unit_on_chasecam", "true" ) );

One call to parse something starts a stringsearch in file and eats more than 1000 instructions just for nothing...
pheonixstorm
Elite
Elite
Posts: 1567
Joined: Tue Jan 26, 2010 2:03 am

Re: Modify physics -get rid of viscosi -underwater model

Post by pheonixstorm »

that may have been due to bad coding rather than slow python. But on the debate is python easier to learn than c/c++.. well of the 3 I think pure C is the easiest. A programmer for warzone once said
C = speedy, C++ = mind mess
But, all of this moves us away from our primary problem; gravity. Lets save the eve stuff and AI issues for another thread ;)
Because of YOU Arbiter, MY kids? can't get enough gas. OR NIPPLE! How does that mkae you feeeel? ~ Halo
BEZ_BASHNI
Merchant
Merchant
Posts: 53
Joined: Wed Nov 16, 2011 7:00 pm

Re: Modify physics -get rid of viscosi -underwater model

Post by BEZ_BASHNI »

U're 100% right.
Gravity is there already. To enjoy gravity and send planets to the trajectories they supposed to move we need to switch off the speed limit. Tho keep VS playable without speed limit we need priori collision system which is also finished.(at least the math part) ..Now I need to integrate the collision system and play with AI. To modify AI I need python. Thats how we moved to python and AI from gravity:)
travists
Expert Mercenary
Expert Mercenary
Posts: 893
Joined: Thu Jul 08, 2010 11:43 pm
Location: Sol III North American Continent

Re: Modify physics -get rid of viscosi -underwater model

Post by travists »

Why is the speed limit a problem for planets? How many planets hare accelerated well past C? Collision detection is a good thing, and AI can benefit I'm sure, but how does the speed limit get in the way? If it is the thrusters firing to keep you within a ship's set speeds, just set the governors on the ship you want to play with to insane levels.
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Modify physics -get rid of viscosi -underwater model

Post by klauss »

BEZ_BASHNI wrote:C ++ uses libraries written in ASM..
So what?..Let me pull you out of your dream...C++ is slow-asm is fast...
Your dream is that you'll find equally optimized prebuilt libraries for game-level AI.
Try more realistic benchmarks, ones that use pure-python implementations, because it's most likely the AI you're wishing to implement in python will be pure-python as well.

You're preaching to the choir here. I'd also like python or any other high-level language for AIs. I've done quite a lot of python programming too. I've even written patches for Python itself. So I know its strengths and limitations. AI in VS is not its strength.
BEZ_BASHNI wrote:The functions that translate python bytecode to machine code are C-built also...as well as interpretator itself..
There are no such functions in CPython (usual python, the one VS uses). You're just assuming and speaking out of ignorance. Sorry if it comes out aggressive, but you are speaking about performance without knowledge.
Only pypy and unladen-swallow generate machine code, pypy is written in RPython btw, and unladen-swallow is pretty dead, but when alive used LLVM.
In any case, both pythons in discussion (CPython and stackless) only generate bytecode, no machine code.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Modify physics -get rid of viscosi -underwater model

Post by klauss »

BEZ_BASHNI wrote: static bool draw_unit_on_chasecam =
XMLSupport::parse_bool( vs_config->getVariable( "graphics", "hud", "draw_unit_on_chasecam", "true" ) );
Static initializers are only evaluated once, the first time the code hits that point.
It is a damn fast way of lazy initialization.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Modify physics -get rid of viscosi -underwater model

Post by klauss »

travists wrote:Why is the speed limit a problem for planets? How many planets hare accelerated well past C? Collision detection is a good thing, and AI can benefit I'm sure, but how does the speed limit get in the way? If it is the thrusters firing to keep you within a ship's set speeds, just set the governors on the ship you want to play with to insane levels.
He's talking about a significant unit speed cap put in place to make players able to dock with stations. Otherwise, the orbits resulted in stations moving too fast, or rather, accelerating too fast (to follow the elliptic orbit), and since ships did not orbit, they could not keep up.

With gravity in place, the limit would not be required, since ships would naturally follow the orbits. But it's a question mark whether we want gravity everywhere, because orbital maneuvering will simply put off most players.

The patch is there, it needs playtesting, and if it doesn't work with gravity all over the place, it needs a solution that enables synchronous orbits while maintaining the easy navigation VS currently has.

We've been discussing it with pheonixstorm here.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
travists
Expert Mercenary
Expert Mercenary
Posts: 893
Joined: Thu Jul 08, 2010 11:43 pm
Location: Sol III North American Continent

Re: Modify physics -get rid of viscosi -underwater model

Post by travists »

Makes sense now, let me think on this.
travists
Expert Mercenary
Expert Mercenary
Posts: 893
Joined: Thu Jul 08, 2010 11:43 pm
Location: Sol III North American Continent

Re: Modify physics -get rid of viscosi -underwater model

Post by travists »

Ok, As I understand it the ships' governors will render gravity mostly invisible except when docking right?

Can "Match Target Velocity" be co-opted, or a new command introduced to match orbit once a ship is within 500km or so? (Maybe "establish orbit here"?) Fires thrusters automatically in rapid succession then you are mostly in a situation where you just have to chase it down much like now. Similarly if an intercept course is easy enough to plot, a key binding to do that would work. In fact ASP should use this, not piloting you to where it is, but where it will be when you get there. When dropping you near a significant object it self corrects to place you in that orbit before disengaging. Only those that insist on flying without autopilot need worry about gravity, and they would likely get a kick out of orbital maneuvering. Also gives another use for turning your flight computer off: hit a parking orbit and kill correction to save on fuel while drifting and making repairs and what have you.
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Modify physics -get rid of viscosi -underwater model

Post by klauss »

travists wrote:Ok, As I understand it the ships' governors will render gravity mostly invisible except when docking right?

Can "Match Target Velocity" be co-opted, or a new command introduced to match orbit once a ship is within 500km or so?
I think it's already default that when you lock a station you match velocity to it.
I'm not sure though.

The problem with orbits is it involves acceleration, constant acceleration. Delta-V.

The problem with gravitational maneuvering is that it involves applying Delta-V to change from one frame of reference to the next. It takes a lot of energy and time to do it naively, and people don't want to spend that time.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Modify physics -get rid of viscosi -underwater model

Post by klauss »

travists wrote:When dropping you near a significant object it self corrects to place you in that orbit before disengaging. Only those that insist on flying without autopilot need worry about gravity, and they would likely get a kick out of orbital maneuvering. Also gives another use for turning your flight computer off: hit a parking orbit and kill correction to save on fuel while drifting and making repairs and what have you.
That's an interesting take on the matter. The problem still remains that with realistic physics, the Delta-V required to match frames takes a looong time to be applied. But, maybe, the autopilot could cheat.

Um...
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
travists
Expert Mercenary
Expert Mercenary
Posts: 893
Joined: Thu Jul 08, 2010 11:43 pm
Location: Sol III North American Continent

Re: Modify physics -get rid of viscosi -underwater model

Post by travists »

Delta = change
v = velocity or vector

The Delta-v of a ship's afterburners is quite large. Cheating autopilot? Only if necessary. Smart autopilot that points the most powerful thrusters where it needs the most powerful thrust? Why would it happen any way else?

(Just ignore, or have compensators, for the insane G loading!)
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Modify physics -get rid of viscosi -underwater model

Post by klauss »

But a realistic autopilot is not easy to code.

I can't remember who coded our neat, simple but effective autopilot. Shame on me, it was an important contribution. He could probably give us some insight on how hard would it be to create one that matches moving frames of reference :)
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
travists
Expert Mercenary
Expert Mercenary
Posts: 893
Joined: Thu Jul 08, 2010 11:43 pm
Location: Sol III North American Continent

Re: Modify physics -get rid of viscosi -underwater model

Post by travists »

I actually use this "burner drop" manually! Often when heavily loaded when autopilot drops off you are moving wrong to hit a jump point. Best way I have found to fix this is set the speed to zero, point your ship in the opposite direction of your drift and hit the afterburners. Of course, manually this must be done in several steps as judging what "opposite" is can be hard.

You posted on me! Quite understandable, nobody said it was easy just that new ideas were needed. What we need is a rocket scientist! Well, flight engineer or some such...
pheonixstorm
Elite
Elite
Posts: 1567
Joined: Tue Jan 26, 2010 2:03 am

Re: Modify physics -get rid of viscosi -underwater model

Post by pheonixstorm »

autopilot i dont know.. new radar and autodock feature though was breese. I think if we can modify the autodock routines to have the station "tractor the unit in for docking (say once they reach 2500 meters) it would help. Or as I stated before when the auto dock code was still getting worked on some hud display that would show the path to the docking port something like what was shown in the movie aliens when the dropship was planet bound. I think part of this is going to be a numbers game rather than creating some overly complex simulation.

Think you could be over thinking this one a bit klauss?

DING! lightbulb.. we already have something we can use once modfied. I can't remember the name, something to do with gun tracking I think. That could be a good start to attack the problem from aside from the math.
Because of YOU Arbiter, MY kids? can't get enough gas. OR NIPPLE! How does that mkae you feeeel? ~ Halo
BEZ_BASHNI
Merchant
Merchant
Posts: 53
Joined: Wed Nov 16, 2011 7:00 pm

Re: Modify physics -get rid of viscosi -underwater model

Post by BEZ_BASHNI »

Your dream is that you'll find equally optimized prebuilt libraries for game-level AI.
Try more realistic benchmarks, ones that use pure-python implementations, because it's most likely the AI you're wishing to implement in python will be pure-python as well.
What I need is math functions to do base trigonometric calcs -I used to beleive that python math is a prebuilt lib and works not bad...Unit iterator will be better to keep outside of the python also -at least to do some database -style requests to the VS units like give ID's of the non-friendly units in range Y, give id of nearest unit...Some manevering tactics is also better to keep outside pyhon ai...
Like in python calling Approach(unit,10) will give order to VS unit and unit will approach using VS engine functionality.
There are no such functions in CPython (usual python, the one VS uses)
After "uncompressing" pyc file into python namespace the interpretator jumps along the lines .im_func.func_code.co_code and converts bytecode to machinecode..That was the function I meant.
Post Reply