Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 575 576 [577] 578 579 ... 796

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

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8640 on: December 09, 2015, 08:51:08 am »

Hey guys, I want to hear your opinion on something. (I'm annoying everyone with a knowledge of programming better than mine with it  :P)

What do you believe is better? To read a bit about any language and then teach yourself the rest by googling, reading snippets and all that stuff (Slower, but "easier", so to speak) or reading a book entirely and doing what it says?

Depends on what book. If you're going to buy a paper version of a C++ reference manual, then don't, because it will go out of date and then you will have a giant book that you can't use. If you're going to buy a book about a specific topic that you want to learn in-depth, then it's probably a good idea.

The best way to learn is to make something.  And not something insane, something like a mini-text rpg with dice rolling and input/output, etc.  Yes, this is simple, it doesn't have to be Cataclysm.

Theres definitely merit in following tutorials or reading a book all the way thru, but IMO: get your basic setup done, figure out what you want to do, then start doing it and learning all the actual references you need to look up.  You will run into roadblocks, sure, but you can get past them.   Your drive to complete the project will help, instead of just doing checkmarks and saying 'I read 5 pages today' or 'I did the exercise section' or whatever.

Past that, you can just keep making stuff all the way up, and maybe getting some use of what you make too, instead of just dumb tutorial projects.

Yeah, don't make something big. If you ABSOLUTELY want to emulate something, find the smallest, most basic piece of it and start attacking that tiny subset of the larger project. Like, for Cataclysm, look at creating rooms on screen with Curses. If that's too big, look at the Curses library in general; if that's still too big for you, look at 2D arrays; if that's still too big, etc. etc.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

DrunkGamer

  • Bay Watcher
  • Beer loving Gentledwarf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8641 on: December 09, 2015, 02:03:12 pm »

I'm reading a bit about C++, but until I get the hang of it I think I'll keep on practicing Python.

Anyone here is good with tkinter/any other GUI framework for python? Where can I find a good tutorial? I have been searching for a long time, can't find much.

(Python 3)
Logged

breadman

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8642 on: December 09, 2015, 02:14:10 pm »

i would like to buy your patent

Sorry, but it was filed by the company who employed the rest of the inventors, and the resulting product turned out to not be nearly as effective as had been hoped.  My current interest in it is merely as resumé padding.
Logged
Quote from: Kevin Wayne, in r.g.r.n
Is a "diety" the being pictured by one of those extremely skinny aboriginal statues?

RoguelikeRazuka

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8643 on: December 11, 2015, 04:34:54 pm »

Hey the thing is that I'm making an Arkanoid game using SFML (C++) now, and who of you guys could consult me about how to make the game switch between different game states? What is the basic concept?
« Last Edit: December 11, 2015, 04:37:18 pm by RoguelikeRazuka »
Logged

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8644 on: December 11, 2015, 08:43:22 pm »

I can think of a function where recursion is required. The Ackermann function.
100% Required or just preference? In my opinion it's extremely rare to find an algorithm which absolutely cannot be converted between iteration and recursion if you put some effort in.

A quick google shows that it's possible to write a loop version, and I'm pretty sure that the loop version could be optimized faster.
http://stackoverflow.com/questions/10742322/how-to-rewrite-ackermann-function-in-non-recursive-style

Ah, Ok. I just couldn't think of one myself.
Recursion is just a special case loop with redundant state data that expands in size at a rate of O(n)=n where n is the depth of the recursion. That's all it is. There is no recursive function which cannot be written as a loop.

Which also means that for most cases of recursion, you can implement a superior performance version of it by turning it into a loop and cutting down the state space. And with the benefit of removing the unknown state size for most cases of an unknown recursion depth, which can cause stack overflows and such.

For some platforms, like the GPU, you don't even have recursion available for precisely the reason of stack space. The CPU has the benefit of big gobs of memory and cache for each thread to waste; but on the GPU, you've got a few bytes per thread, and so there really is no stack. Even if you could have one, with the hardware restraints, using a recursive algorithm would bring you down to like a 10% or less of your ideal performance just from memory transactions alone.

This is also why most papers about GPU implementations of algorithms are mostly about reducing state space. In the CPU recursive implementations, they waste all this space and jam it in the stack when each call and return stores and loads all the data in and out. On the GPU, the state space needs to be close to nothing for optimal performance.
Logged

jaked122

  • Bay Watcher
  • [PREFSTRING:Lurker tendancies]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8645 on: December 12, 2015, 02:05:52 am »

ITT you're confusing the concept of recursion with the implementation that exists on most computer systems.

Recursion is merely a means of describing a certain relationship. Recursion in the cases where it is easy to replace with a loop are generally poor applications of the principle.

Why are we still talking about it? If you aren't programming in a functional language, it's probably not a good idea to use recursion in place of a loop as it isn't likely to be tail recursive, and therefore not changed into a  loop.

Who's writing an ackermann function for the GPU?

They should know that they also won't be able to use the stack in such a manner as is required by it. The best you can do is use tail recursion while defining the cases for m = 0-3, or beyond if that's what's desired.

In any case, you're still using the stack, therefore using the same implementation mechanics as the naive recursive version. I'm going to call it recursive because it still requires the precise semantics of the recursion to function.

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #8646 on: December 12, 2015, 03:02:05 am »

Anyone here is good with tkinter/any other GUI framework for python? Where can I find a good tutorial? I have been searching for a long time, can't find much.
I have never in my life seen a good tutorial for tkinter (not for wont of searching, mind). There's a bit of (surprisingly shoddy) reference material in the official manual. There's a couple of okay guides and such floating around for Python 2. I even had a CS class in highschool that had a section on Python and tkinter, but that really bad (half the time the students had to teach the teacher).
It's easy enough once you get the hang of it, but getting the hang of it is an absolute pain. I might have some example code laying around somewhere if you want it.

...

Who's writing an ackermann function for the GPU?
Computer scientists, obviously.
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.

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8647 on: December 12, 2015, 04:14:34 am »

I downloaded Monodevelop (well Xamarin Studio, same difference). The code completion is way too fucking aggressive. Like, I can barely type a word without it auto-completing something. Is there anyway to maybe make it less aggressive while still showing the autocomplete window? From looking at the options, it seems like my only choice is all-or-nothing.
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 #8648 on: December 12, 2015, 07:52:39 am »

idk, but the recently released Unity 5.3 apparently features a big overhaul to the Monodevop UI system, so anything you tweak with it will have to take that into account since it could all be different now. If you're running something that uses Monodevelop then check whether you're on the latest version or the pre Unity 5.3 version. You could also possibly try other IDEs since a lot of Unity developers use Visual Studio instead of Monodevelop.
« Last Edit: December 12, 2015, 07:54:34 am by Reelya »
Logged

3man75

  • Bay Watcher
  • I will fire this rocket
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8649 on: December 12, 2015, 09:29:45 pm »

Turns out I don't need vectors now because teacher said so.

I have a final on monday and I decided to do practice project to well, practice. Problem is I can't seem to find my error and my compiler says that my array which is a double, isn't compatable with a variable which is also a double.

Spoiler (click to show/hide)

The program is really small and in C++ btw. Right now i'm trying to accomplish filing the array with prices (such as 10.50 and etc) but like I said above it seems to stop around main.
« Last Edit: December 12, 2015, 09:42:27 pm by 3man75 »
Logged

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8650 on: December 12, 2015, 09:41:40 pm »

That's because main's bookARRAY is of type double[], while getBookPrices' bookARRAY parameter is of type double.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8651 on: December 12, 2015, 09:45:11 pm »

Isn't string std::string? You have using namespace str; after your first mention of string, but I don't quite remember if that matters.

Bauglir

  • Bay Watcher
  • Let us make Good
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8652 on: December 12, 2015, 09:48:07 pm »

The error is coming up on the line

Code: [Select]
Prices = getbookPrices(bookARRAY);
right?

The problem is that you're trying to call a function on an array, but it requires a double. Not an array of doubles. Declare the function as

Code: [Select]
void getbookPrices(double[] bookARRAY)
I think, and delete the line in the function where you return something. Then, since you don't seem to be doing anything with Prices, don't bother declaring it and instead just write

Code: [Select]
getbookPrices(bookARRAY);
If I'm remembering how C-style languages work, when you pass an array to a function it will be modified in-place. That is to say, the array you sent in will be changed if you make any changes inside the function. So, once your main function resumes after the function call, if you print bookARRAY, it will have changed (the reason it works like that, rather than how you've learned it deals with things like integer variables passed to an array, has to do with how the computer handles things like arrays in memory, but I'm guessing pointer stuff is beyond the scope of the class).

I don't know what the function's actually supposed to be doing, and it makes no sense to me, but maybe I just don't understand C++ syntax for for loops. So I can't help you there.

Telling us what the program is supposed to do would be a good thing.

EDIT: ninjas
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.

3man75

  • Bay Watcher
  • I will fire this rocket
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8653 on: December 12, 2015, 09:54:19 pm »

Isn't string std::string? You have using namespace str; after your first mention of string, but I don't quite remember if that matters.

When using "namespace std;" you are basically using a function that allows you to write code without saying std:: all the time. I hope I explained that correctuly.

That's because main's bookARRAY is of type double[], while getBookPrices' bookARRAY parameter is of type double.

I don't follow very well. How is this a problem and how do you fix it?



If bookARRAY in main is a double and is being passed to my function (which is getBookPrices) then shoudn't it also be a double?


Ninja'd. I need the return to give me back the sum of book prices. Also I can't follow very well, when you say "...Your trying to call a function on an array..". I hope i'm not sounding dense.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8654 on: December 12, 2015, 09:56:25 pm »

double[] and double are different types. The former is an array of doubles, the latter is a double. You're calling a function that wants a double as an argument but you're putting in a double[], or an array of doubles.
Pages: 1 ... 575 576 [577] 578 579 ... 796