Precission in the games.

G

Guest

Guest
Archived from groups: comp.ai.games,comp.games.development.programming.misc,comp.lang.java.advocacy,comp.theory (More info?)

Hi today is my birthday, and because I'm alone, I though I'd create this
article.
Basically it's not suposed to be trolling, but a proposal to a lengthly
discussion.
This article is IMO on topic in java.advocacy, ai.games, and
games.programming.misc. I'm unsure if it's on topic in the comp.theory.

I listened sentences like "Don't do it too complex", "Simple function is
better than complex one", "Don't bother with anything computationally
expensive, it would unnecessary drop speed of your program", "It would be
hard to maintain", "Simple loop would do", "It's just a game not
scientific application".

After I heavily programmed over 3 years, I think all of them were wrong.
Actually that last sentence has two meanings. I agree that games
shouldn't be done by scientific rules. It's not a math like application
that should be mathematically correct up to x degree. Games should be
highly complex applications that should be factually highly likely
correct up to x degree. (Yes programmer, or designer, shouldn't know if
that game is correct always if that game is complex enough.)

Basically if you have function that accepts integer (All terms here are
in the Java meaning, or MASM32 meaning.), then outputs another integer.
It could have 2^32 different input values, and 2^32 different output
values. It doesn't matter if that used function isn't mathematically
correct (if it's just a guess) if used function is correct for every
possible input, or output. Actually output matter more. I'm frequently
faced with ideas, from people that doesn't know original code that it
should use some other "function" that would have folding properties:
it would be slower.
It would break rest of the code.
It would break functionality of dependent methods and libraries.
It would be precise for just upper/or less frequently lower 16 bits (from
32 bits),
What wrong with people? Are they afraid of complexity? Are the dependent
too much on theirs previous education (that was wrong of course). Or are
they just lazy?

Another funny mistake is believe that single precision is faster than
double precision. First at all we are talking about Intel architecture.
On the Intel architecture, as everyone knows, floating point numbers are
stored in 80 bit precision. Doesn't matter if they are single (32 bit),
or double (64 bit). Of course GFX card could use just FP32. It would
seems that it's unnecessary to use double precision at all. Wrong. As
everyone who played with complex lightening knows, attempts to use as low
precision as possible are recipes for disaster.
A simple example. You have one color channel, its precision is 8 bits.
Now you are trying to do a 3 light calculations in the row and use lowest
precision possible: 8 bits. 0xFF turns to 0x0A - 0x12 - 0x41. now imagine
you'd use a something more complex 0x0A1 - 0x11f - 0x40. Funny this is
somewhat different result.

See? Transformation matrices aren't much different.

Actually I listened that Intel developed SSE instructions "for games". If
this is correct then this excuse isn't valid. Games need parallel
operations, thats right, however low accuracy of these operations was a
big hindrance. As a result of these thoughts most common gaming machine
Athlon 2500 barton has unaccelerated parallel 64 bit floating point
operations. Celeron-Ds aren't exactly nice either. What I would like to
see would be 8x64, 4x128, 16x32. or even better 16x64, 8x128, 32x32. This
would be roughly enough, though I would, in my current program, need
roughly 256 bit precision.

I would be interested by hardware acelerated 128 bit floating precision
numbers, and 128 bit integer arithmetic.

Yes I agree complexity and precision comes with the cost. The cost isn't
cost of the hardware, or speed costs, the cost is the brain of the
programmer, and creativity of the hardware developer.

--
Kizutsuite 'ta ano hi kara
 
Archived from groups: comp.lang.java.advocacy,comp.ai.games (More info?)

Artur Biesiadowski <abies@pg.gda.pl> wrote in
news:2mg7emFmrol1U1@uni-berlin.de:

> Raghar wrote:
>
>> Actually I listened that Intel developed SSE instructions "for
>> games". If this is correct then this excuse isn't valid. Games need
>> parallel operations, thats right, however low accuracy of these
>> operations was a big hindrance. As a result of these thoughts most
>> common gaming machine Athlon 2500 barton has unaccelerated parallel
>> 64 bit floating point operations. Celeron-Ds aren't exactly nice
>> either. What I would like to see would be 8x64, 4x128, 16x32. or even
>> better 16x64, 8x128, 32x32. This would be roughly enough, though I
>> would, in my current program, need roughly 256 bit precision.
>
>
> With 256 bit precision, you don't need floating point. Just put a
> fixed point in the middle (128.128) and you should be able to
> represent almost every physical constant in the world. For example, if

Like PI?

> used for distance in meters, you can accurately position any single
> electron withing universe (range is greater than size of visible
> universe, accuracy orders of magnitude better than size of electron).
>
Yes that would be fun, but I would need 4x64 and 2x128 operations more.

> Don't crosspost so heavily - and what comp.ai.games has to do with
> high precision in games ???

AI in games is the most vulnerable to the low precision.
You have a two posibilities and need to decide between them, alas the
difference would be lower than the 64 bit floating point accuracy. Yes
graphic programmers are somehow acustomed to the squared circless, but AI
programming has often net effect. Of course if you are doing anything
complex you simply need that extended precision to have some kind of
safety net.



--
Kizutsuite 'ta ano hi kara
 
Archived from groups: comp.lang.java.advocacy,comp.ai.games (More info?)

On Mon, 26 Jul 2004 19:23:13 +0000 (UTC), Raghar <notfor@mail.com>
wrote or quoted :

>> represent almost every physical constant in the world. For example, if
>
>Like PI?

PI is a mathematical constant. He means numbers that represent some
sort of measurement.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Archived from groups: comp.lang.java.advocacy,comp.ai.games (More info?)

Raghar wrote:

>>With 256 bit precision, you don't need floating point. Just put a
>>fixed point in the middle (128.128) and you should be able to
>>represent almost every physical constant in the world. For example, if
>
>
> Like PI?

PI doesn't really qualify as physical constant for me. I was thinking
about things like speed of light, weight of electron, weight of sun,
number of atoms in universe etc. In mathematics there are of course a
lot of things you cannot represent - 2^300 for example :)

