Noob learns to code in 3 months

The Partridge Family were neither partridges nor a family. Discuss.
User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » June 29th, 2017, 5:04 pm

Alrighty :) Thanks!

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » June 29th, 2017, 5:35 pm

I make new study plans all the time but gonna try and follow this until august 21st

Step 1:
Red pill vids

Step 2:
3d fundamentals

Step 3:
Linear algebra

Step 4:
C++ book

Step 5 (if time left):
slidefucker and reread linear algebra

Bonus:
Keep watching intermediates as they come out.

Tomorrow I'll do repetition for intermediate stuff part 3-part 5 and then starting above plan on saturday.

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » June 30th, 2017, 12:49 pm

Today I did a bit of repetition for tutorial 3-5.
I also bought a book called "The manga guide to linear algebra"

I'm gonna learn how to math and how to kawaii at the same time!

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » June 30th, 2017, 4:33 pm

Before when I had a bigger playfield on this game. This recursive function gave me a stack overflow.
Is there a way I could dynamically allocate memory for something like this to prevent it from happening?

Code: Select all

void Board::Drop(int Y, int X)
{
	if (grid[Y][X] == empty)
	{
		grid[Y][X] = hidden;
	}
	if (grid[Y - 1][X] == empty)
	{
		Drop(Y - 1, X);
	}
	if (grid[Y + 1][X] == empty)
	{
		Drop(Y + 1, X);
	}
	if (grid[Y][X - 1] == empty)
	{
		Drop(Y, X - 1);
	}
	if (grid[Y][X + 1] == empty)
	{
		Drop(Y, X + 1);
	}
}

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Noob learns to code in 3 months

Post by albinopapa » June 30th, 2017, 6:56 pm

I don't think so because of how recursion works. Each call to a function puts all local variables onto stack and they aren't removed until the function is exited. There is a stack size limit as well as depth limit ( how many levels you can recurs ). If your field is large and there are a lot of free spaces to keep the recursion going, you'll always run into this problem. You CAN increase the stack size in the project properties, I don't know if you can change the recursion depth limit.

EDIT: Ran a couple of tests and tried looking up recursion limits, all I found was this. It doesn't specify recursion limits, but other limits. The tests I ran basically failed when running over the default 1MB of stack space. With a function that just passes on the parameter + 1 I get a depth of around 4027, and a function that creates 2 ints and passes them on, I get around 3220.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Noob learns to code in 3 months

Post by albinopapa » June 30th, 2017, 7:23 pm

Yumtard wrote:Today I did a bit of repetition for tutorial 3-5.
I also bought a book called "The manga guide to linear algebra"

I'm gonna learn how to math and how to kawaii at the same time!
Just read this post, funny shit.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Noob learns to code in 3 months

Post by chili » July 1st, 2017, 4:48 am

Looks like papa got you set while I was away. Lemme add my $0.02.
albinopapa wrote:I didn't follow along with the previous videos so I don't have all the utility functions. I did however try this homework using the STL, just to see what it'd look like. Most everything in the Database and Entry classes, were needed, so the only real savings were the utility functions prior to this lesson.

Chili really knows what he's doing, for all you following along, keep following.
Glad the homework was enticing enough to get you to mess around in it. Probably means a lot of learners tried their hands at it as well. I was considering revisiting this for the homework for strings and streams, but then decided to do something in one of the games instead.
Yumtard wrote:I'm not deleting the Tile field inside of MemeField. Do I need to do it?If I'm deleting field inside of game then doesn't the tile field also get deleted anyways?https://github.com/Yumtard/dynamic-memesbtw: if I close down the game while the sound is playing after I fail, I get an assertion fail. Why is that? It's this one
If you delete MemeField dynamic object, the only thing that gets freed is the memory for that object, not any of the dynamic memory that pointers in that object might point to. There is a way to get this to work automagically when you delete an object, but that will have to wait for the next tutorial ;)

The reason why you are getting the failure when you close down the game is because Memeield isn't getting destroyed properly and the song is still playing when end of program cleanup occurs. This will also be fixed in Tutorial 6.
Yumtard wrote:Today I did a bit of repetition for tutorial 3-5.
I also bought a book called "The manga guide to linear algebra"

I'm gonna learn how to math and how to kawaii at the same time!
Sounds good man. Of all the mathing you have to do in games programming, aside from basic arithmetic it's almost all linear algebra shit with maybe a little cherry of trigonometry on top. That is why I always tell people who think programming will be too hard because of math not to worry. In the grand scheme of things linear algebra is just the tip of the math iceburg. But because you're gonna be using it a shit-ton, it's a damn good idea to put some effort in and learn it inside and out.


