2 registered members (AndrewAMD, alibaba),
1,426
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Converting a script from c-script, having problems
#289019
09/10/09 01:55
09/10/09 01:55
|
Joined: Sep 2008
Posts: 68
Tai
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2008
Posts: 68
|
Since I dislike the way that A* uses a grid-like system, I decided to use Perfect AI's algorithm (with modifications). However, since it's not written in Lite-C, I decided to do some converting. Curiously, the definition of the array, written like...
define max_nodes 300; // maximum number of nodes that can be used in this demo
define max_arrays 90000; // 300 x 300 (max_nodes * max_nodes)
Gave me the first errors. So I rewrote the variables like...
void max_nodes [300]; // maximum number of nodes that can be used in this demo
void max_arrays [90000]; // 300 x 300 (max_nodes * max_nodes)
This worked, but it gave me an error right away with this section
var node_to_player[max_nodes]; // distance from the node to the player
So I searched the forums and found that sometimes [] doesn't work, so I switched to (max_nodes). This worked, and I got all the way down to this.
index = j + i * (number_of_nodes + 1); // compute the correct index in the array
if (node_to_node(index) == 0) // if these nodes can't see each other
{
node_to_node(index) = 999999; // set a huge distance for the nodes that can't see each other
}
I changed the [index] to (index), but now the line setting it to 999999 gives me a syntax error no matter what? What am I doing wrong with converting this code? Any ideas regarding this would be nice. PS. I'm posting a lot of topics atm; sorry for the inconvience.
|
|
|
Re: Converting a script from c-script, having problems
[Re: Tai]
#289021
09/10/09 02:12
09/10/09 02:12
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
afaik i already translated it to lite-c.
also
define max_nodes 300; // maximum number of nodes that can be used in this demo define max_arrays 90000; // 300 x 300 (max_nodes * max_nodes)
would be
var max_nodes=300; // maximum number of nodes that can be used in this demo var max_arrays=90000; // 300 x 300 (max_nodes * max_nodes)
not the one you did.
3333333333
|
|
|
Re: Converting a script from c-script, having problems
[Re: Quad]
#289023
09/10/09 02:16
09/10/09 02:16
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
Actually the equivalent would be:
#define max_nodes 300
#define max_arrays 90000
Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: Converting a script from c-script, having problems
[Re: JibbSmart]
#289024
09/10/09 02:20
09/10/09 02:20
|
Joined: Sep 2008
Posts: 68
Tai
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2008
Posts: 68
|
Well that's interesting. I'll take a search of the forum for your conversion Quadraxas!
Unless you didn't release it :S
EDIT: Found it, thanks! Also I'm seriously off my game today, posting two useless threads. :S
Last edited by Tai; 09/10/09 02:22.
|
|
|
Re: Converting a script from c-script, having problems
[Re: Tai]
#289025
09/10/09 02:39
09/10/09 02:39
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
What don't you like about A*?
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: Converting a script from c-script, having problems
[Re: Tai]
#289028
09/10/09 02:59
09/10/09 02:59
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
Trust me, that depends on your implementation I'm making an RTS, and if I relied on a regular grid for the nodes I'd be in serious trouble (just too many nodes to consider on that scale; too slow). I have a dynamic node system where visibility between nodes is recalculated whenever a building/obstacle is created or destroyed, and each obstacle has nodes attached to its corners so that the nodes always mark out the best path. Each node knows its children and the cost of getting there. It's a bit more effort, though! Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: Converting a script from c-script, having problems
[Re: Tai]
#289030
09/10/09 03:03
09/10/09 03:03
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
Fair enough. Just out of curiosity, what type of game is it?
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
|