Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 598 599 [600] 601 602 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 902795 times)

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #8985 on: February 11, 2016, 06:17:37 pm »

I... what? Apparently there's a typo in the package's setup script, which doesn't actually look like it should error which is kinda weird. Or I might be doing something wrong.
That's perfectly valid Python 2 code. You appear to be using Python 3, which would need "except ImportError as err"
Dammit, it's supposed to be compatible with Python 3. Why must everything be so inconvenient.
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

Bauglir

  • Bay Watcher
  • Let us make Good
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8986 on: February 11, 2016, 08:12:15 pm »

Dammit, it's supposed to be compatible with Python 3. Why must everything be so inconvenient.
welcome to my goddamn summer and autumn

you know you're in deep when you open up the source files and edit them to make them work with python 3, praying that there's nothing left that's still syntactically valid but has changed semantics catastrophically
Logged
In the days when Sussman was a novice, Minsky once came to him as he sat hacking at the PDP-6.
“What are you doing?”, asked Minsky. “I am training a randomly wired neural net to play Tic-Tac-Toe” Sussman replied. “Why is the net wired randomly?”, asked Minsky. “I do not want it to have any preconceptions of how to play”, Sussman said.
Minsky then shut his eyes. “Why do you close your eyes?”, Sussman asked his teacher.
“So that the room will be empty.”
At that moment, Sussman was enlightened.

doomchild

  • Bay Watcher
  • Official Pace Car for the Apocalypse
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8987 on: February 11, 2016, 09:08:43 pm »

I definitely wouldn't try game stuff in Java.  My day job stuff has me doing some Java lately.  Hopefully, we'll get Mono integrated into our workflow so I can go back to C#, but for the time being, I'm stuck.
Stuck with Java in particular, or just with the JVM?  In the latter case, there are a few nicer options available.

In the short term, stuck with Java itself.  Putting another language  into play isn't out of the question (our stuff is all microservices, so we've got a lot of freedom with regard to languages, but right now the path of least resistance is to just use Java.  One of the other developers and I are working on getting Mono up and on the platform, but we haven't finished that yet.
Logged
Quote from: webadict
I could care less what you are now, because what you will be is dead.

jaked122

  • Bay Watcher
  • [PREFSTRING:Lurker tendancies]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8988 on: February 11, 2016, 09:17:43 pm »

Most current "Java is too slow" comments are memetic circlejerking leftovers from a bygone era. Java via LibJDX is actually a very good way to make games nowadays, especially if you're trying to target multiple platforms.


I'm just going to say that Java is one of the least expressive popular language in my opinion. Every damned thing about it is meant to make it easy to compile. That's fine, but I don't like not having nice operator overloading or the general garnishes that C++ provides.


I think it's architecture is not as good as the current generation of .Net stuff. The compilation tools are horrible to work with. The language is incredibly pedantic, and the boxing/unboxing problems which show up for things like lists when you just have an integer is stupid.


Sure they could solve it in java 10. I don't think they will though, that'd break way too much code that relies upon the fact that java doesn't handle generics properly. Of course, there's the most common way to use generics, to make code faster(which it doesn't in java) and to ensure compile time checking(which is terribly neutered in java in comparison to C++ anyway).


 I don't think they will ever get around to it. So java will always have shitty performance related to it's generics.


Also, the JVM is in general, a terrible virtual machine in my opinion. Sure, it compiles code to the fastest version which they could prove runs the same natively, but it doesn't stop the object system from ruining that glorious performance, nor does it help that the JVM has a limited memory by default, which breaks things suddenly without meticulous configuration on sudden demand increase, the fact that the GC is stop the world(as in everything on all the thread stops so the GC can catch it's breath). There's no underlying access to any of the machine architecture, generally not even in a hacky way, which is a sign that the system can't handle the extensions that could improve it immeasurably.


Sure there are java garbage collectors out there that don't stop the execution, but they are all proprietary for the most part or otherwise unsuitable for most people's uses. I think there's a free one that can do it, but it doubles the memory usage because it uses a particular algorithm which requires the entire memory set be duplicated.


The fact that swing can't be themed correctly after fifteen years of thumb twiddling on the matter; the fact that java hasn't really improved majorly in five years; the looming license crisis that will pass if Oracle wins the lawsuit against Google.


