Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2 3 ... 16
1  Discussions / General Discussions / Re: Move to Kotlin? on: 2017-11-12 11:12:32
the user's code will fail at runtime with a cast exception...
However, the consumer/producer intention is gone now, as the user can afterwards freely add arbitrary subclass instances to list l2
I what look how you broke list l2 at runtime after its exit Fun with class cast XD
up: Nope sorry - i don't care XD

I know that generics is only compile time
– and clases don’t have any values from it
so you can’t check class in runtime with generic.class
I doubt that kotlin change this
https://stackoverflow.com/questions/34122450/how-to-get-generic-parameter-class-in-kotlin
So if its fails in java it may same fails in kotlin
You can’t count on generics - its only compile advices(same like annotations) – not 100% type save
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
public static void main(String[] args){
   List<SuperClass> l2 = (List<SuperClass>) doSomething2();
   //crash it runtime here
   List<? extends SuperClass> l3 = doSomething2(); //and this
}

static class SuperClass {}
static class SubClass extends SuperClass {
public void subClassMethod() {}
}
//or after exit function
static List<? extends SuperClass> doSomething2() {
   List<SubClass> result = new ArrayList<>();
   result.add(new SubClass());
   for (SubClass current: result) {
      current.subClassMethod();
   }
   return result;
}

IMO can kotlin remove useless ":" overflow? - no? - f** it

up:
However. My only intention to post in this thread was to show people that Kotlin is at least on par with Java performance and code quality wise
I hear same story couple years ago about Groovy – and all be fine until one day when enterprise start crashing in unknown place
– after spend couple weeks they find out that code compiles wrong by parser – no code errors in src code ^^

upp:
and have a talk about language design like adults
Its ok to show features,
but not ok repeat same text over and over every day
– we need move to constructive discussion)
I like Kotlin features, but don't like syntax(text) overflow comparing with java
2  Discussions / General Discussions / Re: Move to Kotlin? on: 2017-11-11 23:36:14
Yea I'm sorry, I can't give you better examples than the ones I already gave you Tongue
We everyone knows that Java have problems
like no primitive types in List and etc,
don't need create post about its every day)

take this code its compiles fine
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
public static void main(String[] args){
   List<SuperClass> l = doSomething();
   List<SuperClass> l2 = (List<SuperClass>) doSomething2();
   List<SuperClass> l3 = (List<SuperClass>) doSomething3();
   List l4 = doSomething();
   print(l);
   print(l2);
   print(l3);
   print(l4);
}

static class SuperClass {}
static class SubClass extends SuperClass {
public void subClassMethod() {}
}

static List doSomething() {
   List<SubClass> result = new ArrayList<>();
   result.add(new SubClass());
   for (SubClass current: result) {
      current.subClassMethod();
   }
   return result;
}
static List<? extends SuperClass> doSomething2() {
   List<SubClass> result = new ArrayList<>();
   result.add(new SubClass());
   for (SubClass current: result) {
      current.subClassMethod();
   }
   return result;
}
static List<? super SubClass> doSomething3() {
   List<SubClass> result = new ArrayList<>();
   result.add(new SubClass());
   for (SubClass current: result) {
      current.subClassMethod();
   }
   return result;
}

static void print(List<SuperClass> l) {
   System.out.println("List:" + l);
}
3  Discussions / General Discussions / Re: Move to Kotlin? on: 2017-11-10 18:56:23
I dont like in kotlin 2 dots ":" and name var before type and return of function at the end
this was keep me away from kotlin, scala, groovy and other ^^
they all have same strange pattern in syntax(like they all was parsed by Xtext Wink)

up: hm groovy don't have them)) maybe in some past i find something different to not use it - need recheck ^^
Y, now i remember) it have some compile nightmares and this one of them
http://www.gmarwaha.com/blog/2009/02/02/groovy-private-is-not-private/
(i even don't know if they fix this and other bugs ^^)
4  Discussions / General Discussions / Re: Move to Kotlin? on: 2017-11-08 13:23:56
it is veeeery hard to test every possible existing case.
Yes it is)
Same as separate Code for modules – and use only interfaces from it,
Its remove direct dependence and isolate code in it.
Its hard - and the larger the project, the harder it is to test it and separate code on modules.