For any game-oriented simulation, PI in 128.128 format should be more
than enough. I would be a lot more happy with 128.128 than with any
floating point format taking 256 bits.

Anyway, I think that you are barking at wrong tree. I see no point in
hardware acceleration for such big numbers. For these few instances you
are going to need them, you can just emulate such precision and then use
normal-sized variables for given local space.

I would suggest doing the following thing. Write some killer
application, using emulated big-precision math (reasonably fast of
course). Then when it is finished, let's profile it. If it will turn out
that emulation of big-precision is major problem, consider if having
processor half as fast for all other operations but few times faster for
big-precision math will speed it up (there is no free lunch - extra
gates needed for such support will cut cache size,extra registers,extra
pipeline). I really doubt if high-precision math will appear anywhere in
the profile at all (unless it is translation to floats for GPU, which
would be costly anyway) and even if it will be there, it certainly won't
be critical enough to warrant slower processor for main-stream operations.

Artur
 
Archived from groups: comp.lang.java.advocacy,comp.ai.games (More info?)

On Mon, 26 Jul 2004 23:01:15 +0200, Artur Biesiadowski <abies@pg.gda.pl> wrote:
> Raghar wrote:
>
>>>With 256 bit precision, you don't need floating point. Just put a
>>>fixed point in the middle (128.128) and you should be able to
>>>represent almost every physical constant in the world. For example, if
>>
>>
>> Like PI?
>
> PI doesn't really qualify as physical constant for me. I was thinking
> about things like speed of light, weight of electron, weight of sun,
> number of atoms in universe etc. In mathematics there are of course a
> lot of things you cannot represent - 2^300 for example :)
>
> For any game-oriented simulation, PI in 128.128 format should be more
> than enough. I would be a lot more happy with 128.128 than with any
> floating point format taking 256 bits.
>
> Anyway, I think that you are barking at wrong tree. I see no point in
> hardware acceleration for such big numbers. For these few instances you
> are going to need them, you can just emulate such precision and then use
> normal-sized variables for given local space.

For almost all non-trivial computations, main memory bandwidth and cache
effects are the bottleneck for speed.

This is why single-precision floating point can often beat double
precision; the CPU and cache can load more represntable numbers per
cycle, not because the number of cycles for internal computation is so
much lower.

