Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,203 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
use of multidimensional arrays for finding closest entity #213439
06/27/08 22:02
06/27/08 22:02
Joined: May 2006
Posts: 90
England
TigerTao Offline OP
Junior Member
TigerTao  Offline OP
Junior Member

Joined: May 2006
Posts: 90
England
EDIT*

I am trying to find the minimum value of an array of enemy distances compared to each enemy that calls the function. I have been able to succesfuly store the distances but I am having trouble setting my.min_distance to the minimal value in the array.

The array ignores values of 0;

Here is the array code that deals with 4 enemies:

Code:
function find_min()
{
	if (my.l < 4)
	{
		if(E2E[my.pos*4 + my.l] < 300  && E2E[my.pos*4 + my.l] != 0)
		{
			if(my.min_distance == 0)
			{
				my.min_distance = E2E[my.pos*4 + my.l];
			}
			else
			{
				if(E2E[my.pos*4 + my.l] < my.min_distance )
				{
					my.min_distance = E2E[my.pos*4 + my.l];	
				}
			}
		}				
		my.l += 1;
	}
	if(my.l >= 4){my.l = 0;}
}



No worries. Got it sorted. Seemed I needed a switch type value to kick off for the first value that wasnt 0 to make itself the first minimal value.

Code:

function find_min()
{
	if (my.l < 4)
	{
		if(E2E[my.pos*4 + my.l] > 0  && my.first_value == 0)
		{
			my.temp_value = E2E[my.pos*4 + my.l];
			my.first_value = 1;
		}
		if(E2E[my.pos*4 + my.l] > 0  && my.first_value == 1)
		{
			if(E2E[my.pos*4 + my.l] < my.temp_value)
			{
				my.temp_value = E2E[my.pos*4 + my.l];	
			}
		}
		if(my.l == 3  && my.first_value == 1)
		{
			my.min_distance = my.temp_value;
		}
		my.l += 1;
	}
	if(my.l >= 4){my.l = 0;my.first_value = 0;}
}





Last edited by TigerTao; 06/29/08 01:25.
Re: use of multidimensional arrays for finding closest entity [Re: TigerTao] #214899
07/08/08 02:49
07/08/08 02:49
Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Nidhogg Offline
Serious User
Nidhogg  Offline
Serious User

Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Just a stab in the dark here, But have you tried a value of 0.1
instead of 0 ?

I could be wrong but maybe your not allowing for the x,y,z
size of your model..




Windows XP SP3
Intel Dual Core CPU: E5200 @ 2.5GHz
4.00GB DDR3 Ram
ASUS P5G41T-M LX
PCIE x16 GeForce GTS 450 1Gb
SB Audigy 4
Spyware Doctor with AntiVirus
Re: use of multidimensional arrays for finding closest entity [Re: Nidhogg] #215043
07/08/08 23:39
07/08/08 23:39
Joined: May 2006
Posts: 90
England
TigerTao Offline OP
Junior Member
TigerTao  Offline OP
Junior Member

Joined: May 2006
Posts: 90
England
Ah sorry i should have been more clear.

The array is set to ignore values of 0 intentionally so as to speed up evaluating larger values. The values of 0 are distances to other enemies stored in the list but are too far away so are then set to 0 (could set them to 999999 though)


Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1