Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 613 614 [615] 616 617 ... 796

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

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9210 on: March 07, 2016, 12:52:03 am »

To be fair, I'm just exploiting the Python 2/3 dichotomy. Which is, uh, basically just that (and unicode shenanigans).

That dichotomy does make developing in python (developing, not just home scripting) a bit harder in some ways than some other stuff, though.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #9211 on: March 07, 2016, 01:28:33 am »

Both print() and print are correct in Python 2.7, of course. Though, I think print() just prints a tuple in Python 2.7...

I haven't tried this out, but my understanding is

print(string) works fine because it looks like the string concatenation format where ("string1""string2") becomes "string1string2". print(string1, string2) is printed as (string1, string2) because its now a tuple!
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

Lightningfalcon

  • Bay Watcher
  • Target locked. Firing main cannon.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9212 on: March 07, 2016, 03:41:39 am »

Is there any reason why having code like this
int main()
{
   cout << "WTF";
   RandomObject obj(stuff);
}
will not print out stuff to the terminal? If I leave the object constructor there I get a segfault, which I can't easily test because I can't print out any information. If I comment out the object constructor then it will print fine. I know with printing to files and stuff there can be some kind of weird shenanigans with the stack and the program crashing, but I've never had a problem with direct IO to the terminal before.

EDIT: Changed a few words on my google search and I was able to find a solution. Its possible to manually flush cout which will do something. Important thing is that I can indeed see that I'm getting my segfault the moment that I start the loop. Which... does not help me out at all.
« Last Edit: March 07, 2016, 04:08:42 am by Lightningfalcon »
Logged
Interdum feror cupidine partium magnarum circo vincendarum
W-we just... wanted our...
Actually most of the people here explicitly wanted chaos and tragedy. So. Uh.

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9213 on: March 07, 2016, 04:10:39 am »

Yeah, if you odn't put << endl; at the end of the cout, it won't flush right there and it might crash before the print.

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9214 on: March 10, 2016, 09:10:28 pm »

https://www.youtube.com/watch?v=QM1iUe6IofM
"Object-Oriented Programming is Bad"
Logged

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #9215 on: March 10, 2016, 09:42:20 pm »

Didn't watch the whole thing because eh, but it sounds a lot like what I thought of Java, coming from a self-taught OOP angle. Following OOP too strictly is dumb, but so it totally eschewing it.
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.

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9216 on: March 10, 2016, 10:18:06 pm »

https://brianmckenna.org/blog/line45
"Object-Oriented Programming is Bad"
FTFY

Actually, watching it, my link isn't quite as accurate as I first thought. But I still like using that link whenever I can. So it stays.
« Last Edit: March 10, 2016, 10:23:06 pm by Willfor »
Logged
In the wells of livestock vans with shells and garden sands /
Iron mixed with oxygen as per the laws of chemistry and chance /
A shape was roughly human, it was only roughly human /
Apparition eyes / Apparition eyes / Knock, apparition, knock / Eyes, apparition eyes /

Parsely

  • Bay Watcher
    • View Profile
    • My games!
Re: if self.isCoder(): post() #Programming Thread
« Reply #9217 on: March 11, 2016, 12:28:24 am »

I'm not sure whether this SQL query is a bad idea.

SELECT * FROM reservations WHERE
     (startdate < '5' AND '5' < enddate)
  OR (startdate < '6' AND '6' < enddate)
  OR ('5' < startdate AND enddate < '6')
  OR (startdate < '5' AND '6' < enddate)
  OR (startdate == '5' AND enddate == '6');


The idea is to compare with given start and end times ('5' and '6' in this test-case, I was using SQL fiddle) against the database and return all that overlap. I have five groups of comparisons because there are five cases where two events (e1, e2) could overlap: e1 is partially overlapping either in front or behind e2; e1 entirely encompasses e2 or vice versa, and e1 is identical to e2.
People mentioned using '<=' and here's the syntax for that.