up:
There's a school of thought that says tests are papering over the cracks in design specification.
I'm one of those people who actually rather likes design-by-contract
I also can’t write TDD(Test-Driven Development) (write Test before code)
But I can write Raw working code
then make conceptual Tests(Test on what I want it to be, and not for “current Raw code passes”)
– and transform that code in to final code that pass all Tests
(Test also grows during code updates)
5  Discussions / General Discussions / Re: Move to Kotlin? on: 2017-11-08 12:18:27
I can also discuse all that but: there is no big difference in language and code itself
if its return same result and pass all Tests on it.
if code crushes in runtime then its Test error and not code itself

up:
There is a difference between:
Test on Refactoring
and
Test on function (class, module) result and entering params)

p.s Writing “result” Test is hard
- (TD) ("4" "3" "12")("-4" "3" "-12")("4" "-3" "-12")("-4" "-3" "12")
("0" "3" "0") ("4" "0" "0")("0" "-3" "0")("-4" "0" "0")("0" "0" "0")

– because on practice you fully write again tested function(TF) that produce same result without optimizations
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
int Mul(int v1, int v2){
   if(v1 == 0 || v2 == 0){
      return 0;
   }
   int sum = 0;
   int v2_A = v2;
   if(v2 < 0) v2_A = -v2;
   for(int i = 0; i < v2_A; i++){
      sum += v1;
   }
   if(v2 < 0) sum = -sum;
   return sum;
}

-And about TIF(TE) – I not so smart to even write test data for it XD
1  
2  
3  
4  
5  
-& < v1 < &
-& < v2 < &
v1 == 0 {0}
v2 == 0 {0}
r=0 0..(A(v2))[r += A(v1)]{r.s = v1.s * v2.s}

(I can’t even call it properly ^^)

up2: OK i finally write test for TIF with explanations)
1  
2  
3  
4  
v1 == 0 r
v2 == 0 r
v2 > 0 r
v2 < 0 r

test case
1  
-+v1 -+v2


generate
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
if(v1 == 0){
   return x;
}
if(v2 == 0){
   return x;
}
if(v2 > 0){
   return x;
}
if(v2 < 0){
   return x;
}
//Eroor can't go here

filled Data
produce same result on any val enter if no extra val present that not final(const)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
if(v1 == 0){
   return 0;
}
if(v2 == 0){
   return 0;
}
if(v2 > 0){
   int sum = 0;
   for(int i = 0; i < v2; i++){
      sum += v1;
   }
   return sum;
}
if(v2 < 0){
   int v2_A = -v2;
   int sum = 0;
   for(int i = 0; i < v2_A; i++){
      sum += v1;
   }
   sum = -sum;
   return sum;
}

test data
("4" "3" "12")("-4" "3" "-12")("4" "-3" "-12")("-4" "-3" "12")
//
("5" "3" "11")
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
if(v2 > 0){
   int sum = 0;
   for(int i = 0; i < v2; i++){
      sum += v1;
   }
   if(v1 == 5){//no situation like this - because can't add "if" manually
      return 11;
   }
   return sum;
}


final const external var
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
final static int C = 1
...
if(v2 > 0){
   int sum = 0;
   for(int i = 0; i < v2; i++){
      sum += v1;
   }
   sum += C;
   return sum;
}

("4" "3" "13")
("5" "3" "16")

-One Test Data covering all situation no mater in what range params are
(except Cpu register overflow ^^)
6  Discussions / General Discussions / Re: Move to Kotlin? on: 2017-11-07 18:50:26
There is a difference between writing 1 file game script 300-1000 lines of code
and maintaining project 30k-50k+ lines of code - filled by “val”
same about functional languages – fluffy for kids and nightmare for real projects

