Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 525 526 [527] 528 529 ... 796

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

cerapa

  • Bay Watcher
  • It wont bite....unless you are the sun.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7890 on: September 22, 2015, 10:15:18 am »

Anyone know a tip for if and if else statements? I find that I can get my geometry calculator to work for Circle (other functions not done yet) I can make it so it gives me the right answer. But I'm not sure how to stop the user from giving me a negative number.

BTW I'm doing this in C++ but I can't exactly find the answer to my question in if statements part of cplusplus.com.


Spoiler: Code (click to show/hide)

Why are you calculating the answer before taking the inputs? You do realize everything is calculated in sequence, rather than retroactively?

Where is userRequest defined?

Why did you put an "endl" at the end of " cin >> radiousC"?

Why is "cout << circleAnswer<< endl;" not inside of an else block, if you want it to print error instead of the answer? According to the code, it will print "Error" and then the answer, onto the same line even. But I guess that was your question in the first place.
Logged

Tick, tick, tick the time goes by,
tick, tick, tick the clock blows up.

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7891 on: September 22, 2015, 10:16:25 am »

Anyone know a tip for if and if else statements?
Not entirely sure what you're asking. You mean like this:
Code: [Select]
if (condition)
    something;
else if (condition)
    something;
else
    something;
« Last Edit: September 22, 2015, 10:19:58 am by Bumber »
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7892 on: September 22, 2015, 10:35:57 am »

that code snippet shouldnt work at all.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7893 on: September 22, 2015, 10:37:45 am »

Just use the abs function on the input value.
Or do if(input <0) input = - input;
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7894 on: September 22, 2015, 12:10:16 pm »

<snip>
I've never had any problem placing submit buttons, and I don't use any specific tricks I need to remember. They go where I ask. Maybe you're not using divs and other elements properly. If you put an element inside a table cell it will stay in that cell. Maybe you forgot to wrap the submit button inside a cell, and it was just floating inside the table element? In that case, it would float to the top.

For the image alignment thing, it definitely needs less lines of code that you're saying. You can already treat an image as a div and all the CSS rules work pretty much universally. Maybe you can link to the solution and as a group we can see if that is in fact the simplest solution or whether there is a much more trivial solution where you just add one tag to an element.

Maybe it could use an overhaul. But at what cost? If the browser defaults were changed, then every classic site instantly breaks. Should millions of classic sites need to be rewritten because we changed how table layout defaults work? What about sites backed up in the internet archive? If we change modern browsers, none of those will render properly when we access them. Should we need to re-edit every site we pull out of the archive to conform to the latest standards so we can view them? They stick with the defaults because people still want older sites to not be broken, and by it's nature, browsers need to work for all sites, not just yours.
« Last Edit: September 22, 2015, 12:38:05 pm by Reelya »
Logged

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7895 on: September 22, 2015, 12:52:48 pm »

Is there even any Flash in common use, besides sites that specifically gather unique Flash content (Newgrounds, Kongregate, boorus, etc.)? I didn't like Youtube's HTML5 player at first, but now I'd never go back to the flash player.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7896 on: September 22, 2015, 01:03:42 pm »

Is there even any Flash in common use, besides sites that specifically gather unique Flash content (Newgrounds, Kongregate, boorus, etc.)? I didn't like Youtube's HTML5 player at first, but now I'd never go back to the flash player.
Generally, flash has been relegated to flash animations/movies and video players now. For a while there were sites which used flash for navigation etc, but that's seen as a very bad methodology now, and was significantly criticized when it was happening.
« Last Edit: September 22, 2015, 01:05:21 pm by Reelya »
Logged

Bauglir

  • Bay Watcher
  • Let us make Good
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7897 on: September 22, 2015, 01:11:47 pm »

I actually still force Flash on Youtube. Video quality in HTML5 is capped at shit for some reason.
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.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7898 on: September 22, 2015, 01:16:28 pm »

Probably the adaptive bitrate thing. You can see why ISPs are happier that Youtube does that.

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7899 on: September 22, 2015, 01:18:38 pm »

I can do 720p60 on my connection. 1080p60 usually takes ten billion years to buffer and then it freezes and stutters, but anything below that is fine most of the time.

It is a bit of a hassle to have to pick a higher quality for every video, though. For some reason, Youtube automatically picks the lowest quality available for any video that I watch, even though higher qualities are just fine.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7900 on: September 22, 2015, 01:21:15 pm »

You need to think about it not from a single-customer perspective, but from the perspective as one-customer-of-many.

If you are getting "HD-by-default", then so is everyone else on your ISP. Which slows down the entire network, and reduces the overall quality of what you yourself could watch. It's extra bandwidth used on every node from your ISP back to the youtube server, which means slower traffic of all kinds across all those nodes, and more packet loss / resends. What about if someone walks away / switches tabs, and leaves youtube playing in the tab? If it's HD by default, that's everyone's bandwidth chewed up delivering HD video to someone who's not even watching. By switching to minimum/passable for every video, you minimize this amount of wasted traffic. Which, again, increases the amount of free bandwidth for HD video or just general downloading. Reducing server load on youtube's end also increases the number of clients they can support and keeps costs down.

