home home

downloads files

forum forum

docs docs

wiki wiki

faq faq

Cube & Cube 2 FORUM


python scripting support in cube

by pflanzenmörder on 01/17/2003 00:54, 38 messages, last message: 09/15/2003 17:00, 3858 views, last view: 05/18/2024 06:35

I\'m currently embedding python into cube.
At the moment I\'m embedding python into \"void monsteraction(dynent *m)\" so you can edit all monsterbehaviour in an external file without having to recompile the whole sourcecode.
I started it because I wanted to see if it works (and it does :-)) and to allow people to do develop there own AI and to play a bit with the whole stuff.
I\'ll continue to embed python into other parts of the sourcecode to allow easy playing with the engine without the need to recompile it.
So here are my questions:
1. What do you think about it?
2. Is there any detailed documentation about the map-format available?

I hope I will be able to release some Sourcecode as soon as I\'m done with my exams (which start next week)

P.S.: Thanks for the well structured sourcecode :-))))

   Board Index    Go to next 20 messagesGo to last 20 messages

#1: really? python?

by pushplay on 01/17/2003 02:59

Interesting. I would have thought that lisp would be the more natural choice between your desire for AI and the syntax of current commands. Not that I'm saying python is a bad choice, I know nothing about it.

reply to this message

#2: ..

by Thalion on 01/17/2003 06:38

Python is nice indeed. Would be also great to add item scripting as well (so we can easily modify weapons pickups etc without recompiling Cube). In other words, if it comes to that, provide a complete replacement for QuakeC at least...

But one thing disturbes me here:

"If you add to the cube source code, you fork the code and it becomes your own project, do not ask for me to integrate your changes into the main branch, no matter how brilliant they are."

Considering this, is it worth forking?

reply to this message

#3: Re: ..

by Al_Capone on 01/17/2003 07:48, refers to #2

"Is it worth forking?"

Hell yes its worth forking, DO IT !!! How you think Cube was made ? It was created by Aard forking it into a engine.

reply to this message

#4: Re: really? python?

by Al_Capone on 01/17/2003 07:54, refers to #1

"Not that I'm saying python is a bad choice, I know nothing about it."

You should, Python is an extreamly powerfull programming language, just look on my link page and see for yourself :) http://mysite.iptic.com/virtualblender/Links/Links2.html

reply to this message

#5: Re: ..

by Aardappel on 01/17/2003 10:41, refers to #3

eh? I never forked anything

reply to this message

#6: umm...

by Aardappel on 01/17/2003 10:46

1. well, it looks like a bit overkill, it's more like adding cube support to python, as the latter is over an order of magnitude bigger :) I would personally think a smaller, more elegant language like Lua would work better... or why not use the build-in scripting language? it's not great but certainly enough for your purpose.

2. no there isn't... it is not recommended you mess with it, but if you have to the only documentation is in worldio.cpp, the load & save routines.

reply to this message

#7: ..

by pflanzenmörder on 01/17/2003 11:21

There will never be a language everyone will be satisfied with. Python is my choice of language because I like it, people can choose if the like to do the programming in a structured or in an OOP way. It's also easy embeddable and there is a big community. There have been several great improvements in the speed of the interpreter over the last releases.
My aim is to provide a facillity that will make it much more easy to create total conversions.
As soon as I got some time I will set up a page for my little project to show what it all will be about, currently I'm doing some tests on the performance of the embedded pythoncode.

reply to this message

#8: Lua!

by Thalion on 01/17/2003 15:50

Okay, so you've convinced me. =)

Hm. I really like Lua more than Python. Python is quite huge, and with all those libs... Lua, on other hand, is designed to be embedded scripted language. And its syntax is, IMO, somewhat cleaner.

I did something like this before - embedded Lua scripting into Quake2, for advanced map effects.

One more thing. I think that speed of various scripting solutions should be compared, to decide which one to use. After all, in 3D gamemaking, speed is what really matters.

reply to this message

#9: Re: Lua!

by Aardappel on 01/17/2003 18:43, refers to #8

Lua is the fastest of the dynamically typed scripting languages (it is easily twice as fast as python in many test) but is still very slow as a language in general... don't expect to do computationally expensive stuff in any scripting language (running some script for every monster in a map every frame quickly adds up).

reply to this message

#10: ..

by Thalion on 01/18/2003 00:14

Hm. I've been thinking exactly of this - running a script for every moster... =)

There are workarounds, of course. First of all, no need to run each frame. Might as well use 1/10 sec ticks, as QuakeC did. Also, every monster (as well as other entities) may have an associated flag which tells whether we have some associated code to run periodically or not. Thus, only those monsters that must be scripted (and only when they must be scripted) use CPU time.

reply to this message

#11: stuff

by spentron@PP on 01/18/2003 00:40

I'm actually seeing slowdown at times from the standard monster code on my machine.

BTW, do the monsters run at 50 Hz like the player or different? Is it assured that the monsters behave mostly the same relative to the player regardless of performance?

reply to this message

#12: don't look at the subject

by SysteM_H on 01/20/2003 03:32

COOL! I can't wait for this kind of monster/item scripting in cube... I really couldn't care what language it's in. being able to do this stuff without compiling the source is gonna be like heaven. I hope it all works out.

reply to this message

#13: Re: stuff

by Aardappel on 01/20/2003 11:17, refers to #11

monsters and players use the same physics, but monsters are less accurate and cpu intensive (the main player is given very accurate physics to enhance smoothness). They all run atleast at 50hz, or more if your fps is more. Yes this can hurt machines with slow cpu's.

reply to this message

#14: Re: #13: Re: stuff

by spentron@home on 01/22/2003 03:36

Do monsters not awakened yet affect things if not visible to the player? Any "rule of thumb" on maxes you suggest?

reply to this message

#15: Re: #13: Re: stuff

by Aardappel on 01/22/2003 11:05, refers to #14

asleep monsters hardly cost any cpu time, except for the occasional line-of-sight check. The cpu time spent on monsters is roughly proportional to the amount of awake monsters. So on a slow cpu don't try to speedrun a map with many monsters :)

reply to this message

#16: They are shooting at me!!

by pflanzenmörder on 01/24/2003 00:53

Yeah, I did it.
All monster related functions are accessible via python.
I just rewrote nearly the whole AI using python.
After I'm finished with AI and cleaned up my code a bit I will make available the whole sourcecode.
But currently the whole stuff will only run on linux as I don't have any experience with Visual C. Anybody out there who wants to aid me??

reply to this message

#17: Re: They are shooting at me!!

by pushplay on 01/24/2003 03:23, refers to #16

Can't you get the OpenGL headers for mingw?

reply to this message

#18: ..

by Thalion on 01/24/2003 04:50

The code might as well be portable enough to just recompile it with VC. Just put it on-line, and we shall see =)

reply to this message

#19: ..

by pflanzenmörder on 01/24/2003 10:52

It's not the code that I'm worrying about (that should work without any changes on windows), it's adjusting the projectfiles.
I'll post it as soon as I'm finished with my tests.

reply to this message

#20: ..

by Thalion on 01/24/2003 14:31

Won't just adding all your new *.cpp to Aard's VC project and linking to Python libs be enough?

reply to this message

   Board Index    Go to next 20 messagesGo to last 20 messages


Unvalidated accounts can only reply to the 'Permanent Threads' section!


content by Aardappel & eihrul © 2001-2024
website by SleepwalkR © 2001-2024
54037183 visitors requested 71817305 pages
page created in 0.015 seconds using 9 queries
hosted by Boost Digital