Up:
But why even bother when future for TDD
MTD -> MTF -> MTE (MTIF)
(M for Module, D for Data Res {"3" "+" "4" "7"}) XDDDDD  Roll Eyes
7  Discussions / General Discussions / Re: Gosh, it's quiet in here on: 2017-11-05 22:54:05
I'll prepare a database dump 'soon' (this week) and we'll see who is willing to make a JGO clone worthy and capable of replacing the current forum. If it's any good, I'll seriously discard SMF and roll out whatever is ready to replace it.
I have very low experience with Web framework's
But from what I know: trying direct DB Copy(dump) from one framework to another is nightmare.

Alternative solution, because its WEB – someone can write simple parser(Scrapier, scrambler) for html version of forum)
And dump all data from Front-End side ^^

+ if needed compatibility with current version – for every post, topic
can also be dumped Extra info post / topic id
gosh-it-s-quiet-in-here/38470/msg/367159/view/topicseen.html

I think it's less painful than trying integrate current DB to new framework
8  Discussions / General Discussions / Re: Gosh, it's quiet in here on: 2017-11-04 13:35:19
Java itself is a piss-poor platform for game development, you need mature engines/frameworks, and those tend to have their own communities
I don't think that libgdx or LWJGL Tutorials can attract at least minimum amount of new ppl to forum
– not today, too many alternatives

I have extra solution – make mods for popular realized games on Java (sadly we have only few)
Mods very well gathering players and developers together
(Sorry I remember only few company's (ppl): PuppyGames and OrangePixel)

Yes its hard to implement – and almost not profitable in many cases
And it must be easy to understand and to modify game(maps) for end user,
And its no so easy to implement especially for finished game without moding support

p.s I for mods, but sorry I don't have mental stability to helping with mods full day(half day) for free,
I can help advices, little code, but not every day

pp.s Forum is better then reddit for mods discussion because it's filtering kids, that too lazy to register on it Wink
9  Discussions / General Discussions / Re: Gosh, it's quiet in here on: 2017-11-03 20:22:00
Java Web is forbidden by browsers
All Kids on Unity, GameMakers and Unreal
All Pro (Indie) – in own garages aka bunkers in isolation
Clean Java Android - almost no one cares
Minecraft Hype is almost gone…
..So – I don’t see clean future for javagaming in current state (((

Solution?
Maybe make forum for gamedev – not targeted to some game engine or programming language
But, is it be better than Unity specialize forum?
In any case it receive more active users than currently have javagaming

I've already suggested in the past- Dark solution
"make Game market for indie games" one more - one less - he will find his own audience
but its dark side Wink
10  Game Development / Newbie & Debugging Questions / Re: Hosting game/demo file for download on: 2017-10-04 16:12:05
There is plenty Free Web hosting in internet – with 400gb+ or even unlim bandwidth
+there are many file hosting with wait 30 sec to download
Or you can use Google drive or similar ^^
(steam 100$ for game + free bandwidth XD)

@jonjava
IMHO: Sorry but: that racism (or similar words) to criticize someone for their site logo and life position.

Quote from: gouessej
I get away from the extralegal censorship of the asocial networks under imperalist control
Its not so simple as it looks – custom server can’t help with censorship
– it can be blocked in 1 minute by IP (or even by server internet provider)

“until you not dangerous - no one cares about you”
and even sites like “Pirate Bay” may live for years and years
– but if “they” want – they can block it in all form less then 1 day
- its very easy – simple no one care )

p.s I support “gouessej” position to be independent ^^
(until his action not harm others)
why? because hi at least trying change something in better way
Yes, trying to be independent may go wrong way and its f**k up something important XD
But we don’t know future)
(believe you or not but in couple 50-100 years people will be paying for Air)

pp.s IMHOOOOOOOO "Amazon S3" is full crap
 - never ever use it: their prices are ridiculous their stability not bigger than other big providers VPS
(same as Microsoft Clouds XD)
Its sad to see so many brainwashed people believe in fluffy Ads (with magic inside)
All you need is simple pay little more and all that magic can be yours Wink
11  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-09-18 15:19:20
You need therapy, at once!
Maybe)  
(or use Auto Formatter before post code somewhere XD)
ED:I use lower Case only for function arguments, in function variable and RAW code
1  
2  
3  
4  
5  
int W;
public Win(int w){
   W = w;
   int x = 10;
}

I don't like this type of style:
1  
2  
3  
4  
int w;
public Win(int w){
   this.w = w;
}

For static and final – I have different Font style(color) in IDE so I don’t care )