Code: [Select]
SELECT *
FROM reservations
WHERE
    startdate >= '5' AND '6' <=;

But! Another cool way you could do it is:

Code: [Select]
SELECT *
FROM reservations
WHERE
    startdate BETWEEN '4' AND '7';
^^It does exactly what it says on the tin (very specifically it returns all rows from the reservations table that contain the values 5 and 6), and this will still work even if you replace '4' and '7' with actual DATE values like '01-12-1997' since it will implicitly CAST them, but just be careful your formatting is correct when you do that. SQL is actually pretty good at reading date strings.
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #9218 on: March 11, 2016, 02:41:52 am »

SQL is quite interesting, having special syntax for a < x < b and all :P

Incidentally, I'm actually using epoch time for the date instead of a string.

Also McFry said the simplest way to check that two time intervals above, so I'm currently using that!
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

Parsely

  • Bay Watcher
    • View Profile
    • My games!
Re: if self.isCoder(): post() #Programming Thread
« Reply #9219 on: March 11, 2016, 02:45:53 am »

SQL is quite interesting, having special syntax for a < x < b and all :P

Incidentally, I'm actually using epoch time for the date instead of a string.

Also McFry said the simplest way to check that two time intervals above, so I'm currently using that!
* GUNINANRUNIN just wanted to share since this is the first time he ever saw a question in this thread he knew he could answer.

SQL is really really good at what it does and I like it.
Logged

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9220 on: March 11, 2016, 11:51:08 am »

I hate it when something seems fine, yet it is actually completely incorrect and only appears to work because I've been testing it in exactly the wrong conditions.

It's a long story and I'm quite sick of thinking about it, but I pretty much forgot literally everything I knew about vector math and wrote some really really dumb raycasts as a result.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9221 on: March 11, 2016, 07:18:42 pm »

I've done almost the exact same thing.  Well, in my case I just wrote some interestingly broken vector math code that was just wrong by a little bit most of the time.  I think it was a vector dot or cross product function... anyway, it took me a good long while to figure that mess out since I couldn't really get a good intuitive feel for what the results should have been, which means I didn't blame the vector code for errors for way too long.

Anyway, my research has really taught me to hate code that looks like it's working when it isn't.  I have a program that sifts through about 4GB of protein data and outputs results.  The results look reasonable, but are they correct?  Who knows!  About five times by now I've said, "Yes, that is correct," only to discover a major bug in my software.  There's way too much data to hand verify it or step through it with a debugger for more than a sequence or two, so if you have a bug that's only triggered on 10% of the sequences you may never realize it.

So... I really don't trust anything that comes out of it anymore and mostly just care about the performance numbers since that's what my research is about in the first place...
Logged
Through pain, I find wisdom.

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9222 on: March 15, 2016, 10:04:40 am »

I have several humanoid models that all have four to six materials on them, bog-standard shaders that don't have any special behavior at all. If I were to combine the textures (RGBA and a normal map) of all these materials into one massive image (4096 * 4096) and use one single material with the appropriate UV mapping for that image, would there even be any performance benefit? What if I shrunk the combined textures to 2048 * 2048?
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9223 on: March 15, 2016, 10:10:58 am »

There would be.

Each different model needs a different call to the gpu whenever you want to draw it.

Combining the textures allows you to combine the model as well, which speeds things up.
Logged

Spehss _

  • Bay Watcher
  • full of stars
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9224 on: March 15, 2016, 01:24:58 pm »

Writing a program for a college class assignment.

Trying to use strcpy() function in a method of a class in c++. Compiler gives me an error, saying that "strcpy was not declared in this scope".

I don't see why it's not working.

Spoiler: code (click to show/hide)
Logged
Steam ID: Spehss Cat
Turns out you can seriously not notice how deep into this shit you went until you get out.
Pages: 1 ... 613 614 [615] 616 617 ... 796