The Flyweight pattern was popularized in response to the shortcomings of the JVM, and I don't like it either. It's basically just throwing a bunch of your shit into global variables which are managed in a single place. That's not a solution to any of the things that java was originally purported to help solve.


I hate java. That should be clear here. I don't like the JVM, or even the dinky expressive languages like Scala, which still suffers from being bound to the java object model, which is somewhat powerful, if not completely unsuitable for high performance work.


If I continue talking about it I'm going to say things that are neither helpful or true, because that's where this rant is heading.
Dammit, it's supposed to be compatible with Python 3. Why must everything be so inconvenient.
welcome to my goddamn summer and autumn

you know you're in deep when you open up the source files and edit them to make them work with python 3, praying that there's nothing left that's still syntactically valid but has changed semantics catastrophically


Just run 2to3 on it. It'll probably work given that most of the issues are probably due to syntax.


That migration tool is great.


The python interpreter hasn't changed all that much, so there isn't much that should be an issue with the migration.


I definitely wouldn't try game stuff in Java.  My day job stuff has me doing some Java lately.  Hopefully, we'll get Mono integrated into our workflow so I can go back to C#, but for the time being, I'm stuck.
Stuck with Java in particular, or just with the JVM?  In the latter case, there are a few nicer options available.

In the short term, stuck with Java itself.  Putting another language  into play isn't out of the question (our stuff is all microservices, so we've got a lot of freedom with regard to languages, but right now the path of least resistance is to just use Java.  One of the other developers and I are working on getting Mono up and on the platform, but we haven't finished that yet.


I already feel vindicated and I haven't posted yet.