up: ps.
this preference only for my own projects
- if i write for 3rd party project I use their formatting style Wink
12  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-09-18 14:54:46
What sort of sick puppy says "static public"!?
Cas Smiley
static is more important for me then public / protected ^^
I also have
1  
2  
3  
Object ar[] 
Object ar[][]
Object[] ar[]

(when many ppl use
Object[][] ar
)
=)
13  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-09-18 11:32:06
Look what i found)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
   static public void main(String[] args){
      B b = (B) new B().Call();
      B b_E = new B().Call_E();
      C c = new C().Call_E();
     
      //Runtime Error
      //But Because its Class exception - its trigger on every call = easy to find and fix
      C c_Er = new A().Call_E();
   }
   
   static public class A{
      public A Call(){
         return this;
      }
      public <E extends A> E Call_E(){
         return (E) this;
      }
   }
   
   static public class B extends A{}  
   static public class C extends B{}
14  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-09-14 22:30:24
Ah--probably the "macro recording" feature proved too tricky to just kick out and I put it aside for that reason.
Capturing Events and reproduce them can be tricky
here some raw example
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
long Start_Time;
Start_Recording(){
   Start_Time = cur_Time_Ms
}

ArrayList Events
java_Mouse_event(){//etc evn
   long time_Trig = cur_Time_Ms - Start_Time
   Events.add(event, time_Trig)
   
   java_Mouse_event_Proc(ev)
}

java_Mouse_event_Proc()
///
Thread_Load_Events{
   Events_Load
   int proc_List_Pos = 0;
   int size = Events_Load.size;
   while(proc_List_Pos < size){
      long cur_Time_Ms_Macro = cur_Time_Ms - Start_Time_Macro
      int i = proc_List_Pos
      for(; i < size; i++){
         if(ev.time_Trig <= cur_Time_Ms_Macro){
            java_Mouse_event_Proc(ev);
         }else{
            break; //for loop
         }
      }
      proc_List_Pos = i;
      Sleap(15)
   }
}

all be fine and smooth if application don't have Lags =)
if you have after some event let say 100ms lag
-additional event align needed - to compensate multithreading desync ^^
(or don't care if events don't need perfect time accuracy)
15  Game Development / Shared Code / Re: Fast Atan2 [Again] on: 2017-09-12 16:44:04
Quote
From my tests in the past, Java's Math.sqrt() is pretty damn fast these days
...
we have x86 instructional support
Yes, ok, my mistake - why i even trying...
– no one cares)
16  Game Development / Shared Code / Re: Fast Atan2 [Again] on: 2017-09-12 10:04:53
Let make next Contest "Fast Sqrt" Smiley
one from the Baselines https://en.wikipedia.org/wiki/Fast_inverse_square_root
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
float Q_rsqrt( float number )
{
   long i;
   float x2, y;
   const float threehalfs = 1.5F;

   x2 = number * 0.5F;
   y  = number;
   i  = * ( long * ) &y;                       // evil floating point bit level hacking
   i  = 0x5f3759df - ( i >> 1 );               // what the f**k?
   y  = * ( float * ) &i;
   y  = y * ( threehalfs - ( x2 * y * y ) );   // 1st iteration
//   y  = y * ( threehalfs - ( x2 * y * y ) );   // 2nd iteration, this can be removed

   return y;
}
17  Game Development / Shared Code / Re: Tagged Human JSON (THJSON) Parser on: 2017-09-05 10:24:48
We need even Moarrrrrr custom syntax and Languages  Roll Eyes
(it's not sarcasm, we really need them
 – but not stupid copy past or change 2-3 lines of exist like some kids do,
"you can do it Alone – it's not so hard... really not so hard")
18  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-09-02 16:24:15
Funny topic)
https://forums.tigsource.com/index.php?topic=18397.msg1351265#msg1351265
19  Game Development / Newbie & Debugging Questions / Re: Efficient Bukkit multi-plugin Mongo database design on: 2017-09-02 16:09:18
i see same question from you on stackoverflow ^^ (no answer and some kid give minus)