> I would suggest doing the following thing. Write some killer
> application, using emulated big-precision math (reasonably fast of
> course). Then when it is finished, let's profile it. If it will turn out
> that emulation of big-precision is major problem, consider if having
> processor half as fast for all other operations but few times faster for
> big-precision math will speed it up (there is no free lunch - extra
> gates needed for such support will cut cache size,extra registers,extra
> pipeline). I really doubt if high-precision math will appear anywhere in
> the profile at all (unless it is translation to floats for GPU, which
> would be costly anyway) and even if it will be there, it certainly won't
> be critical enough to warrant slower processor for main-stream operations.

The right thing to do is analysis of typical sizes and normalizations
to ensure proper computations to acceptable precision.

If the lowest order tiny bits really matter, then you may be doing the
computation wrong, but not always.

> Artur
 
Archived from groups: comp.lang.java.advocacy,comp.ai.games (More info?)

Artur Biesiadowski <abies@pg.gda.pl> wrote in
news:2ml9ntFo33obU1@uni-berlin.de:

> Raghar wrote:
>
>>>With 256 bit precision, you don't need floating point. Just put a
>>>fixed point in the middle (128.128) and you should be able to
>>>represent almost every physical constant in the world. For example,
>>>if
>>
>>
>> Like PI?
>
> PI doesn't really qualify as physical constant for me. I was thinking
> about things like speed of light, weight of electron, weight of sun,
> number of atoms in universe etc. In mathematics there are of course a
> lot of things you cannot represent - 2^300 for example :)

Amount of money that G Bush would like to have? ^_^

> For any game-oriented simulation, PI in 128.128 format should be more
> than enough. I would be a lot more happy with 128.128 than with any
> floating point format taking 256 bits.

If processors would be optimalized on this. So lets asume it would reach
64 bit acuracy in bad case. The question is: would be 64 enough? Another
question would be: what about using this as a 2x 128 bit numbers?

> Anyway, I think that you are barking at wrong tree. I see no point in
> hardware acceleration for such big numbers. For these few instances
> you are going to need them, you can just emulate such precision and
> then use normal-sized variables for given local space.

Ever did it in assembly?

>
> I would suggest doing the following thing. Write some killer
> application, using emulated big-precision math (reasonably fast of
> course). Then when it is finished, let's profile it. If it will turn
> out that emulation of big-precision is major problem, consider if
> having processor half as fast for all other operations but few times
> faster for big-precision math will speed it up (there is no free lunch
> - extra gates needed for such support
This is a first reasonable argument that I listened on this theme.

> will cut cache size, extra registers,extra pipeline). I really doubt
Lack of extra registers would hurt. I would however more like 32 kB worth
of scratch pad, than bigger L1 cache. Moore law increases amount of
transistors on chip faster than developers are able to add new features.
I doubt high precision math would hurt processor a lot. I think heat
problems, and power requirements are larger limitations that just a
slight increase of register size.

> if high-precision math will appear anywhere in the profile at all
> (unless it is translation to floats for GPU, which would be costly
> anyway) and even if it will be there, it certainly won't be critical
> enough to warrant slower processor for main-stream operations.

I'm playing with thoughts on using GFX as a secondary processor, so
profiling might turn interesting. High precission math could be common in
profiler output, just after timer calculations and other tasks.


--
Kizutsuite 'ta ano hi kara
 
Archived from groups: comp.lang.java.advocacy,comp.ai.games (More info?)

