Posts

Showing posts from August, 2008

Adventures in F# - A port of the simplest Herbivore

Following the past of my previous post, this time I present a barebones stripped-down version of the Herbivore that ships with the Terrarium SDK. The code is will equip you with a compilable herbivore, which however does nothing but sit in your terrarium. Just like in the previous post, I did not strip out some of the inline comments, which may be helpful to some of us. So here comes the code ... namespace CBHerbivore #light #r "E:\\Development\\my fsharp\\Terrarium\\Terrarium\\OrganismBase.dll" open System;; open System.Drawing;; open System.Collections;; open System.IO;; open OrganismBase;; //Sample Herbivore //The following Assembly attributes must be applied to each //Organism Assembly [<assembly: OrganismClass("CBHerbivore.CBHerbivore")>] //The class that derives from Animal [<assembly: AuthorInformation("Christian Bitter", "x@y.z")>] //It's an herbivore [<CarnivoreAttribute(false)>] //This value must be between ...

Adventures in F# - A Plant for Terrarium 2

Recently, my beloved Terrarium-game has reappeared from the neatherworlds of software. As some of you may know, Terrarium's intend was to showcase the back then rather new and exciting .NET platform version 1.x (not that it is not still exciting). Although from a gamer's perspective, the graphics weren't all to great, from a technology standpoint, it featured great things, such as Webservices, Reflection, etc. At some point Terrarium ceased to exist, which was a shame, since the community was quite active developing plants, herbivores and carnivores for the virtual ecosystem that Terrarium simulates. I for myself, developed some simple creatures too (a simple decision-based/state-based agent), as part of a project I did during university for my AI course. More advanced (in comparison to my creature) could be imported showcasing great AI stuff such as A*, neural networks, planning, etc. However, in an community effort, Terrarium was relaunched lately on codeplex and will hop...

Adventures in F# - F# and ADO.NET

Today's post is rather simplistic in what it does, but it illustrates some key language elements of F#, such as exception handling.  The task to accomplish is quite it easy, nameley, to connect to a SQL Server 2005 database called "TestDB" on my local machine, using ADO.NET to pull out some rows of the "Person" table having the following schema: Person (   PersonID: int ;   FirstName nvarchar (50);   LastName nvarchar (50);   Street nvarchar (50);   City nvarchar (50);   ZIP int ) The code we use in F# is a rather straightforward conversion of some typical C# code, and as such is probably not the best way to do things, but it gets the task done, and may illustate the point. #light We use the lightweight syntax option. open System.Data; open System; open System.Data.SqlClient; As a next step, we have to open the correct namespaces. let ADONetTest =    let conStringBuilder = new SqlConnectionStringBuilder()   conStringBuilder.IntegratedSecurity   conStringB...

Small one - SourceSafe via command line

Yes, I haven't been blogging for quite a bit and this small post is not going to change that but at least it is a little somethin'. I've been digging into F# and have had some great learning experience but this is nothing to really present now. Today I show a little snippet that let's you load some project ("XYZ") from SourceSafe into a specific folder (&ltTarget Directory&gt). This may come in handy in some sort of automatic build invironment. At first you need to define, i.e. set as environment variables: 1. SourceSafe User Account, supplied with sufficient privileges to actually access the project you want to retrieve 2. The account's password 3. The path to the SourceSafe DB's SourceSafe configuration file (srcsafe.ini) Next you ask SourceSafe to change the working directory for the project, you are going to load. You do this via "ss Workfold". The last step is to load/get the actual project into the working directory. SET SSUSER=...