language-agnostic

Are there any open-source military/war strategy simulating engines/frameworks?

Are there any open-source military/war strategy simulating engines or frameworks? Combat rules engines or weapon selection guides? I'm looking for something similar to a military strategy "unit testing" in a simulated field. What I'm trying to build is a combat advisor for troops deployed in the field. Intel' comes in with enemy's moves...

Is there really a performance hit when catching exceptions

edit: Someone had added the C# keyword. I am NOT talking about C#, just exceptions in general. Specifically, exceptions in compiled languages like C++ and D; though C# was also in my mind. I asked a question about exceptions and I am getting VERY annoyed at people saying throwing is slow. I asked in the past How exceptions work behind ...

Optimal way for partitioning a cell based shape into a minimal amount of rectangles

Assume a boolean array like: 1111 1111 1110 1111 1001 Now you need to find the way of arranging the least rectangles of any size to achieve this shape. So, for example, you'd find this: +-++ | |+ | | +-++ + + Where + is a corner of a rectangle and |, - borders of a rectangle. What I thought about doing is starting with the larges...

Use of Vertical Whitespace

My intention in this question is not to be pedantic, but rather to explore an overlooked axis of an important topic (the use of whitespace). Much debate and care has been put into the use of horizontal whitespace, indenting after a conditional, a space between an if and parenthesis, etc. In fact the issue is considered to be so importan...

What are some authoritative/respected "best known implementation" websites/resources?

EDIT: Wow, the initial response to this question was quite negative. I think I might have triggered some pretty strong emotions by using the word "best"; it seems like a few people latched onto that word and decided to dismiss my question right away. Obviously, there are many, many situations in which no single approach is "best", or a...

Good framework for the game of Go (weiqi, baduk)?

I enjoy the game of Go (also known as weiqi in China or baduk in Korea). I want to create a program (an evaluation function) to play it. I would prefer if the framework handled two important tasks: Handle rules for the game, including captures, ko rules, and final scoring. Handle communication between a server like KGS and my program...

Algorithm for finding 2 items with given difference in an array

I am given an array of real numbers, A. It has n+1 elements. It is known that there are at least 2 elements of the array, x and y, such that: abs(x-y) <= (max(A)-min(A))/n I need to create an algorithm for finding the 2 items (if there are more, any couple is good) in O(n) time. I've been trying for a few hours and I'm stuck, any c...

File header or general comment

Does anybody have a nice well structured starting comment for a file? I'm looking for something that looks nice, either fancy or very professional. By general comment I mean the comment at the top of a file showing your name and purpose of the file. Like this one: /******************************************************** ...

Describe the three elements that must be included in order for a loop to successfully perform correctly

I have this homework question about loops in general (if it make sense at all), it goes like this: Describe the three elements that must be included in order for a loop to successfully perform correctly. Any idea what they might be? ...

Best-case Running-time to solve an NP-Complete problem?

What is the fastest algorithm that exists up with to solve a particular NP-Complete problem? For example, a naive implementation of travelling salesman is O(n!), but with dynamic programming it can be done in O(n^2 * 2^n). Is there any perhaps "easier" NP-Complete problem that has a better running time? I'm curious about exact solutions...

Website Session Analysis

I'd like to know the best way to deep dive into the flow of my users. For example, I have 4 pages in my flow, how can I analyze which users abandon on which step? I can definitely do it by hand with logging, etc, but I'd rather use an off the shelf solution. I have apache request logs, as well as google analytics. Can these analyze user...

To what extent can optimisation replace Macros, Stack allocation ... ?

There is a lot of discussion about the lack of macros in some languages, and the inefficiencies that can arise. Perhaps the most common example is the guard before a log statement. To what extent can current & future optimisation be relied upon to do the right thing and obviate the need for a macro. In this example and in general? // ...

Use of Facade Pattern

How can I know that I need a facade Pattern at a point in my application development? How can I draw the line between Facade Pattern and Template Pattern? For example: In [this] article, we see that, int placeOrder(int CustomerID, List<BasketItem> Products) has a number of predefined steps in the algorithm. So why don't the author use ...

What are the uses of recurrent neural networks when using them with Reinforcement Learning?

I do know that feedforward multi-layer neural networks with backprop are used with Reinforcement Learning as to help it generalize the actions our agent does. This is, if we have a big state space, we can do some actions, and they will help generalize over the whole state space. What do recurrent neural networks do, instead? To what tas...

Can coordinates of constructable points be represented exactly?

I'd like to write a program that lets users draw points, lines, and circles as though with a straightedge and compass. Then I want to be able to answer the question, "are these three points collinear?" To answer correctly, I need to avoid rounding error when calculating the points. Is this possible? How can I represent the points in mem...

How to best save XML files

I have a bunch of classes that each read in their values from an XML file using TinyXML. I've done this so everything is in memory, and my user is using the app and making changes. If the user presses Save, I need to iterate through my objects and call the Save() function which writes out the XML file. Should I rebuild the XML file pr...

Are there any good resources on real world practical uses of programming theory?

Can anyone recommend any good material that seeks to provide a real world perspective on programming theories? I'm speaking from my perspective as a long time professional software engineer slash ex-cs student. When I say real world, I mean stuff like "Why should I use interfaces? Doesn't that go against DRY principles? It just seems l...

Business Objects - Containers or functional?

Where I work, we've gone back and forth on this subject a number of times and are looking for a sanity check. Here's the question: Should Business Objects be data containers (more like DTOs) or should they also contain logic that can perform some functionality on that object. Example - Take a customer object, it probably contains some...

Is there an API or tool that can automate software updating?

Is there any API or tool that can automate software updating? It should take care of checking for updates from a URL for a provided list of files and downloading and replacing the ones that need updating. It would also be nice if it contained an authentication module so that only authorized parties could access the updates. It should be ...

How to write an enumeration of all computable functions?

Motivation: I'd like to be able to use toy functional programming in languages without first-order functions, by using natural numbers instead of functions. A universal function is a function f : N -> (N -> N), equivalently f : N * N -> N that enumerates all possible computable functions. In other words, there's a number k such that f(k...