my solutions
my solutions
I'm currently on Intermediate C++ Game Programming and Im really enjoying it so
I'll post some of my own solutions for homework here, before watching chili's solution.
Would love to hear anyone's feedback.
Here is my solution for |Homework 5|.
https://imgur.com/a/O7eDMuH
I'll post some of my own solutions for homework here, before watching chili's solution.
Would love to hear anyone's feedback.
Here is my solution for |Homework 5|.
https://imgur.com/a/O7eDMuH
Re: my solutions
The homework was about dynamic allocation of the memefield so first I changed filed[] to field*. I then moved most of the stuff from the constructor of memefield to function called setField which allocates new array on the heap and passes it's address to *field. Is there going to be any memory leakage in my solution?
Re: my solutions
Seems good, except you're not freeing the memory when the game is destroyed (this tutorial is before destructors if I recall correctly, so you're okay not implementing a destructor). You'll learn a lot more about memory leaks in the next vidja
Chili
Re: my solutions
If we dynamically alocate new object and this object has member variables which are not created with the 'new operator' like 'int width' and 'int height', are these member variables stored in the stack or they are stored in the block of memory allocated for the object ?
Re: my solutions
if you new an object up, ALL members are stored on the newed block on the heap.
a class has int x,int y,int* p
p is set to new int[x*y] in ctor
you new an object
x y p are all stored in the heap object of the new
the target of p is stored in a different heap object
a class has int x,int y,int* p
p is set to new int[x*y] in ctor
you new an object
x y p are all stored in the heap object of the new
the target of p is stored in a different heap object
Chili
Re: my solutions
Makes sense now, thanks.
On Homework 6 where we have to implement a stack with linked lists,
I've solved all tests and had no memory leaks but my solution is a mess compared to yours which is so elegant and simple using recursion.
You've put a lot of thought in these challenges and I really appreciate them.
On Homework 6 where we have to implement a stack with linked lists,
I've solved all tests and had no memory leaks but my solution is a mess compared to yours which is so elegant and simple using recursion.
You've put a lot of thought in these challenges and I really appreciate them.
Re: my solutions
Dude, I'm glad you appreciate them.
I put extra effort into the I6 homework, hearing that makes it worth the while
I put extra effort into the I6 homework, hearing that makes it worth the while
Chili
Re: my solutions
On your word guessing game tutorial you mention something about a bot, but I can't find anything on your github. Very interested to see how it is implemented and how fast will it find the word.
Re: my solutions
Yeah, the bot ain't on the github. Also, it's written in C#. I might be using a C# Dictionary for the lookup (basically a hash table I believe, C++ equivalent is unordered_map)
Chili
Re: my solutions
Some extremely talented hacker also made a solver for the bot, no clue how: https://i.imgur.com/eEjjUGU.gifv