short - brutal trick:
- Make 1 big field like 256-512 byte and manually pack unpack different data in it:
"2 bytes kills, 1 byte Score, 2 byte Money"
per Game Data, or per player Data (MMO) - use it where you want)
Short – brutal - same DB size for different Versions of client and server (while in bounds of field limit)

p.s I may say little disappointed – we have at least 3 ppl who working with DB(experts) and make for living with it.
But they don’t care (or too Greedy to help for free XD)
Quote from: Icecore
I may say little disappointed
But I don’t XDDDD
There are so many, so I even not care…
20  Game Development / Shared Code / Re: Fast Atan2 [Again] on: 2017-09-01 09:28:17
It have more accuracy because use bigger array and use less memory because its 1 array – not 8 )
(1000 x 8 x 4(f) = 32kb   4000 x 4(f) = 16 kb)
More array size more accuracy ^^

also may try this - less on one OP =)
1  
2  
3  
++      private static final float Pi_H_M = -Pi_H;
--      if(y < x) return -(Pi_H + Atan2[(int) (x / y * Size_Ac)]);
++      if(y < x) return Pi_H_M - Atan2[(int) (x / y * Size_Ac)];
21  Game Development / Shared Code / Re: Fast Atan2 [Again] on: 2017-08-30 18:07:29
I also have this - it's more Cache friendly, but have more OPs ^^
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
private static final float Pi = (float) Math.PI;
private static final float Pi_H = Pi / 2;
//4 x 4000 = 16 kb L1 Cache
private static final int Size_Ac = 4000;
private static final float Atan2[];

static{
   final int Size_Ar = Size_Ac + 1;
   Atan2 = new float[Size_Ar];
   for(int i = 0; i <= Size_Ac; i++){
      double d = (double) i / Size_Ac;
      double x = 1;
      double y = x * d;
      Atan2[i] = (float) Math.atan2(y, x);
   }
}

static public final float atan2_1(float y, float x){
   if(y < 0){
      if(x < 0){
         // (y < x) because == (-y > -x)
         if(y < x) return -(Pi_H + Atan2[(int) (x / y * Size_Ac)]);
         else return Atan2[(int) (y / x * Size_Ac)] - Pi;
      }
      else{
         y = -y;
         if(y > x) return Atan2[(int) (x / y * Size_Ac)] - Pi_H;
         else return -Atan2[(int) (y / x * Size_Ac)];
      }
   }
   else{
      if(x < 0){
         x = -x;
         if(y > x) return Pi_H + Atan2[(int) (x / y * Size_Ac)];
         else return Pi - Atan2[(int) (y / x * Size_Ac)];
      }
      else{
         if(y > x) return Pi_H - Atan2[(int) (x / y * Size_Ac)];
         else return Atan2[(int) (y / x * Size_Ac)];
      }
   }
}
22  Discussions / General Discussions / Re: Programmer jokes on: 2017-08-23 21:44:55
Tell me where you work because I never want to work there!! My experience of working in IT is more like how KaiHH describes it.
Happy few)
And maybe you even don’t work 10-12 hours a day + Weekends In Deadline
Dream Land ^^
p.s On every successful story- at least 1000 not so successful ^^
(Like Story about Fable Development)
23  Discussions / General Discussions / Re: Programmer jokes on: 2017-08-22 14:11:10
Quote
Good knows that his coworkers are idiots and makes mistakes (bugs) all over the time
That's an awful description.
From perspective of Manager:
- Programmer that write code with bugs is idiot “didn't he see that he make a bug” =)

Quote
And he accept them as they are, without trying to change them
A good manager encourages people to improve themselves. Of course not by blaming them for their errors but by establishing an environment in which errors are accepted (and to some degree, encouraged) and then giving them hints on how they can improve and to learn from themselves.
And did you really want that some manager (not programmer)
Will try to teach you how to program better and make more quality code (product) XD
(and many of them do, do this all over the time ^^)

