# Code

I took the Ludum Dare challenge for the first time, i’ve done game jam’s before with my best finish in F this Jam last year. I only had about 8 hours to build this game, but I’m really happy with how it turned out. The art and music are definitely my weakness, but I think it turned out pretty good. Okay enough of it, let me introduce Egg Empire! You can grab the source and play it right on the Ludum Dare website.

http://ludumdare.com/compo/ludum-dare-31/?action=preview&uid=18798

Cheers until next time!

Adam

*The view ‘Nop.Plugin.Payments.CashOnDelivery.Views.PaymentCashOnDelivery.Configure’ or its master was not found or no view engine supports the searched locations. The following locations were searched:*

I started getting this error when upgrading to NopCommerce 3.30, and although i’m decent enough with .NET this is one that really confused me. So what did I do to actually fix the problem?

Step 1: I started Googling every variation of this possible.

Step 2: I attempted a bunch of the suggestions I found

Step 3: I found a programmer friend of mine (in the same office) and started bouncing some ideas off of him, by the end we were both stuck scratching our heads.

Step 4: I finally found a suggestion that started leading me down the right path which I will detail below.

In Visual Studio 2013 you click on each View (cshtml) in the plugin that is having the problem, set the **Build Action to Content and the Copy to Output Directory to Copy if newer**.

The next thing you want to do is change the requested view to be the actual path instead of the embedded path.

return View(“~/Plugins/Payments.CashOnDelivery/Views/PaymentCashOnDelivery/PaymentInfo.cshtml”, model);

Then rebuild and everything magically started working. So it turns out that in 3.40 of NopCommerce they get rid of embedded cshtml files completely, still not sure why I’m having this problem in 3.30, but this at least got me running again.

Until next time

Adam

Please note this is part of documentation I wrote for the opensource feather web framework currently available on GitHub. You can find the document in its original form here: https://github.com/maddogawl/feather/blob/master/featherdoc/docs/state%20machines.md

**feather Finite State Machines**

Finite State Machines (FSM) are well understood in computer science, and as such they won’t be covered much here. There are some really good articles online that you can check out to read more in depth analysis on FSM’s.

Links to some good articles

In the simplest definition a FSM is a set of states and transitions. A FSM can only be in one state a time, thus allowing you to easily build state driven applications like Rich Internet Applications. In more complex systems that utilize state machines you will begin to see hierarchical state machines, and states that have their own state machines.

In general Finite State Machines are a tool that simplifies common problems including UI management and async flow.

### Benefits of State Machines

An application could easily be created without utilizing FSM’s, but there are some clear advantages to using them.

– *Flexibility* : Code can easily be tweaked and extended with proper use of state machines.

– *Debugging* : Code that is isolated in small testable states makes it much easier to track down defects in the software.

– *Simplicity* : Its human nature to think of things in terms of states. It is generally simple to break down parts of software in terms of states.

### (more…)

I was recently tasked with a new system to handle any number of combos. Basically it needs to be easy to define a given combo and easy to fire off an event when that combo is successful. Starting off I had 27 various combos with 13 different attack types. For example ( Light hit, Light hit, Light hit ) would be one combo. First I wanted to define the limitations of the combo system.

Once a combo has been reached the attack chain is cleared. For example ( Light hit, Light hit, Light hit, Uppercut ) would be 1 combo with the first 3 hits and then the chain would be cleared, and uppercut would begin the next sequence. This is important because the designers need to be aware of the types of combo’s they define. If it was absolutely necessary to extend the combo, I think it would still be possible, but my solution wouldn’t work as well, because a person could in theory just do light hits constantly and be notified of a combo.

**Determining if a point is in a 2D triangle**

Visual Studio 2008 Project and Source here

For this one I needed to read in a file of a ton of triangles and then process them to determine if a point is contained in the triangle. I thought of a couple different algorithms to solve this but ultimately decided to use the cross product between the generated segments to determine if it is contained. I had been needing a basic File class for reading and writing files, so I set one of those up, then I moved to the 2D integer vector class that I used for the math needed to solve it. The parsing is very basic I just scan for the integers, then i sorted the points from left to right so I knew how to process the triangle.

Anyway check it out and leave some feedback.

### The Idea

A lot of the problems that I keep attempting on projecteuler.net require more bits than than unsigned __int64, so I started thinking about making my own LargeInt class. For the particular problem I’m solving I need the following operators.

- operator*
- operator=
- operator+
- operator–
- operator<
- operator>
- operator==

I need to be able to have numbers of nearly infinite size with fast indexing to perform operations on. I decided to utilize the vector class in the Standard Template Library, but you can pretty much use any dynamic array. (more…)

*Given a triangle filled with values find the maximum sum that can be achieved by traversing from top to bottom.*

I spent a bit of time thinking about the best way to accomplish this since on Project Euler one of the triangles is 100 lines in the text file. I thought about an algorithm that basically traverses the largest branch in the tree, but that doesn’t always yield the maximum sum. So then I realized that I don’t really need to know the actual values of the triangle, only the sum of up to that point. So I basically came up with a way that calculates the maximum value at a point in the triangle by starting from the top and working my way down. So for example A triangle like this: (more…)

I’ve seen a lot of implementations of array based binary heaps, and really only talk about tree based implementations. Granted the array based versions that use dynamic arrays are probably better for most things since the average cost of insertion is of constant time O(1), and sorting the array based versions is much easier. With that said I wanted to attempt a tree based version for some comparisons. One thing to note is this a max based binary heap meaning the largest value will always be at the root. I got some suggestions for speeding up my insertions, which turned out to be highly needed. I’m sure theres a few ways I can improve the insertion algorithm which runs at O(log(n)) instead of the O(1) that the array based insertions take. I’ve tested this class with over 10 million inserts and removals of varying types, and it gets the job done, but I do see that the array based implementations are superior.

Check out the code here

### Here’s a fun problem I took a stab at.

“You have 2 lightbulbs in a 100 story building, the goal is to find the highest floor you can drop a lightbulb from without it breaking. You can break both lightbulbs in your tests.”

At first this may sound really easy, divide and conquer and then go up by ones to find the solution, after 10 seconds you’ll realize this doesn’t work at all. My first actual attempt used an algorithm that used fixed steps of 10 to drop the lightbulbs with a worst of 19 when 99 is the answer. I didn’t like how much worse this got the higher the test so I looked for another solution. I came up with a method that uses the summation formula to pick the increment of each drop. New worst case is 14 drops. Want to see how it works check it out here.