Fortsätt till huvudinnehåll

Inlägg

Visar inlägg från mars, 2017

Next project, artificial neural networks

After I finish the Asteroids clone in Java (I now have a running version, but without all the polish) I am planning to read up on, and test some, artificial neural networking. The little I have read about it so far sounds very interesting. I am planning to start off with  this course  on Practical Deep Learning For Coders. A course that handles image recognition, convolutional neural networks, over fitting and under fitting, embeddings, natural language processing (NLP) and recurrent neural networks. Lets get finished with the game! (I have had a slow week since I have spent several days in bed with a fewer, not able to function at all, but now it starts to feel better).

Regarding the new features in C# 7.0

I have read through the  New Features in C# 7.0  blog post on Microsoft Developer Network (MSDN) and also tried them using Visual Studio 2017. My conclusion is that there is nothing revolutionary in C# 7.0. The features are all "nice to have" stuff. Out variables It is now possible to declare an out variable right where it is passed as an out argument. Example: // Before C# 7.0 int x; int y; GetSomeInts(out x, out y); // From C# 7.0 GetSomeInts(out int x, out int y); Personally I think this can be good to limit the scope of variables when using the Try-pattern (a method that returns a boolean to indicate success or failure and results as out parameters): if (TryParse(s, out string a, out string b)) {     // string a and b in scope and can be used here. } else {     // string a and b not in scope. } Pattern matching I am not a big fan of passing generic "objects" around and letting methods behave differently depending

Genetic Algorithm Kata - Done!

Continued with the games programming a bit - adding a Polygon Wrapper class that lets polygons wrap around the edges of the screen. Interesting solution. Also took a break from the games and solved a 2 Kyu task on Codewars that involved implementing a genetic algorithm. It was really interesting to see how such an algorithm can be used to solve a specific problem. The kata, with a thorough description, can be found on Codewars:  https://www.codewars.com/kata/526f35b9c103314662000007 Good stuff! Give it a try.

Async Delegate BeginInvoke Callback Example

I found it hard to find a straight forward example of Asynchronous invocation of a delegate using BeginInvoke and a callback that is called when the delegate is completed. So I wrote one myself. 1: using System; 2: using System.Runtime.Remoting.Messaging; 3: using System.Threading; 4: 5: namespace AsyncDelegates 6: { 7: public delegate int Add(int a, int b); 8: 9: class Program 10: { 11: private static volatile bool isCalculating; 12: 13: static void Main(string[] args) 14: { 15: Console.WriteLine($"Main() running on thread {Thread.CurrentThread.ManagedThreadId}"); 16: var theDelegate = new Add(Adder); 17: isCalculating = true; 18: theDelegate.BeginInvoke(7, 5, AdderCallback, null); // Runs the Add method on a separate thread. Calls AdderCallback when Add has finished. 19: while (isCalculating) // The isCalculating boolean is set to false in the AdderCallback method.

Games programming update

Still focusing 100% of my limited spare time on getting through the games programming book. Currently reading up on, and implementing, algorithms for intersection testing. Now I know what an Axis Aligned Bounding Box is ;).