glob2-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [glob2-devel] Nicowar and desync


From: Stéphane Magnenat
Subject: Re: [glob2-devel] Nicowar and desync
Date: Tue, 18 Jul 2006 09:41:32 +0200
User-agent: KMail/1.9.1

> There is no float usage in Nicowar, I assure you. And it does use more
> CPU, but I doubt thats the cause unless its litterally lagging your
> machine.

grep float AINicowar.h AINicowar.cpp :

AINicowar.h:                            GradientPoll(Gradient::Sources source, 
Gradient::Obstacles obstacle, float weight) : is_null(false), source(source), 
obstacle(obstacle), weight(weight), min_dist(-1), max_dist(-1) {}
AINicowar.h:                            float weight;
AINicowar.cpp:          average_unit_strength_level=static_cast<unsigned 
int>(std::floor(static_cast<float>(average_unit_strength_level)/static_cast<float>(total)+0.5))-1;
AINicowar.cpp:          average_unit_strength_level=static_cast<unsigned 
int>(std::floor(static_cast<float>(average_unit_strength_level)/static_cast<float>(total)+0.5))-1;
AINicowar.cpp:                  float score=0;
AINicowar.cpp:                                  const float weight = 
CONSTRUCTION_FACTORS[building_type][factor].weight;
AINicowar.cpp:                                          
score+=static_cast<float>(top_left)*weight;
AINicowar.cpp:                                          
score+=static_cast<float>(top_right)*weight;
AINicowar.cpp:                                          
score+=static_cast<float>(bottom_left)*weight;
AINicowar.cpp:                                          
score+=static_cast<float>(bottom_right)*weight;
AINicowar.cpp:                  tp.percent=static_cast<unsigned 
int>(static_cast<float>(counts[i])/static_cast<float>(num_buildings_wanted[i])*100);
AINicowar.cpp:  float devisor=1;
AINicowar.cpp:          devisor=static_cast<float>(max)/16.0;
AINicowar.cpp:  float 
average_happiness=static_cast<float>(total_happiness)/static_cast<float>(total_units);
AINicowar.cpp:                          float 
enemy_average_happiness=static_cast<float>(enemy_happiness)/static_cast<float>(enemy_units);

It seems it does. Don't forget floating point format does not constrain 
handling of least significant bits, so different CPU (even both x86) can give 
different results. We had this bug in glob2 earlier in the same type of 
computation Nicowar is currently doing.

I agree for the CPU.

Steph




reply via email to

[Prev in Thread] Current Thread [Next in Thread]