Sign in to follow this  
Followers 0

I Really Need Ideas

4 posts in this topic

#1 ·  Posted (edited)

Hello Everyone!

What I am trying to do is a little difficult to explain however, I am trying anyway!! I simply need ideas how you would code the following. I really dont need the exact code, as I am fairly good, just simply ideas. How I should go about it simply confuses me :whistle:

The Discription Part! Yay!

Below is an example of a rather large CSV file I have. In fact it is around 13000 rows long. Each column is labled either fromSolarSystemID or toSolarSystemID. This file simply list each solarsystem and what other solarsytems it can connect to. For instance solarsystem 30000001 can goto systems 30000003, 30000005,

30000007 and 30003491. Each of these other solarsystems all have systems they can connect to aswell. If you look at FromSolarSytemID 30000003 you will see it can connect four systems in total. I hope this explains how this file works.

Now you wonder, what ishe trying to do?! Lets say I am in system 30000001 and want to arrive in system 30000084. I want to know what is the shortest route(the number to pass through) and which systems they are. The human eye can pick this example out easy. We would start in 30000001 then go to 30000003 and finally 30000084.

Does anyone have any ideas? I am at a loss with this one. Rolled around all night thinking about it before I posted. Thanks! :)

fromSolarSystemID toSolarSystemID

30000001 30000003

30000001 30000005

30000001 30000007

30000001 30003491

30000002 30000005

30000002 30002973

30000003 30000001

30000003 30000007

30000003 30000052

30000003 30000084

30000004 30000005

30000004 30002509

30000005 30000001

30000005 30000002

30000005 30000004

30000005 30000032

30000006 30000008

30000006 30000023

30000007 30000001

30000007 30000003

30000007 30000008

30000008 30000006

30000008 30000007

30000008 30000057

30000008 30000076

30000009 30000010

30000010 30000009

30000010 30000011

30000010 30000013

30000011 30000010

30000011 30000038

30000012 30000013

30000012 30000073

30000013 30000010

30000013 30000012

30000013 30000014

30000013 30000015

30000013 30000016

30000014 30000013

Edited by trixs

Share this post

Link to post
Share on other sites

#2 ·  Posted (edited)

If I'm understanding you correctly, then it sounds like you just need a 2 dimensional array, then poll through them.

[0] will be the from

[1] will be the to

I've pasted what you had in a text file and did this to see if it would work, then you can poll however you need to get the correct answers I guess:

$GetArray = _Create2Dim(@DesktopDir & '\Solar.txt')
If IsArray($GetArray) Then
    For $i = 1 To UBound($GetArray, 1) - 1
        MsgBox(64, 'Info', 'fromSolarSystemID = ' & $GetArray[$i][0] & _
            @CR & 'toSolarSystemID = ' & $GetArray[$i][1])

Func _Create2Dim($hFile)
    Local $hFRead = FileRead($hFile)
    Local $aSplit = StringSplit($hFRead, @LF)
    Local $aAdd, $aAdd2
    For $iCount = 1 To $aSplit[0] - 1
        $aSplit2 = StringSplit($aSplit[$iCount], Chr(32))
        If $aSplit2[0] > 1 Then
            $aAdd &= $aSplit2[1] & Chr(01)
            $aAdd2 &= $aSplit2[2] & Chr(01)
    $aAdd = StringSplit(StringTrimRight($aAdd, 1), Chr(01))
    $aAdd2 = StringSplit(StringTrimRight($aAdd2, 1), Chr(01))
    Local $aReturn2Dim[$aAdd[0]][2]
    For $iCount = 1 To $aAdd[0] - 1
        $aReturn2Dim[$iCount][0] = $aAdd[$iCount]
        $aReturn2Dim[$iCount][1] = $aAdd2[$iCount]
    Return $aReturn2Dim
Run this with the _Create2Dim() UDF above. Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post

Link to post
Share on other sites


Thanks for the reply. Unfortunatly this problem is much more complex than simply finding whichever is located next to it. I probably didnt explain it verywell. Guess Ill think of a better way while I am at work


Share this post

Link to post
Share on other sites

Ok, After further research what I need is a Dijkstra's algorithm lol.. Hmm Going to be fun!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0