Unity3D/C# - Asynchronous Programming - Coroutines vs await/async

First, let me talk a little about Asynchronous Programming. Async programming is basically to run program logic independently of the main thread. This means that if your logic running asynchronously get stuck into a loop or processing something it won't freeze the main thread.

Async programming is mainly used with multithreading. In many languages, you have native high-level ways to represent a separate thread from the main thread and send some work for it to do.

What does it have to do with Coroutines in Unity?

Well, Coroutines are a workaround that Unity made in order to allow people to easily write async code. But keep in mind, Coroutines are not multithreaded.

Now let's look a little into the Coroutine API.

public IEnumerator SomeCoroutine() { //... do something yield return null; yield break; } Well, coroutines are basically methods that return an IEnumerator. So, in order to explain better how Unity's Coroutines work we need to take a loot into IEnumerator.

Tools and Property Drawers

Hi :)

I think there 2 kinds of tools that help development. Tools that speed up processes and tools that help visualize data. For the first type, most of the time they specific to a given project and they are usually reused or adapted for similar projects. The second type is more generic, they are specific for some data but different projects deal with a common data format.

In Unity3D we have Custom Editors and Property Drawers. Custom Editors are more commonly used for the first type of tools. They include new windows, custom inspectors are custom Scene GUIs. Property drawers are more of the second type, they are just some fancy way to show certain data.

Well, I think visualization is power and that everyone should know how to use Property Drawers since they are easy, fast and helps you and others understand whats is going on in the game.

Let's start with a simple Interval struct. Most games make use of some kind of interval for many variables, usually referred as resources (e.g.…

PCG and Data Analysis - Two sides of the same coin? Also, GANs?


PCG stands for Procedural Content Generation. PCG is an area of AI that has appeared because of games (different than other areas of AI that appeared because of scientific research and ended up being used in games).

Data Analysis

Data Analysis comes from statistics. It has been widely studied and from a long time, people have started to apply computer algorithms to data analysis. In AI, many widely popular topics related to data analysis (neural networks, data mining, big data, etc..). What all the algorithms used have in common is that they effectively look at data, analyse it and try to infer or predict some information or behaviour from the data.


How do these 2 concepts relate? Well, first they are both related to AI.

Now let's analyse the etymology of PCG a little.

"Procedural" is an adjective with origin on the word procedure. In computer science, a procedure is normally associated with a function. It is a series of commands that will be executed in orde…

C# - Simple Graph Interfaces and a MeshGraph

In a previous post about grids, I declared some interfaces to deal with graphs in an effort to explain how the grid segment could be treated as a graph.
Now I'm going to step further and define some generic graph interfaces as well as a MeshGraph that implements it based on the Mesh data structure from Unity3D.

To start, a vertex in a graph can be anything. So it will be an open type parameter for all interfaces.

An edge is a connection between 2 vertices, and as such, it can be defined as:

/// <summary> /// An edge is simply a conection between 2 vertexes /// </summary> /// <typeparam name="TVertex">Vertex Type</typeparam> public interface IGraphEdge<TVertex> : IEquatable<IGraphEdge<TVertex>> { TVertex VertexA { get; } TVertex VertexB { get; } }
Now, let's move to the graph. Starting with a read-only graph.

/// <summary> /// A read-only graph is a collection of vertices with methods to get the edges /// </sum…

Programming logic and logic programming

I see many people speaking about programming logic when they refer to programming. Well, there is no formal logic definition for programming logic. What people usually refer when using this term is structured programming, object-oriented programming or procedural programming.

Now let's talk about logic programming, which is something entirely different from programming logic or any of the popular definitions for it. Logicprogramming was one of the first ways to program and is based on formal logic.

Formal logic also has some popular confusion about it, when speaking about formal logic some people confuse it for Boolean Algebra. Well, let me try to make it clear: Formal logic is something most people "kinda" know but never really thought about it and logic programming is based on that. Everyone must have read sometime these kinds of phrases:

Concrete is grey.
Walls are made of concrete.

walls are grey.

Well, here is the news: this is something that can be expressed u…