Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

yadango

Member Since 23 Jul 2005
Offline Last Active Sep 28 2012 07:43 PM
-----

Topics I've Started

Minimal Path Problem

27 September 2012 - 12:50 AM

I'm trying to implement a minimal/shortest path type problem. Normally, you'd think Dijkstra or some other algorithm would work, but this is a special type of graph where the weights aren't fixed. For example, if the problem was like this, it would be easy (just use Dijkstra):

Posted Image

However, the problem I have is like the following.

Posted Image

Think of it like this... because A -> D is downhill and D -> E is uphill, the weight for D -> E is 1.
Because B -> D is flat and D -> E is uphill, the weight for D -> E is a little larger, 5.
Because C -> D is uphill and D -> E is uphill, consecutive uphill are a doozy for the enemy and so he has a weight of 9.

In other words, any weight along the path doesn't just depend on where you were previously, but where you were before that too. It can even extend farther back several levels like going uphill 3 times in a row is a real doozy and you must pay an extra penalty for that too.

I've thought of a bunch of stuff, but backtracking requires a lot of memory especially when the graph gets large and so far the only solution I've come up with is to just test all possible paths (since enemies are usually close to the player the graph doesn't get too large but for even small graphs testing all possible paths takes too much time).

Has anyone seen a problem like this before? Is there an algorithm for it? Algorithms like Dijkstra, Viterbi, etc. don't work because they assume only one weight per edge.

Thanks!

MessageBox and Direct3D11

05 August 2012 - 05:15 PM

Hey guys,
Is it ok to call MessageBox with an active device and swap chain? Just by chance I forgot to rename a compiled shader file... and the following code started to crash on the MessageBox line. But if I move the MessageBox line to below the FreeDirect3D call, the message box displays fine. I'm on on an AMD card with latest drivers running a sample D3D11 application in windowed mode.

Thanks!

This crashes.

[source lang="cpp"]// open vertex shaderstd::ifstream vsfile("002.vs", std::ios::binary); // oops! wrong filenameif(!vsfile) { MessageBox(GetMainWindow(), TEXT("Failed to open vertex shader file."), TEXT("Error"), MB_ICONSTOP); // crash! FreeDirect3D(); return FALSE; }[/source]

This works OK.

[source lang="cpp"]// open vertex shaderstd::ifstream vsfile("002.vs", std::ios::binary); // oops! wrong filenameif(!vsfile) { FreeDirect3D(); MessageBox(GetMainWindow(), TEXT("Failed to open vertex shader file."), TEXT("Error"), MB_ICONSTOP); // OK! return FALSE; }[/source]

EDIT: After some more testing, for me, any MessageBox called after D3D11CreateDeviceAndSwapChain but before a call to CreateVertexShader crashes atidxx32. Any MessageBox after the call to CreateVertexShader doesn't crash.

Full source code crashes on line 47 of d3dapp.cpp.

HLSL Assembly Question

03 August 2012 - 04:01 AM

Hello,
I'm trying to learn HLSL assembly, using MSDN as a guide and a book or two. Most swizzle examples given are kind of simple and I saw some code that looked like this and wondered what the equivalent statements were.
mova a0.w, r4.x

mul r4.yzw, v0.y, c0[a0.w].xxyz


is the equivalent expression
a0.w = r4.x

r4.y = v0.y * c0[a0.w].x

r4.z = v0.y * c0[a0.w].x

r4.w = v0.y * c0[a0.w].y

or this?
a0.w = r4.x

r4.y = v0.y * c0[a0.w].x

r4.z = v0.y * c0[a0.w].x

r4.w = v0.y * c0[a0.w].y

r4.w = v0.y * c0[a0.w].z

Thanks!

PARTNERS