((Yes, yes if you work in big company and have QA department with 50+ ppl
– they check code and add errors to bug tracker when after couple months someone will try to fix them..
But what if you have only 10- ppl at All Wink))

p.s I fears you can’t understand me, because we live in different realities: 2 ppl can also be a company
(and you can’t hire best of the best because they go in bigger companies and you simple don’t have money on them)

UP pp.s
Even best-of the best:
may spend plenty of working time on some nonsense like watch videos, sitting in facebook, reddit etc..

Can I call them Idiots? – Yes I can.
When they have work, they spend time on some nonsense, and later crying that they not finished work in time

This is where:
He know their strengths and weaknesses
Is important: you know that you’re coworkers spend half working day on non work nonsense.
You planning Terms and Milestones with this offset.

Dirty reality:
And if you work in Big company where you have 50+ ppl on 1 position
If some of workers spend more time than manager think its needed
– it's fired in no time, and on next day new person works on his place
No one will even try to understand you, or teach you something.
Because it's extra expenses – And business didn't like extra expenses.
24  Game Development / Newbie & Debugging Questions / Re: Using bytes to save space. Does that really optimise perfomance or not? on: 2017-08-22 13:49:10
Short answer: no.
Longer answer: when you start to use a lot of bytes - like megabytes, typically in arrays, or buffers - then yes. But as class members? No. Don't.
Cas Smiley
Thank you Cas. Seems my idea was stupid haha
Its good Idea - and Bad Implication in Java (not your fault ^^)
p.s I use byte when i can - without paranoia (all int -> short -> byte) XD

For big Data consuming - its nice to pack data to ByteBuffer Object - and clean its manualy
if you let say have 10mil objects with 38 byte each +12 byte Object Header + 6 Align x64 = overhead is 180 mb
But 10 mil objects - is rare (and its only 180 mb+, another problem is GC)
25  Game Development / Newbie & Debugging Questions / Re: 2 questions, coding MMORPG in Java on: 2017-08-22 13:43:08
2 questions, coding MMORPG in Java
One Answer - NO)

If you have at least 1 question about MMORPG – then you’re not Ready for it =)

p.s:Nice Blog about Games Programming (Java)
https://www.youtube.com/playlist?list=PLRIWtICgwaX3M0JRdA_0ykrjp7mHGuynI
26  Discussions / General Discussions / Re: Programmer jokes on: 2017-08-22 13:29:08
Conditional inserts? This joke has too many layers Pointing
Do you know the differences between good Manager and bad?
Good knows that his coworkers are idiots and makes mistakes (bugs) all over the time,
He know their strengths and weaknesses,
And he accept them as they are, without trying to change them

Not a joke – dirty Reality XD
27  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-08-14 12:53:05
I was thinking more about concept of float structure,
In theory format may use only max 8 bits float part(with 0.0039 tick) and 4 bits exponent its adds more integer data to use

But he was design in different way – so it hold as many float part as he can.

And after more thinking I suddenly find explaining why)
Because it was designed to return div accurate result
– and not for holding big value)
This is a purpose of float and not to hold 300000.005f =)
1  
2  
3  
4  
5  
6  
int a = 100000;
int b = 100001;
float f = (float)b / a;//1.00001
int c = (int) (f * a);//100001
if(c == b)System.out.println("same");
else System.out.println("not");
28  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-08-13 20:20:08
When you receive this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
float fff_5 = 65536.0f + 0.003f;
float fff_6 = 65536.0f + 0.001f;
float e = 0.0001f;
if(Math.abs(fff_5 - fff_6) >= e){
   System.out.println("not same");
}
else{
   System.out.println("same");
}

fff_5 = 65535.0f + 0.003f;
fff_6 = 65535.0f + 0.001f;
if(Math.abs(fff_5 - fff_6) >= e){
   System.out.println("not same");
}
else{
   System.out.println("same");
}


wiki data about "Single-precision floating-point format" can’t save you or help solve problem)
1  
2  
3  
4  
5  
6  
7  
FV:0.001     Hex:3a83126f Bits:111010100000110001001001101111
FV:0.003     Hex:3b449ba6 Bits:111011010001001001101110100110
FV:65535.0   Hex:477fff00 Bits:1000111011111111111111100000000
FV:65536.0   Hex:47800000 Bits:1000111100000000000000000000000