Try erlang. It has a better VM, lots of nice syntactic support for compilation checking, a very lightweight threading and actor system etc, concurrent GC(doesn't pause all the threads), and absolutely nothing in common with java other than the fact that it has a virtual machine.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #8989 on: February 11, 2016, 09:20:07 pm »

I like C#.  That is all. :v
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

jaked122

  • Bay Watcher
  • [PREFSTRING:Lurker tendancies]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8990 on: February 11, 2016, 09:22:03 pm »

I like C#.  That is all. :v
I do too.

NAV

  • Bay Watcher
  • I have an idea!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8991 on: February 11, 2016, 09:22:34 pm »

My sister needs help with a programming problem so she PMed me for help. I'm too dumb to help her and she's too shy to post in this thread. Help me help her please?
I'm stuck on a programming/math problem. Can you help??

I'm making a tank shoot a shell. The tank can be anywhere, and the turret can be pointing any direction. The shell must appear at the end of the turret.

I've done the calculations of the relative position of the shell to the position of the turret, and gotten an x and a y. But those could be added or subtracted to the overall x and y of the turret, depending on its angle??



Is there any way to do this that doesn't involve a convoluted if/else to figure out which?? I feel like I'm missing something obvious.
Logged
Highmax…dead, flesh torn from him, though his skill with the sword was unmatched…military…Nearly destroyed .. Rhunorah... dead... Mastahcheese returns...dead. Gaul...alive, still locked in combat. NAV...Alive, drinking booze....
The face on the toaster does not look like one of mercy.

doomchild

  • Bay Watcher
  • Official Pace Car for the Apocalypse
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8992 on: February 11, 2016, 09:23:47 pm »

I don't like Java overall, but the one really nice thing I've found has been Java 8's streaming API.  It's a freaking pleasure to work with.  Of course, you can't use methods that throw exceptions in lambdas, because checked exceptions are the devil that comes out to laugh at you when you attempt to write beautiful Java code.

In general, I feel like Java has always attempted to cater to the lowest common denominator, feature-wise, and has therefore acquired a set of weird, poorly-fitted features that fight with each other.  Checked exceptions and lambdas are one example, and type inference along with type erasure is another one.  The tooling is significantly more complicated than the equivalent .NET tooling (Maven is madness made manifest, and Gradle just barely covers over the trouble enough to be usable), the various framework APIs have very little in common (look at the JavaX Mail API, then at the Stream API, and tell me they were made by the same entity), and it's obvious to me that nobody has ever looked at the system as a whole and tried to streamline it.  It's just a constant piling-on of features.

Backwards compatibility is important.  It really is.  But Java has gone about it in a way that pollutes future code with past mistakes, and that's just not acceptable.
Logged
Quote from: webadict
I could care less what you are now, because what you will be is dead.

jaked122

  • Bay Watcher
  • [PREFSTRING:Lurker tendancies]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8993 on: February 11, 2016, 09:32:53 pm »

I don't like Java overall, but the one really nice thing I've found has been Java 8's streaming API.  It's a freaking pleasure to work with.  Of course, you can't use methods that throw exceptions in lambdas, because checked exceptions are the devil that comes out to laugh at you when you attempt to write beautiful Java code.


That looks exactly like LINQ but without all the things that makes it acceptable, like allowing you to use exceptions in the lambdas.


I mean,
Code: [Select]
parallelStream is the same as
Code: [Select]
AsParallelQuery

I also suspect that it is not as extensible, can it perform object relational mapping? Like in C#.


It probably can, and it might just have been the thing to redeem java, were it not for the issue that you brought up.


My sister needs help with a programming problem so she PMed me for help. I'm too dumb to help her and she's too shy to post in this thread. Help me help her please?
I'm stuck on a programming/math problem. Can you help??

I'm making a tank shoot a shell. The tank can be anywhere, and the turret can be pointing any direction. The shell must appear at the end of the turret.

I've done the calculations of the relative position of the shell to the position of the turret, and gotten an x and a y. But those could be added or subtracted to the overall x and y of the turret, depending on its angle??



Is there any way to do this that doesn't involve a convoluted if/else to figure out which?? I feel like I'm missing something obvious.


I think that should work with the projectile emerging at [cos(theta)*cannonLength+tank.x,sin(theta)*cannonLength+tank.y]. Is that what you mean?


Do you want the angle based on the mouse position relative to the tank?


theta=atan((mouse.y-tank.y)/(mouse.x-tank.x))?


I think that should do it, but I'm a bit rusty here, so it may be wrong.

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8994 on: February 11, 2016, 11:53:39 pm »

So one of my classes (Principles of Languages) is done in a version of Scheme (specifically Racket, more specifically the legacy Racket language "Pretty Big"). While (being forced into) doing everything recursively is an interesting way of thinking, the lack of the program data divide is being pretty cool, and experiencing the great satisfaction being gained when a 3 line program solves your whole program is pretty awesome; it's horriblefying. I mean I don't particularly enjoy the idea of having to take multiple hours to come up with 4-line simple programs that I could crank out non-recursive versions (that probably work faster due to the C++ compiler) for in like 5 minutes. :P It's not helped by the fact that normal Racket has several very helpful functions that our legacy version doesn't support either. :-\

And ye gods the parenthesis. I can't imaging how normal coders in similar languages survive; it's already gotten bad enough that I've pretty much said "Screw the 'recommended' official coding style, C's 1TBS style here I come!", since at least it wrassles the parenthesis beast enough to make stuff somewhat intelligible, albeit only a little.
*i2amroy goes and cries into his drink

(It is kinda funny that my professor for the class is one of those hardcore LISP guys who never really gave up on the idea that LISP is "the future of programming". :P I mean don't get me wrong, LISP-related languages have their uses in places like pioneering new research algorithms and other specific types of work that benefit from it's advantages [though even in some of those fields they're starting to be beat out by things like Python for similar benefits or C++ for speed requirements], but they aren't exactly the language the vast majority of people reach for when they think "I want to code X to do Y", even when said people have been exposed to the benefits of LISP-y languages. Is it a nice tool that you should definitely learn? Yeah, even if only for the practice in a very different way of thinking. But as for "the future of programming", it's almost certainly never going to be the generic language that people grab first when they just need to code a generic something up.)
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

Bauglir

  • Bay Watcher
  • Let us make Good
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8995 on: February 12, 2016, 12:02:08 am »

Just run 2to3 on it. It'll probably work given that most of the issues are probably due to syntax.

That migration tool is great.

The python interpreter hasn't changed all that much, so there isn't much that should be an issue with the migration.
It is, in general, great, but it didn't do the job for reasons I can no longer recall clearly. I do remember that the library I was messing around with already had built-in Python 3 support, but that support was a new addition and still needed a few additional changes (that the dev implemented quite quickly after they were found). Probably typos or something in the bits written for 3?
Logged
In the days when Sussman was a novice, Minsky once came to him as he sat hacking at the PDP-6.
“What are you doing?”, asked Minsky. “I am training a randomly wired neural net to play Tic-Tac-Toe” Sussman replied. “Why is the net wired randomly?”, asked Minsky. “I do not want it to have any preconceptions of how to play”, Sussman said.
Minsky then shut his eyes. “Why do you close your eyes?”, Sussman asked his teacher.
“So that the room will be empty.”
At that moment, Sussman was enlightened.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #8996 on: February 12, 2016, 01:05:37 am »

My sister needs help with a programming problem so she PMed me for help. I'm too dumb to help her and she's too shy to post in this thread. Help me help her please?
I'm stuck on a programming/math problem. Can you help??

I'm making a tank shoot a shell. The tank can be anywhere, and the turret can be pointing any direction. The shell must appear at the end of the turret.

I've done the calculations of the relative position of the shell to the position of the turret, and gotten an x and a y. But those could be added or subtracted to the overall x and y of the turret, depending on its angle??
Is there any way to do this that doesn't involve a convoluted if/else to figure out which?? I feel like I'm missing something obvious.

This is probably not helpful, but in my own game I used transformation matrices for everything and it works. :v
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8997 on: February 12, 2016, 01:08:55 am »

For projectiles in my engine, I used vectors... sorta. It's a tile-based engine, and there's no subtile movement, but I had the projectiles track their own subtile movement by using a complex number that represents a direction in radians and a distance in terms of tiles from the projectile origin point. Then, I would convert the projectile's polar coordinate to a rect complex number and add the real part to x and the imaginary part to y.

...that may have been dumb in hindsight


EDIT: What the hell happened in the last two years of 0 experience with any language that explicitly uses them that made me suddenly understand pointers
« Last Edit: February 12, 2016, 01:13:56 am by Putnam »
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8998 on: February 12, 2016, 02:04:22 am »

For the tank problem, call the tank position (x,y), the turret angle a, and the length of the turret from the pivot point as d.

The basic way to use this information is with cos and sin. As angle a goes from 0 to 360, (cos(a), sin(a)) traces out a unit circle (assuming you're using degrees and not radians. if things go weird here, it's probably because your maths library is using radians, and you have to convert the degrees when needed).

The only caveat, is that whether you tie cos to x and sin to y, or vice-versa, is dependent on where you want zero degrees to be pointing: cos(0) = 1, and sin(0) = 0. So, if you use cos with the x value, then zero degrees will point along the x-axis, or if you use cos with the y value, zero degrees will point along the y-axis. You need to keep that in mind.

So the general formula for the front of the turret is:

tx = x + d * cos(a)
ty = y + d * sin(a)

But this will point "zero degrees" along the x-axis, so swap sin and cos if it suits you.

breadman

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8999 on: February 12, 2016, 12:45:37 pm »

One of the frequent jabs I've seen people take at Java for game development is the garbage collector.  I have almost no experience with Java and none at all with games written in it, but people blame the garbage collector for periodic and noticeable hiccups in framerates.  Is there any sort of support for making garbage collection more deterministic or otherwise mitigating the odds that it will kick in and hang the game for "long" periods of time?
There is!  Granted, I only know this because a client at my previous job used manual garbage collection without understanding why or how, and made performance so ridiculously terrible that they expected us to change everything to fit what they could manage to do.

For the tank problem, call the tank position (x,y), the turret angle a, and the length of the turret from the pivot point as d.

The basic way to use this information is with cos and sin. As angle a goes from 0 to 360, (cos(a), sin(a)) traces out a unit circle (assuming you're using degrees and not radians. if things go weird here, it's probably because your maths library is using radians, and you have to convert the degrees when needed).
The key here is that cos and sin are useful for angles that you won't find in a right triangle, so their results can be negative.  It's okay to always add, because for half of the angles, you'll be adding a negative number.
Logged
Quote from: Kevin Wayne, in r.g.r.n
Is a "diety" the being pictured by one of those extremely skinny aboriginal statues?
Pages: 1 ... 598 599 [600] 601 602 ... 796