• Create Account

Banner advertising on our site currently available from just \$5!

Member Since 23 Jul 2005
Offline Last Active May 17 2015 02:30 AM

### 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):

However, the problem I have is like the following.

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!

### complex polygon test

10 August 2007 - 09:58 AM

hi there, i know of a concave/convex polygon test, but is there an efficient complex polygon test other than checking every line segment pair to see if they are intersecting? thx

### An Assembly Question

17 June 2007 - 10:58 AM

Hey guys, I got this ASM book and going through some stuff. And the following MASM code on my 32-bit XP OS gets built into an OBJ file just fine using ml.exe. However, when the custom build tries to link the OBJ file, I get a strange error:
`fatal error LNK1107: invalid or corrupt file: cannot read at 0x81`
```.386
.model flat, c
.code

mov eax, x
RET ; return value already in eax

end

```
```#include<iostream>
using namespace std;

extern "C" int AddTwoNumbers(int x, int y);

void main()
{
cout << "Hello Assembly!" << endl;
int a = 2;
int b = 3;
cout << "c = " << AddTwoNumbers(a, b) << endl;
}

```
What's funny though if I switch to an x64 project, remove the .386 and .model sections, then build with ml64.exe, and then build the project, it compiles, links, and runs as expected on XP64. My custom build command line is (exactly as MSDN's MASM Euclid examples):
`ml.exe -c -Zi "-Fl\$(IntDir)\\$(InputName).lst" "-Fo\$(IntDir)\\$(InputName).obj" "\$(InputPath)"`
BTW, I know with inline assembly in Visual Studio I can't use MASM's variable declarations, but can I use MASM's IF/ELSEIF/ELSE/ENDIF directives in inline assembly? I tried and it didn't work, but maybe there's a trick? MSDN says nothing about not being able to use IF directives in inline assembly.

PARTNERS