# Algorithm Use UML Instead Of Flowcharts

868 views

Updated: 2/15/2019
- added "if...else" Double Selection Statement

Visual Studio Enterprise 2015 has build in tool for creating UML Activity Diagrams. We can use this tool for creating flowcharts for describing algorithms.

Creating UML Activity Diagram:

• Select: "File" -> "New" -> "Project..." -> "Modeling Projects"
• Write a name, for example: UseUMLInsteadOfFlowcharts_ModelingProject
• Press "OK" button
• Right Click on a name of the project
• Select: "Add" -> "New Item..." -> "UML Activity Diagram"
• Write a name, for example: UseUMLInsteadOfFlowcharts.activitydiagram
• To add new items, drag them from the "Toolbox"

I get these examples from the book:

1. "if" Single-Selection Statement

int studentGrade = 70;

{
Console.WriteLine("Passed");
}

2. "if...else" Double-Selection Statement

int studentGrade = 70;

{
Console.WriteLine("Passed");
}
else
{
Console.WriteLine("Failed");
}

3. "while" Iteration Statement

int product = 3;

while (product <= 100)
{
product = 3 * product;
}

4. "for" Iteration Statement

for (int counter = 1; counter <= 10; ++counter)
{
Console.Write(\$"{counter} ");
}

## 1 Comment

I much prefer Enterprise Architect for UML or design documents in general. Not only is it graphical but it has document templates to generate it for you. I think they have about 100 different diagram templates. Enterprise Architect . For shops that insist of Visio ( as limited as it is ) EA can translate back and forth. They have tons of tutorials on the pages and their site to help you get up to speed quickly.

Not insulting MS and VS which I use daily. Just i've been doing both for 10+ years and always go back to EA because it saves so much time.

## Create an account

Register a new account

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• ### Similar Content

• In DCC, we can soft select things with proper falloff in volume/viewport. I think I can do the soft selection with viewport falloff. But how is volume falloff implemented especially with lasso/poly selection mode?
In lasso/poly selection mode, the 2D selection area in viewport is irregular polygon. Then selected objects will also in an irregular 3D space. How to do volume falloff based on this irregular 3D space to achieve soft selection?
• By Ryokeen
Well, just for the fun of it i started to implement a simple quadtree into a little project of mine. Just to maybe speed up rendering and have at least some sort of culling for maps as they are made as basicly one huge mesh. But then there is the situation that triangles will cross borders of the childnodes if a node has to be splitted.

Pushing them into the parent node would be easier, but that means that there is the potential to draw more nodes than possible because of well, crossing triangles.
Then if they would get split so that i only have to render leaf nodes, means i get quite some more triangles to render.
As for now the quadtree will only be used for rendering so each triangle in the hughe mesh should only be present one time(to avoid possible overdraw/double rendering of triangles)
Now what i'm asking or where i need some input is, is it better to push the triangles which are in more than one childnode into the parent node or split them at the boundary, resuling in more triangles but they will only be in leaf nodes ?

regards Ryokeen

• Hey guys. I just released my first game called "Paper Pigeon". Please check it out and give it a good rating if you liked it. This started as just a simple "Flappy Bird" clone to familiarize myself with Unity and just learn programming in general. Midway through the process I started having my own ideas and different takes on this game design which birthed this game. It probably took WAY longer than an experienced programmer could make this in, but nonetheless, I am quite proud to have created this. Please support it fellow gamedevs! Thanks.

• Hi,
Currently I'm trying to get my ai enemy path find to the player. I've got astar working as expected but i want the enemy ai to jump at an arc when it need to jump between platforms. Here how I'm calculating initail velocity using suvat physics equations:

public LaunchData CalculateLaunchData(Vector3 launchTarget, Vector3 projectilePositions, float height) { float displacementY = launchTarget.y - projectilePositions.y; Vector3 displacementXZ = new Vector3(launchTarget.x - projectilePositions.x, 0, launchTarget.z - projectilePositions.z); float time = Mathf.Sqrt(-2 * height / gravity) + Mathf.Sqrt(2 * (displacementY - height) / gravity); Vector3 velocityY = Vector3.up * Mathf.Sqrt(-2 * gravity * height); Vector3 velocityXZ = displacementXZ / time; return new LaunchData(velocityXZ + velocityY * -Mathf.Sign(gravity), time); }
According to the v = u + at formula, I can use time and initail velocity to calculate final. So does final velocity mean velocity at any time t? My idea was todo something like this in my enemy ai class, but it doesnt quite work expected as my enemy is having a weird landing and jumping behaviour and not as smooth as when I just add displacement to original position. Here is what I'm doing:

IEnumerator Jump(LaunchData launchData) { float timer = 0.0f; while (timer <= launchData.timeToTarget) { velocity.x = launchData.initialVelocity.x + (timer); velocity.y = launchData.initialVelocity.y + (timer * (ps.gravity)); timer += Time.deltaTime; enemyController.Move(velocity * Time.deltaTime); yield return null; } jumping = false; } Where enemyController will handle some collision detection related stuff and call Transform Translate method in unity. Something else is that I can use the equation: s = ut + (1/2)(a)(t^2) to get the displacement directly. This works quite well as I can just add the displacement directly to the jump starting position. However, I can only set the transform.position directly with this way and thus I can't handle collisions as nicely as transforming with a velocity (since my resusable code is inside the controller takes velocity). I'm quite new to unity and game programming, so am I doing something wrong with setting my velocity? I can add a little gif later to better visulise things.

• Looking for feedback from someone who has done this, mainly just to confirm that my guestimates are not way off.  I know enough to be dangerous not my area of expertise.
Trying to budget for a custom 3D skeletal animation system with cross fading and 2 layer blending.  Context is Unity.
My thought is someone who has done it before could probably get the core features working in some form in a month.  But by the time you factor in everything like bugs, performance refactors, platform specific gotcha's, whatever, it's probably around a 6 month job to get something actually usable in game.
Does that sound reasonable?

×