Darwinbots Forum

Code center => Darwinbots Program Source Code => Topic started by: Botsareus on January 29, 2014, 01:29:16 PM

Title: Need a mod for IM
Post by: Botsareus on January 29, 2014, 01:29:16 PM
I know no one is currently working on IM, but I do need a mod for it already.
I would need a separate IM folder for robots in normal simulations and separate IM folder (or distribution process) for robots in ecosystem survival evolution. I have been considering all other ways to avoid mixing this robots. I can restrict mixing in newer versions of the program. However, due to the backwards compatibility of a (working) IM I have no other choice but to separate the process. Thank you for your consideration.



What is going on with IM Shasta?
Title: Re: Need a mod for IM
Post by: Peter on January 29, 2014, 01:50:21 PM
I would think all that's needed is a ftp server and clients placed with DB2. That shouldn't be too hard, but likely less feature rich than what would be the old solution.
Title: Re: Need a mod for IM
Post by: Numsgil on January 29, 2014, 06:03:24 PM
I think the idea of using a separate program to manage the uploading/downloading is a good idea, like Shasta and Ammeh were playing with.  DB2 could just save and grab bots from its in/out folders and leave the managing of the server architecture to something else.

The main difficulty here is that DB2 gets angry if another program attempts to delete or use a file it's currently reading or writing.  The first step in getting this to work is for the routines that save bots to in/out folders to check if a file is currently in use by the operating system before trying to read or write to it.  I don't know how hard that is in VB6.  Assuming you got the program to play nice with file handles, writing the app that shares robot files isn't too hard, especially since a lot of the work is currently done already in the C# app in the repository.
Title: Re: Need a mod for IM
Post by: Botsareus on January 30, 2014, 11:16:07 AM
Numsgil, I have created this little program called "LocalIM", and it seems to work fine:

Code: [Select]

Imports System.IO
Public Class Form1
    Dim infolder As String
    Dim outfolder As String

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim strFileSize As String = ""
        Dim di As New IO.DirectoryInfo(outfolder)
        Dim aryFi As IO.FileInfo() = di.GetFiles("*.*")
        Dim fi As IO.FileInfo

        Dim fir(0) As String
        For Each fi In aryFi
            fir(UBound(fir)) = fi.Name
            ReDim Preserve fir(UBound(fir) + 1)
        Next
        Dim mf As String = fir(UBound(fir) * Rnd())
        Try
            IO.File.Move(outfolder & "\" & mf, infolder & "\" & mf)
        Catch ex As Exception
        End Try
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim c As Byte
        For Each p As Process In Process.GetProcesses
            If p.ProcessName = "DarwinBotsIM" Then
                c = c + 1
                If c = 2 Then End
            End If
        Next
        ' ''-in "C:\in" -out "C:\out" -name Newbie 5676 -pid  4404
        Dim sp() As String = Split(Command, """")
        infolder = sp(1)
        outfolder = sp(3)
        Randomize()
        Application.DoEvents()
        Timer1.Enabled = True
    End Sub

End Class


I call just move the file only after it is done writing.
edit: .net is smart enough not to move a file that is currently writing based on my experience, so we don't really need to worry about file access as long as we are moving files.
Title: Re: Need a mod for IM
Post by: Botsareus on February 07, 2014, 12:39:08 PM
Very sloppy programing for IM found:

Who wrote the loadRobot code? You declare a filenumber, then you completely do not use it and pass a 1 to loadrobotbody? V8 for you!
Title: Re: Need a mod for IM
Post by: Botsareus on February 07, 2014, 12:53:14 PM
Rofl, file continue of all places?! Eric who is the poor programer now? (Same error as above)
Title: Re: Need a mod for IM
Post by: Peter on February 07, 2014, 01:13:00 PM
File continue?
Title: Re: Need a mod for IM
Post by: Botsareus on February 07, 2014, 01:15:37 PM
It is a binary file search code to make individual robots reverse compatible without completely screwing up the save simulation code.