Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 17 Jul 2002
Online Last Active Today, 02:51 PM

#5312909 Coding-Style Poll

Posted by on Yesterday, 02:50 PM

Until we have prettifiers integrated in our version control systems, there will always be coding styles that people dislike.

You statistically cannot construct a style everyone will agree on unless there is just one person working on the code, and even then, that individual is subject to changing their mind over time.

The important conclusion is that you should not seek to eliminate the discomfort of working in someone else's style.

Instead, you should recruit people who are smart and empathetic enough not to be petty about what line the fucking brace goes on.

#5312893 target selection strategies

Posted by on Yesterday, 01:11 PM

The way we handle this is to stratify the utility scores. Idles, ambient behavior, making tea, etc. get a score up to, say. 1.5 ceiling. Movement and tactics get a 2-3 range score. Using combat abilities get 3-4. Emergency stuff like evasion, yelling barks, and so on might be up to 5 or 6.

I think it's important to highlight that game AI in particular is not about mimicking human thought patterns. It's about providing an illusion of intentionality and rationality. If the behavior "makes sense" to the player, we have succeeded. The mechanics of choosing that behavior are almost always opaque to the player anyways (Sims games notwithstanding) so it's more important to look good than to be scientific.

#5312571 Visual studios 2010 debugger variable doesn't update

Posted by on 25 September 2016 - 05:11 PM

Are you debugging a Debug build or a Release build?

#5312568 target selection strategies

Posted by on 25 September 2016 - 05:06 PM

If you want to hard-code your decision process, don't use a system that's designed to make flexible decisions.

I don't understand what you gain by forcing a utility scoring system to basically turn into a decision tree.

#5312543 _CrtSetBreakAlloc() not breaking

Posted by on 25 September 2016 - 02:05 PM

If you want to get really filthy...


Just abuse the CRT init segment to run a function that sets up leak checking before static initializers/main runs. I think this is still subject to the initialization order fiasco so you probably will get flaky ordering behavior, but it's a thing you could try.

#5312348 target selection strategies

Posted by on 24 September 2016 - 05:32 PM

Survival is a nebulous goal. Often the best way to win is not to play, i.e. just flee the combat if you can and you've satisfied your survival condition.

It's very difficult to separate target selection from acting on the target. If you have a fireball, don't target the fire-resistant enemy. If you already committed to targeting the fire-resistant enemy, and none of your other abilities are available, well then you just fell into the Stupid Zone - the AI will do something stupid because the order of operations is wrong.

But if you pick the fireball first, you can still get the same stupid behavior if all enemies are behind cover except the fire-resistant one.

The most robust strategy is to consider all targets and all interactions, and pick the best combination. Utility systems are great for this. It helps to mix in "non-targeted" actions as well (running away, healing, etc.) so you can always have something semi-reasonable to do regardless of situation.

#5312198 Would you try a language if all you had to do was install a Visual Studio ext...

Posted by on 23 September 2016 - 08:32 PM

I don't agree - at least not in those broad of terms.

I think there is plenty of interest in languages and plenty of interest in moving to better ones. It's just limited to certain subsets of the programming world as a whole.

Looking to the web for a pulse on the general opinions of programmers is risky at best. The web hasn't been a reasonable ambassador of technological progress in 20 years.

Frankly I launched (and mostly kept) Epoch at GameDev.net and a few smaller game development circles for one major reason: I honestly believe that games are the best type of software we have today for pushing the boundaries of programming languages. This is especially true of realtime networked simulation games.

That may sound contradictory given that I've already stated I'm apathetic about making Epoch into a game development platform. But I don't think it is. Epoch should be able to use C and C++ libraries fluently, so that we can push the envelope without sacrificing premade tools. I started a BGFX integration project for exactly that reason, and it's motivated a lot of improvement to the language and tooling.