Raghar wrote:
> Artur Biesiadowski <abies@pg.gda.pl> wrote in
> news:2mg7emFmrol1U1@uni-berlin.de:
>
>
>>Raghar wrote:
>>
>>
>>>Actually I listened that Intel developed SSE instructions "for
>>>games". If this is correct then this excuse isn't valid. Games need
>>>parallel operations, thats right, however low accuracy of these
>>>operations was a big hindrance. As a result of these thoughts most
>>>common gaming machine Athlon 2500 barton has unaccelerated parallel
>>>64 bit floating point operations. Celeron-Ds aren't exactly nice
>>>either. What I would like to see would be 8x64, 4x128, 16x32. or even
>>>better 16x64, 8x128, 32x32. This would be roughly enough, though I
>>>would, in my current program, need roughly 256 bit precision.
>>
>>
>>With 256 bit precision, you don't need floating point. Just put a
>>fixed point in the middle (128.128) and you should be able to
>>represent almost every physical constant in the world. For example, if
>
>
> Like PI?
>
>
>>used for distance in meters, you can accurately position any single
>>electron withing universe (range is greater than size of visible
>>universe, accuracy orders of magnitude better than size of electron).
>>
>
> Yes that would be fun, but I would need 4x64 and 2x128 operations more.
>
>
>>Don't crosspost so heavily - and what comp.ai.games has to do with
>>high precision in games ???
>
>
> AI in games is the most vulnerable to the low precision.
> You have a two posibilities and need to decide between them, alas the
> difference would be lower than the 64 bit floating point accuracy. Yes
> graphic programmers are somehow acustomed to the squared circless, but AI
> programming has often net effect. Of course if you are doing anything
> complex you simply need that extended precision to have some kind of
> safety net.

Well, I have never worked in AI for games, but I think one of the main
characteristics of AI is its relative robustness to noise, or loosely
structured information (think of expert systems and fuzzy logic). If
your AI is so sensible to precision, isn't this the case you are trying
to use an AI solution where a different algorithm would perform better ?

>
>
>
 
Archived from groups: comp.lang.java.advocacy,comp.ai.games (More info?)

Rodrigo Rizzi Starr <rodrigo.starr@poli.usp.br> wrote in
news:2nacl9Fuf6t4U1@uni-berlin.de:

>
>
> Raghar wrote:
>> Artur Biesiadowski <abies@pg.gda.pl> wrote in
>> news:2mg7emFmrol1U1@uni-berlin.de:
>>
>>>Don't crosspost so heavily - and what comp.ai.games has to do with
>>>high precision in games ???
>>
>>
>> AI in games is the most vulnerable to the low precision.
>> You have a two posibilities and need to decide between them, alas the
>> difference would be lower than the 64 bit floating point accuracy.
>> Yes graphic programmers are somehow acustomed to the squared
>> circless, but AI programming has often net effect. Of course if you
>> are doing anything complex you simply need that extended precision to
>> have some kind of safety net.
>
> Well, I have never worked in AI for games, but I think one of the main
> characteristics of AI is its relative robustness to noise, or loosely
> structured information (think of expert systems and fuzzy logic). If
> your AI is so sensible to precision, isn't this the case you are
> trying to use an AI solution where a different algorithm would perform
> better ?
>

My biggest proficiency is a strong AI. Dunno about error correction in a weak AI,
but in the strong AI you don't know what's an error and what is necessary for
propper work.
Different algorithm than inteligence for thinking ? Like, looked around, woman
logic?

--
Kizutsuite 'ta ano hi kara
 
Archived from groups: comp.lang.java.advocacy,comp.ai.games (More info?)

Raghar wrote:

> My biggest proficiency is a strong AI. Dunno about error correction in a weak AI,
> but in the strong AI you don't know what's an error and what is necessary for
> propper work.
> Different algorithm than inteligence for thinking ? Like, looked around, woman
> logic?
>
That will be quantum-computing...Put in all the possibilities, and hope
that interference will bring out something useful...just what women
brain do...:)
 
Archived from groups: comp.lang.java.advocacy,comp.ai.games (More info?)

Francesco Marafini <doombringer@libero.it> wrote in
news:B2h3d.10981$2T6.363414@twister1.libero.it:

> Raghar wrote:
>
>> My biggest proficiency is a strong AI. Dunno about error
>> correction in a weak AI, but in the strong AI you don't know
>> what's an error and what is necessary for propper work.
>> Different algorithm than inteligence for thinking ? Like,
>> looked around, woman logic?
>>
> That will be quantum-computing...Put in all the possibilities,
> and hope that interference will bring out something
> useful...just what women brain do...:)
>
>

I hope you are not married.

Quantum computing helps just a little. The biggest problem is don't
throw away everything.
--
Kizutsuite 'ta ano hi kara