Game Maker Games, Articles, Tutorials & More

Game Maker Network


Howdy, Guest! Please sign in or register an account.

Print

ds_list_normalize

By Daniel · January 3, 2009

Normalizes a list of reals so that all the entries add up to 1

// ds_list_normalize(id)
// Normalizes a list of reals so that all the entries add up to 1

var size, sum, i;

size = ds_list_size(argument0);
sum = 0;

for (i = 0; i < size; i += 1)
  sum += ds_list_find_value(argument0, i);

for (i = 0; i < size; i += 1)
  ds_list_replace(argument0, i, ds_list_find_value(argument0, i) / sum);

Comments

There are no comments to display.

Post a Comment

You must be signed in to post comments.

Advertisement