I think if you look back far enough in any successful language's history you'll find a very small number of highly motivated people. Maybe even an individual. Yes, the goal is important (and I have one, it's just... abstract!) and backing is a powerful force multiplier. But backing comes after the core people have decided to do something.

On the one hand, it would be a tragedy if programming languages stalled out and people were too lazy to learn new ones.

On the flip side, I don't think that's our destiny. I think what people miss is the familiarity of tools and libraries. If we make that transition less painful, I think plenty of programmers would be willing to learn a new language - maybe even eager to do so.

The majority of actually experienced C++ programmers I've talked to will (sometimes grudgingly) admit to wanting a better language. Maybe to them that's just C++20, or maybe it's Rust, or Go, or Haskell, or fuck it, maybe it's Epoch. But they're all just waiting for someone to lower the barrier to entry far enough that they can jump ship to a better technology.

In any event, I'm not doing Epoch for grand world-takeover schemes. I'm doing it because I want better languages and because I know what will scratch my own itch best. Nobody else is getting the same mix of ideas. So to me, there's room for more languages, even if it's a tiny niche.

Bottom line is I'm not all that concerned about dominating the PL field. I'd be thrilled for the language project to gain enough critical mass that other people could enjoy it besides me. But even if nobody ever does, even if nobody so much as looks, I'm doing this fundamentally because I want a language to code in that doesn't constantly make me wish I had been punched in the balls instead.

#5311973 13 Y/O That Is Interested In Learning How To Make Video Games

Posted by on 22 September 2016 - 03:22 PM

Have you read through all of this?

#5311957 Biome based map generation?

Posted by on 22 September 2016 - 02:20 PM

My go-to trick with procedural landscapes has always been (and, at this rate, probably always will be!) a derivative of a noise function. Simplex noise is the most useful and modern variant I'm aware of personally.

#5311828 Making a bot for a website in C++?

Posted by on 21 September 2016 - 05:39 PM

Google for C++ Common Gateway Interface

CGI is a server mechanism, not a client mechanism. If I understand OP correctly, they want to automate interacting with an existing hosted site.

#5311678 Basic multithread question

Posted by on 20 September 2016 - 02:39 PM

I profiled the WaitForSingleObjectwhen I wrote the sheduler and it came with a latency arount 1-10ms and my sleep(0) was in the peek 1ms.
On Fedora 22 I profiled usleep and got the same behaviour but the pthread signals are much faster compared to WaitForSingleObject.

I smell something fishy. I work with code that relies on sub-millisecond responses from inter-thread signals on Windows and it runs just fine across a very large number of users. If you're doing your threading right you can count on the kernel to wake a relevant thread in a few microseconds, not 10ms. It sounds like you mistakenly measured the process quantum, not actual thread context switching.

See (anecdotally) here for similar experiences.


The numbers were even worse before I assigned the threads to the cores.

This is a concurrency smell. Trying to outwit the kernel with thread priorities and core affinities is almost always counterproductive unless you're extremely good.

It seems that you expect that you use less CPU power if the process monitor show 0-1% of cpu usage on your process then 25 or even 100%.

Complete and total straw-man, I never said anything of the kind. I said you use less CPU resources by which I meant actual scheduled CPU clock time.

Desktop CPUs run all the time and use the same amount of power because if you don't use the cpu the kernel will do.

That flatly contradicts your next statements:

If possible it will lower the frequency of the cpu to use less energy and in this case your power supply will drain less energy(FX-8350 can work between 1,4-4,2Ghz).
You can run tools like cpuz to monitor the cpu frequence and run your work sheduler code to find a solution which drain less power.
If the core speed go down the same code will result in higher process usage which makes this number treacherous.
On my 8 Core FX the core speed jumps beween 1,4GHz and 4,2Ghz if you enqueue many tasks, my cpu usage go up to 100% for all Cores and it runs with 4,2GHz per Core.

Note that system profiling with Task Manager is bush league at best and probably just flat wrong in the common case. You should be giving evidence with ETW perf counters or similar tools if you want to convince anyone.

In any case microoptimization is dangerous and hard, and concurrent microoptimization is at least an order of magnitude harder. Even if your numbers suggested that sleeping/nopping is a good idea for general use, you're gonna lose a lot of ground to solutions that aren't so fragile.

#5311460 C++ Angle bracket function

Posted by on 19 September 2016 - 11:28 AM

I'm sorry but I tried using templates but I couldn't seem to get them working. Could you give me an example?

What have you tried?

We're not in the habit of answering questions blindly. It's much more useful - both for us and for you - to be detailed and explicit about what you're trying to do, what doesn't work, and what you have already tried to do to address the problem.

Otherwise you're likely to get "helpful" examples like this one:

namespace Metaprogramming {

template <unsigned A, unsigned B>
struct EqualityCheck {
    enum PerformCheck {
        CheckResult = (A == B)

struct EnableIfDummy { };

template <bool> struct EnableIfHelper;
template <> struct EnableIfHelper<true> {
    typedef EnableIfDummy type;

template <> struct EnableIfHelper<false> {
    typedef void * type;

template <unsigned A, unsigned B>
struct EnableIfEqual : public EnableIfHelper<EqualityCheck<A, B>::CheckResult> { };


#5311457 C++ Angle bracket function

Posted by on 19 September 2016 - 11:16 AM

The C++ term for doing this sort of thing is "templates." There are many resources ranging from entry-level to advanced-trickery available on the web, so I'd suggest you start there; but if you run into any specific issues please do feel free to ask!

#5311449 Basic multithread question

Posted by on 19 September 2016 - 11:01 AM

There's a lot of poor quality information in this thread.

Condition variables (or other synchronization methods) are your best bet. They tell the OS to use virtually zero (CPU) resources on your thread until it is time for it to do work. Any good multithreading-aware kernel will schedule your thread so that it wakes up as soon as it can after being signalled.

The latency of synchronization is trivial and not worth freaking out about. Basing your threading models on Sleeps and fairy dust is a recipe for frustrating bugs and non-scalable architectures.

#5311336 Would you try a language if all you had to do was install a Visual Studio ext...

Posted by on 18 September 2016 - 08:55 PM

Just based on an editor plugin, no. It's a requirement these days though.

What would make me considering looking into a new language are the following.
- open-source
- great set of examples and documentation to start out
- easy ways to inerface with C code, easy ways to call and link together with c libs
- plugin for a multiplatform IDE, that has some for of auto-completion (std lib at least!)
- ways to interact with the community, reddit, blogs, IRC, stackoverflow like pages etc...

There are other things, but those are specific to my usual set of projects. (VFX where you need perf and to deal with tons of data) Or just the simple fact, that it gives me something that no other language can.

Apparently I made a rare assumption when I posted... namely, I assumed that any language worth investigating would check enough boxes to get people's interest in the first place. Obviously though based on the typical responses in this thread people tend to assume the opposite :-)

This is fair, though, given that "new languages" are kind of a dime a dozen these days.

For the record, for the language I'm working on:
- Definitely open-source (3-clause BSD all the way)
- Has some examples but not nearly enough
- Interops trivially with C DLLs on Windows (I include a demo integration with BGFX for instance)
- I'm working on the IDE plugin for my platform of choice
- Has no users and therefore no community, although there is an (empty) mailing list

These are not surprises to me, though. I'm already well aware of the need for good examples and intro materials as well as a robust stdlib and documentation. That stuff will come in time.

Right now what I need is early adoption, people willing to overlook a bit of grime on the less-than-shiny coat of paint. People who might even be interested enough to become contributors to things like docs, stdlib, ports, and so on. My motivation for posting this thread isn't to snag Joe Garage Programmer as much as to see how many programmers would even take a look at an unfinished product.


That tells me that its hard for languages that are explicitly general purpose or at least without a clear target, and harder still if you have system-level aspirations.

Part of what I need to clarify with this language is what the intended killer app should look like. It's changed a bit over the years and I'm in the middle of a heavy soul-search to refocus it.

Not everybody will have Visual Studio installed though so you could consider using the Visual Studio Shell so that you have a standalone IDE if necessary but it could also integrate with an existing Visual Studio installation if there is one.

I'm aware of this option but as I'll elaborate on below I have reasons™ for starting with this :-)


If Epoch is cross-platform then there's no need to lock yourself into Windows, so Eclipse might be a better technology to use. Eclipse is best known for being a Java IDE but really it's all just plugins so you can basically start with an 'empty' IDE and add languages and tools from the ground up.

I find it oddly humorous that anyone would attach the phrase "better technology" to Eclipse. Also Epoch is not cross-platform and is not intended to be. If it becomes available on other platforms it will be through the generous donations of time of the community, not from me.


I don't mind having to install both a standalone command-line suite of tools, plus an optional .VSIX. Frequently with serious projects, the command-line tools need to be as easy to install as possible to get them deployed on our CI build machines. Ideally, no environment variables need to be set; usually just adding the PATH entry to the bin folder or having a well-known path that it gets installed to is enough.

This is a good point, and something I'll be sure to keep in mind, thanks.

I'd honestly prefer a Visual Studio Code extension over a full VS one.

I don't install VS extensions unless I really need them. I'll happily install a VS Code extension to play around with for an afternoon, though.

So I opted to use full VS instead of VScode for two specific reasons. First, I prefer the full IDE when possible, and I want to dogfood my extensions such that I'm developing Epoch core tech from within VS itself.

Secondly, I've worked with the VS extensibility model before and I'm reasonably comfortable mucking with it. VScode would just be learning overhead and unjustifiable work since I wouldn't use it routinely.

That said, I may well do a VScode addon later, just because it does help with the barrier to entry. It'll probably also force me to tidy up some of the shared logic.


There are only a few things that make me learn a new language
- The languages I know are not the right tool for the job
- I want to learn a new paradigm, functional made me explore F#, ML and Haskell

Fair enough.


A VS extension is definitely a good substitute for a specialized IDE, but it's still an extra on top of an easy way to compile and run programs, which should be the first priority but often isn't.
There are a few common patterns of bad tools: pathetic support for Windows (experimental and/or obsolete and/or incomplete packages, or deliberate omission), enormous platforms (e.g. bundling Emacs or Eclipse) and invasive installers, and more rarely sucking portably (e.g. the convoluted privileged classpath parts and JDK/JRE redundancies in Java).
For example, when I tried Haskell I struggled with a slightly obsolete nonstandard installer using nonstandard file locations, and even if I managed to compile programs it deleted my PATH environment variable anyway. I was unusually motivated, otherwise I would have given up before downloading anything at the choice between Cabal and Stack and between the barebones GHC distribution, the big Haskell Platform and other variants.
Ease of update, preferably from sources, is also more important than IDE features.

Good points, thanks.


Why not just have an online compiler with basic IDE to try out some stuff? Either people get hooked and are willing to install some overhead needed to get started or they just close the browser tab.
While I was reading my last C++ book and had only a not so fast tablet available, this was the perfect solution to try out some snippets.

"Just" is one of those funny words. It alternately makes me want to laugh my ass off or boil my blood in rage.

I'll try to be as gentle as I can with this: you clearly are not aware of the amount of effort involved in building a "basic IDE" let alone an "online compiler". If I had another ten years to sink into this project I'd think about it, but just... no.


In short, yes. But also show me an example of something a bit more non-trivial than "Hello World" as well. Ex: Website, To-Do List, Championship Bracket, Flappy Bird.

Absolutely. I'm working heavily on this.