And as for the recursion, there are a number of fixes you can implement. A straight recursive function is gonna eat stack space as a function of recursive depth, and there is only so much stack space you have. One fix is to increse the stack allocation (in linker settings I think), another is to optimize the recursive function to minimize the number of local variables/function parameters if possible. Probably the best optimization you can do is to modify the algorithm to reduce its maximum depth. I know for a fact the the recursive algorithm I have there could be made to run with a lot lower depth with some semi-clever improvement.

These are all band-aids though, as with a large enough field you will eventually run out of stack space. However, any recursive algorithm can be replaced by an equialent which runs in a loop and has its own stack-like data structure. The advantage of this is of course if you can use your own data structure then you are free to allocate it on the heap instead of the stack (automatic storage region). This technique is often required to solve shit like algorithmic programming challenges.
Chili

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » July 1st, 2017, 12:15 pm

albinopapa wrote:
Yumtard wrote:Today I did a bit of repetition for tutorial 3-5.
I also bought a book called "The manga guide to linear algebra"

I'm gonna learn how to math and how to kawaii at the same time!
Just read this post, funny shit.
:D It's actually a book that my future teacher recommended when I was in for interviews so I assume it should be pretty good.

chili wrote:Looks like papa got you set while I was away. Lemme add my $0.02.
albinopapa wrote:I didn't follow along with the previous videos so I don't have all the utility functions. I did however try this homework using the STL, just to see what it'd look like. Most everything in the Database and Entry classes, were needed, so the only real savings were the utility functions prior to this lesson.

Chili really knows what he's doing, for all you following along, keep following.
Glad the homework was enticing enough to get you to mess around in it. Probably means a lot of learners tried their hands at it as well. I was considering revisiting this for the homework for strings and streams, but then decided to do something in one of the games instead.
Yumtard wrote:I'm not deleting the Tile field inside of MemeField. Do I need to do it?If I'm deleting field inside of game then doesn't the tile field also get deleted anyways?https://github.com/Yumtard/dynamic-memesbtw: if I close down the game while the sound is playing after I fail, I get an assertion fail. Why is that? It's this one
If you delete MemeField dynamic object, the only thing that gets freed is the memory for that object, not any of the dynamic memory that pointers in that object might point to. There is a way to get this to work automagically when you delete an object, but that will have to wait for the next tutorial ;)

The reason why you are getting the failure when you close down the game is because Memeield isn't getting destroyed properly and the song is still playing when end of program cleanup occurs. This will also be fixed in Tutorial 6.
Yumtard wrote:Today I did a bit of repetition for tutorial 3-5.
I also bought a book called "The manga guide to linear algebra"

I'm gonna learn how to math and how to kawaii at the same time!
Sounds good man. Of all the mathing you have to do in games programming, aside from basic arithmetic it's almost all linear algebra shit with maybe a little cherry of trigonometry on top. That is why I always tell people who think programming will be too hard because of math not to worry. In the grand scheme of things linear algebra is just the tip of the math iceburg. But because you're gonna be using it a shit-ton, it's a damn good idea to put some effort in and learn it inside and out.


And as for the recursion, there are a number of fixes you can implement. A straight recursive function is gonna eat stack space as a function of recursive depth, and there is only so much stack space you have. One fix is to increse the stack allocation (in linker settings I think), another is to optimize the recursive function to minimize the number of local variables/function parameters if possible. Probably the best optimization you can do is to modify the algorithm to reduce its maximum depth. I know for a fact the the recursive algorithm I have there could be made to run with a lot lower depth with some semi-clever improvement.

These are all band-aids though, as with a large enough field you will eventually run out of stack space. However, any recursive algorithm can be replaced by an equialent which runs in a loop and has its own stack-like data structure. The advantage of this is of course if you can use your own data structure then you are free to allocate it on the heap instead of the stack (automatic storage region). This technique is often required to solve shit like algorithmic programming challenges.
Awesome :) Looking forward to tutorial 6!

Yeah my school will start with 6 intense weeks of linear algebra so I'd like to be at least somewhat prepared.

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » July 2nd, 2017, 12:17 pm

Study Update

Step 1, Red pills
Completed.
Watched the 2 red pills. They were a bit too red for me.
I decided for now it'll be enough to just watch them, get an idea of it and then move on.
If I understand correctly I wont have to think about this too much during normal programming. I'll go back and rewatch them if it feels needed at some point.

Step 2, 3d fundamentals

Watched part 0 and part 1

After part 0 I during the prerequisite list I realized I'm probably not really ready. I still lack some c++ and math knowledge. But I will still give it a try and go through them all, trying to understand as much as possible.
For step 5 which is supposed to be the last thing I do before school I was planning to do repetition of linear algebra and slidefucker. but might end up changing that to repetition of linear algebra and 3d fundamentals. At that point I should have more tools in my belt.

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » July 2nd, 2017, 8:18 pm

Productive day, rather than programming or doing something worth while I noticed I had 12.5k play money chips in my poker account. Started grinding play money tables and 4 hours later I have made 500k play money chips and 0 dollars

Post Reply