FV:65536.01  Hex:47800001 Bits:1000111100000000000000000000001
FV:65535.004 Hex:477fff01 Bits:1000111011111111111111100000001

only double fix it =)

p.s And yes i know that float part in 65536 is not 1 byte(8 Bits) its 7 bits
and when integer data grow float part is decreased not by bytes but by bits
(on top post was raw example ^^ because no one cares this bits magic unless it solves the problem and it doesn't =))
1  
2  
3  
4  
5  
6  
FV:65535.004 Hex:477fff01 Bits:10001110111111111111111_00000001
FV:65535.996 Hex:477fffff Bits:10001110111111111111111_11111111
FV:65536.01  Hex:47800001 Bits:100011110000000000000000_0000001
FV:65536.99  Hex:4780007f Bits:100011110000000000000000_1111111
FV:65537.0   Hex:47800080 Bits:100011110000000000000001_0000000
FV:65537.01  Hex:47800081 Bits:100011110000000000000001_0000001
29  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-08-13 15:09:24
Why you must never use float with sensitive data
(it's literally everything except img, audio out, and maybe AC out)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
float fff_1 = 65536.0f;
float fff_2 = 0.0039f; // or 0.003f
float fff_3 = fff_1 + fff_2;// = 65536.0f == fff_1

/**
65536 = 65535(2 byte) + 1(1 byte) = 3(byte)
1 / 256 (1 byte) = 0.00390625
0.0039 (2 byte) - because its less 0.00390625 (8 Bits accuracy)
3(byte) + 2(byte) = 5(byte) and float have only 4(byte)
*/

float fff_4 = 65536.0f + 0.00390626f;// 65536.01
float fff_5 = 65536.0f + 0.00390625f;// 65536.0

You even can't epsilon compare it because its 3 digits after zero.
30  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-08-07 12:08:09
Funny moment Smiley I accidentally find this one
https://en.wikipedia.org/wiki/Diamond-square_algorithm

I almost fell off my chair when i read this,
Because it's one-o-one algorithm that i am developed in 2012 for terrain generation,
I have nothing to know about fractal generation, and terrain generation (at that time)
All I knew: Minecraft is using perlin noise,
I don’t want use it (because I have no idea how implement it)
and I want make something more realistic
so, I spend on it couple weeks or even month, trying out different ideas,
(upgrading my previous generation from 2011)
And I receive this:
http://www.java-gaming.org/topics/world-of-change/23947/msg/241892/view.html#msg241892


Here raw code img (if I made it today it may looks better ^^)


Simple imagine I also have random value to mix it in to result (because without it, it looks like waves)
same as in Diamond-square algorithm(that was developed from wiki in 1982)

p.s This is example why its not copy past or lame implementation: I have static parameter to set size of square at some size it can’t be divided by 2 in midle iteration like 3 / 2 for 8x8 square
So I made this:
1  
2  
3  
4  
if((MaxX - MinX) % 2 > 0){
   MinX++;
}  
int midlX = (MaxX + MinX) / 2;


why I even need to make square like 8x8 that have problems to divide middle parts?
- because I trying many options, searching best possible solution
//
And you saying, something about intellectual property rights and patents?
Its bullshat: random ppl in different parts of the world can implement same algorithms and technologies without knowing each others.
(and if “Diamond-square algorithm” was patented and I used something similar to it I may even lose in law court)
Pages: [1] 2 3 ... 16
 
Ecumene (108 views)
2017-09-30 02:57:34

theagentd (135 views)
2017-09-26 18:23:31

cybrmynd (245 views)
2017-08-02 12:28:51

cybrmynd (240 views)
2017-08-02 12:19:43

cybrmynd (238 views)
2017-08-02 12:18:09

Sralse (252 views)
2017-07-25 17:13:48

Archive (864 views)
2017-04-27 17:45:51

buddyBro (1007 views)
2017-04-05 03:38:00

CopyableCougar4 (1566 views)
2017-03-24 15:39:42

theagentd (1373 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!