An amusing analogy (no offense meant, itisnotlogical) would be a bunch of people in a queue waiting to be served, and if you ask really nice, the server person will make you a cup of tea while you wait. Someone then says "hurumph! A cup of tea while I wait is a necessity, I shouldn't have to ask for a cup of tea, cups of tea should be the default! Honestly, they will make me a cup of tea if I ask so they musn't be that busy. Just make me a cup of tea without me needing to ask every time!" With the obvious outcome that they now spend most of their time making cups of tea for everyone, regardless of whether those specific people wanted the tea, or plan to drink it.

Because you just know that given the option, everyone is going to set: default video quality: fucking awesome for all their videos, all the time. Regardless of whether they need it or want it, or whether they're even paying attention.
« Last Edit: September 22, 2015, 01:50:28 pm by Reelya »
Logged

Bauglir

  • Bay Watcher
  • Let us make Good
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7901 on: September 22, 2015, 02:32:06 pm »

Yeah, my gripe is that it isn't even an option in HTML5, so...
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.

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7902 on: September 22, 2015, 04:03:18 pm »

Maybe it could use an overhaul. But at what cost? If the browser defaults were changed, then every classic site instantly breaks. Should millions of classic sites need to be rewritten because we changed how table layout defaults work? What about sites backed up in the internet archive? If we change modern browsers, none of those will render properly when we access them. Should we need to re-edit every site we pull out of the archive to conform to the latest standards so we can view them? They stick with the defaults because people still want older sites to not be broken, and by it's nature, browsers need to work for all sites, not just yours.
No offense intended, but to put it blunty that's not necessarily a good argument. I could just as easily say "Should millions of classic Windows 98 programs need to be rewritten because we changed the OS code by updating to Windows 7?" And of course you wouldn't do it in one jump, you'd support both for a while, then switch over to solely the new one, giving people time to migrate things and do reworks. Computer languages evolve over time and many eventually get dropped. Does anyone even still develop on COBOL anymore? (Yes, I realize there are probably still a very rare few people still using some form or other, but I know people who are still using Windows 98 too :P.) Just because people are still using something isn't necessarily a good reason why something shouldn't be changed, just another factor to take into account. You still need to eventually draw the line somewhere, and indeed we've seen at least some compatibility breaks showing up in Mac's Lion and Yosemite versions and in Windows 10.

An amusing analogy (no offense meant, itisnotlogical) would be a bunch of people in a queue waiting to be served, and if you ask really nice, the server person will make you a cup of tea while you wait. Someone then says "hurumph! A cup of tea while I wait is a necessity, I shouldn't have to ask for a cup of tea, cups of tea should be the default! Honestly, they will make me a cup of tea if I ask so they musn't be that busy. Just make me a cup of tea without me needing to ask every time!" With the obvious outcome that they now spend most of their time making cups of tea for everyone, regardless of whether those specific people wanted the tea, or plan to drink it.
Similarly something like this is again just another factor to consider in a given situation. If 60% of people didn't want any tea, and only 5% of people would actually drink the tea, then it's obviously not going to be something you want to do. On the other hand if 95% of people are going to ask you for tea, and almost every one of them is actually going to drink it, then you're actually going to save time in the long run by simply running your tea as an opt-out instead of an opt-in, because the time it takes you to deal with 95 people asking you for tea is going to outweigh the cost of 5 people asking you to not have tea enough to cover any extra cups you accidentally make.

Right now we the majority of people can't handle video quality: fucking awesome, and many people don't even want it (usually because they know they can't handle it). On the other hand 20-30 years from now, when hopefully the majority of us have some form of fiber/etc. and 95% of people can handle it? Then yeah, I'm gonna want to change the defaults at that point, because the amount of bandwidth wasted by the 5% who start loading and have to reload when they switch to a lower quality level is going to far outweigh the amount of bandwidth and time cost by forcing the other 95% to go and change the quality setting every single time.

It's just basic cost/reward analysis, and, based on my personal experiences, there's a lot that could be done. That's not necessarily saying that that's what should be done, though! I'm obviously still learning and I'm sure there are tons of people out there with more experience than me and with better access to widespread data on the language's problems, complaints, and so forth. I'm just stating what I, through my personal experiences, have encountered in my dealings with it.
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.

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7903 on: September 22, 2015, 04:20:08 pm »

this.PTW();
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7904 on: September 22, 2015, 05:05:06 pm »

Windows 98 programs are different. You can get new versions of programs released whenever you want. But the old programs still work on the correct operating system, so you can still run Windows 98 if you want. Whereas a website is a single resource which must be used by all clients. Changing the interface breaks both new sites on old clients and old sites on new clients.

The end result will be that you end up putting in things like "table-layout:fixed" anyway just to ensure cross-compatiblity with all generations of browsers. And all old-style tables would now need "table-layout:auto" style tags put in to ensure they don't look different to before, meaning even more typing since you can no longer count on any particular table behaviour by default. So the end result would be that unstyled tables would be at the whim of whichever browser someone just happened to use. Which is a qualitatively worse outcome than just not liking the default for the one site you're making.
« Last Edit: September 22, 2015, 05:27:18 pm by Reelya »
Logged
Pages: 1 ... 525 526 [527] 528 529 ... 796