Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 223 224 [225] 226 227 ... 796

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

dreadmullet

  • Bay Watcher
  • Inadequate Comedian
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3360 on: November 01, 2012, 08:08:46 pm »

If anything, "~=" should mean "is almost equal to", as a way of comparing floats and such. I know Lua uses "~=" as a replacement for "!=", which is strange, since it's supposed to be heavily influenced from C++. Eh, I don't understand what's wrong with "!=".
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3361 on: November 01, 2012, 09:02:38 pm »

A coworker, our current senior-most-programmer, has decided the new system he's going to be working on will use "~" to represent the not symbol (and "~=" to represent not equals) instead of the more tradition ruby "!" and "!=".

His reason is that "I don't like how bangs look, the tilde looks much better."

This explains why he previously created his own "Not" method and used that almost exclusively up until this point, I suppose.

In other news, I'm now officially hunting for a new job.

If he had cited unary operators as a reason, then that would be somewhat valid. Preferring how tildes look over bangs is not valid. He is bad and should feel bad.

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #3362 on: November 01, 2012, 09:59:40 pm »

but ~= is the approximately equal operator!
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3363 on: November 01, 2012, 10:11:23 pm »

but ~= is the approximately equal operator!

In mathematics, yes. But computer science has a tendency to shit on mathematical notation. Also, if you can find me a good use for the ~= operator in a programming language that can't be done just as succinctly and lucidly, or more so, then I will give you an internet cookie.

For example, the ~= operator would require 3 arguments: the two floats being compared, and the greatest allowed difference for the floats to still be considered approximately equal. That can just as easily be done like so:

Code: (Python) [Select]
import math
def approx(a,b,epsilon):
    return math.abs(a-b) <= epsilon

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3364 on: November 01, 2012, 10:13:35 pm »

but ~= is the approximately equal operator!

And you get the real meat of why this makes me so immensely negative emotioned. The code it's replacing even USED that mean approximately equal - not it will mean the exact opposite!

I'm going to cry if I keep talking about this. I need to go back to trying to figure out event handling for my game and calm down.
Logged

MadocComadrin

  • Bay Watcher
  • A mysterious laboratory goblin!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3365 on: November 01, 2012, 10:30:21 pm »

A coworker, our current senior-most-programmer, has decided the new system he's going to be working on will use "~" to represent the not symbol (and "~=" to represent not equals) instead of the more tradition ruby "!" and "!=".

His reason is that "I don't like how bangs look, the tilde looks much better."
Ruby? How about nearly any widely used language that doesn't use the explicit word "not?"
Please tell him the last time you see him that you don't like the way his face looks and that a paper bag would look much better. :/
Logged

kaijyuu

  • Bay Watcher
  • Hrm...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3366 on: November 01, 2012, 10:49:08 pm »

What the fuck use is an "approximately equal" operator? Within what bounds? :P It just seems so... vague and arbitrary.
Logged
Quote from: Chesterton
For, in order that men should resist injustice, something more is necessary than that they should think injustice unpleasant. They must think injustice absurd; above all, they must think it startling. They must retain the violence of a virgin astonishment. When the pessimist looks at any infamy, it is to him, after all, only a repetition of the infamy of existence. But the optimist sees injustice as something discordant and unexpected, and it stings him into action.

eerr

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3367 on: November 01, 2012, 11:14:30 pm »

What the fuck use is an "approximately equal" operator? Within what bounds? :P It just seems so... vague and arbitrary.


Float values aren't perfectly accurate.

They are NOT decimals, they are fractions, and get rounded to the nearest fraction.

From the larger double operations, no less.

The perfect accuracy is lacking.
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3368 on: November 02, 2012, 12:34:03 am »

What the fuck use is an "approximately equal" operator? Within what bounds? :P It just seems so... vague and arbitrary.


Float values aren't perfectly accurate.

They are NOT decimals, they are fractions, and get rounded to the nearest fraction.

From the larger double operations, no less.

The perfect accuracy is lacking.

Maybe, instead of what I thought, it could be to determine if two floating-point numbers could be results of the same operation?

Damnit, we're putting too much effort into something stupid.

MadocComadrin

  • Bay Watcher
  • A mysterious laboratory goblin!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3369 on: November 02, 2012, 01:06:30 am »

What the fuck use is an "approximately equal" operator? Within what bounds? :P It just seems so... vague and arbitrary.
Significant Figures vs Accepted Values/Values with more Significant Figures.
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3370 on: November 02, 2012, 01:08:13 am »

What the fuck use is an "approximately equal" operator? Within what bounds? :P It just seems so... vague and arbitrary.
Significant Figures vs Accepted Values/Values with more Significant Figures.

SigFigs? IN MY COMPUTER SCIENCE?

GTFO.

MadocComadrin

  • Bay Watcher
  • A mysterious laboratory goblin!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3371 on: November 02, 2012, 01:14:21 am »

You don't understand: we need to ally with the Physicists and the Chemists before they ally with the Biologists so we can make androids to fight their genetic super-mutants!
Logged

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3372 on: November 02, 2012, 01:21:51 am »

Pfft, we're programmers. We use magic-boxes to build universes. We beat all three by distracting them until they forget all they have learned. "I could make a super-mutant army.... but on the other hand.... just one more turn. OuO"

I have a hard enough time not distracting myself by opening up that erosion simulation, letting it run for hours, and just sitting there, watching it. It's terrible for productivity >_<
« Last Edit: November 02, 2012, 01:26:06 am by alway »
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3373 on: November 04, 2012, 09:28:11 am »

HELP Dx
The problem: There is a vector of a structure that includes a string, "plantname". It's referenced in a different class to draw it to the screen. However, somewhere between writing it and reading it, it gets wiped.

Here's the snippets of relevant code:

Spoiler (click to show/hide)

This has stumped me for a good hour.
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

DrKillPatient

  • Bay Watcher
  • The yak falls infinitely
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3374 on: November 04, 2012, 06:54:53 pm »

I've got a programming-logic quandary:

In a tile-based game, caves are generated randomly. Some are disconnected from others, and the game flood-fills these areas, setting each isolated group of tiles as a separate subregion. These subregions are stored as a vector of 2D coordinate points, which are run through one-by-one to apply various changes to a subregion. Each 2D point stored in the vector refers to a point on the map that is within the subregion. In addition, each tile on the map stores an integer referring to the index of the subregion in which it resides (-1 if it does not belong to a subregion).

If I want to ensure that each subregion is connected to, say, all other subregions within 20 tiles (IFF those subregions can be reached with a straight line), what's the best way to compute that? All I need is to find one point on the edge of one subregion, then find a reasonably close point on the nearest subregion. With that data, I can begin to draw tunnels.
Logged
"Frankly, if you're hanging out with people who tell you to use v.begin() instead of &v[0], you need to rethink your social circle."
    Scott Meyers, Effective STL

I've written bash scripts to make using DF easier under Linux!
Pages: 1 ... 223 224 [225] 226 227 ... 796