Recent

Author Topic: computer sience class in school  (Read 22643 times)

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: computer sience class in school
« Reply #60 on: December 31, 2017, 02:33:32 pm »
No, that formula is wrong. I can found at least 2 1 issue there.

Without using Abs, there will be 75% chances the formula gives incorrect results
https://www.freepascal.org/docs-html/rtl/system/abs.html


Also as already mentioned, it needs 2 delta values, not summary.

It seems the OP is very careless or maybe he need a cup of coffee to boost his concentration.
Don't write code when you're unable to concentrate.
 ;D
« Last Edit: December 31, 2017, 03:14:21 pm by Handoko »

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: computer sience class in school
« Reply #61 on: December 31, 2017, 02:38:51 pm »
If you're interested, you can see the examples by me (StickyBalls) and rvk (DancingBalls). They're different with what you're doing now, but the concept is similar:
http://forum.lazarus.freepascal.org/index.php/topic,38511.msg262692.html#msg262692
« Last Edit: December 31, 2017, 02:47:25 pm by Handoko »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: computer sience class in school
« Reply #62 on: December 31, 2017, 03:07:07 pm »
No, that formula is wrong. I can found at least 2 issues there.

Without using Abs, there will be 75% chances the formula gives incorrect results
https://www.freepascal.org/docs-html/rtl/system/abs.html
How did you come with that percentage? By my calculations the square of any delta value (positive or negative) will always be the same so abs is only a waste of cpu cycles.

Also as already mentioned, it needs 2 delta values, not summary.

It seems the OP is very careless or maybe he need a cup of coffee to boost his concentration.
Don't write code when you're unable to concentrate.
 ;D
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: computer sience class in school
« Reply #63 on: December 31, 2017, 03:08:18 pm »
The formula looks correct to me.

I have a problem with the two loops:
Code: Pascal  [Select][+][-]
  1.     for c := 1 to 20 do begin
  2.   for c2 := 1 to 20 do begin

Imagine that two circles are touching like circle number 5 and circle number 10. This loop will pass them twice:
when c = 5, and c2 = 10
when c = 10 and c2 = 5
but only changes direction once! I say, lets see the correct results, before complicating things with optimizations.
« Last Edit: December 31, 2017, 03:11:00 pm by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: computer sience class in school
« Reply #64 on: December 31, 2017, 03:13:41 pm »
No, that formula is wrong. I can found at least 2 issues there.

Without using Abs, there will be 75% chances the formula gives incorrect results
https://www.freepascal.org/docs-html/rtl/system/abs.html
How did you come with that percentage? By my calculations the square of any delta value (positive or negative) will always be the same so abs is only a waste of cpu cycles.

Okay, sorry I was wrong.

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: computer sience class in school
« Reply #65 on: December 31, 2017, 03:17:16 pm »
I agree with Handoko, the formula is not right, yet.

I also agree with Taazz about abs.

But I still have an issue with the two loops. Taazz can you explain how the direction is changed only once?

bradyhartsfield

  • New Member
  • *
  • Posts: 41
Re: computer sience class in school
« Reply #66 on: December 31, 2017, 03:25:11 pm »
hey,

i will sleep now, i will try those things later but at the moment i dont understand what you are meaning.

regards
brady

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: computer sience class in school
« Reply #67 on: December 31, 2017, 03:28:01 pm »
Which one you didn't understand?

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: computer sience class in school
« Reply #68 on: December 31, 2017, 03:31:14 pm »
But I still have an issue with the two loops. Taazz can you explain how the direction is changed only once?
Oops you are correct. The direction must change only for the C1 variable and use only c1 based values not the c2 at all.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: computer sience class in school
« Reply #69 on: December 31, 2017, 03:33:31 pm »
We all need a cup of coffee.  :D

:)  Happy New Year 2018 :)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: computer sience class in school
« Reply #70 on: December 31, 2017, 03:37:59 pm »
We all need a cup of coffee.  :D
that's the beauty of the community. Some one will smack you in right direction (thank god).  ;)
:)  Happy New Year 2018 :)
Happy new year to every one. O:-)
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: computer sience class in school
« Reply #71 on: December 31, 2017, 04:07:59 pm »

 

TinyPortal © 2005-2018