namespace SequenceTestNamespace
using System
using System.Collections.Generic
using System.Text
using System.IO
using BwBot.Runtime
using BwBot.Runtime.Tasks
class SequenceTest()
def Main(sequence-test)
{Console.WriteLine("a");}
sequence
{Console.WriteLine("1");}
{Console.WriteLine("2");}
{Console.WriteLine("3");}
{Console.WriteLine("b");}
sequence
{Console.WriteLine("1");}
{Console.WriteLine("2");}
{Console.WriteLine("3");}
{Console.WriteLine("c");}
sequence
{Console.WriteLine("1");}
{Console.WriteLine("2");}
{Console.WriteLine("3");}
sequence-test
Wednesday, December 9, 2009
Behavior Language
WIP:
Tuesday, June 16, 2009
Redo
I finally decided to go forward with a C# redo since the C++ version is too long and hard of a row to plow.
I've also cooked up a new syntax that is basically a prefix version of Python's syntax.
I've already written a simple tokenizer based on this article about regular expression parsing in C#. Another article that was helpful was Python: Myths about Indentation. That only took one day. The rest of the week was spent agonizing whether to have the parser just read the token list or convert to s-expressions and then parse.
I finally went back to an earlier idea of writing a class called TokenTree that extends List(object) where each element is either a token or a subtree. This should make things easier on the parsing end for various reasons. The s-expression idea was kind of neat but it seems redundant since I need AST classes anyways.
Later on I'll have to dump the RegEx stuff and write a more sophisticated tokenizer but at least this was a quick way to get started. For now I need to start writing the recursive descent parsing functions and the AST classes.
I've also cooked up a new syntax that is basically a prefix version of Python's syntax.
class Test():
def Foo1($x is foo): #forward chaining method
rule:
$x has $y
$y is bar
-->
$y is foo
I've already written a simple tokenizer based on this article about regular expression parsing in C#. Another article that was helpful was Python: Myths about Indentation. That only took one day. The rest of the week was spent agonizing whether to have the parser just read the token list or convert to s-expressions and then parse.
I finally went back to an earlier idea of writing a class called TokenTree that extends List(object) where each element is either a token or a subtree. This should make things easier on the parsing end for various reasons. The s-expression idea was kind of neat but it seems redundant since I need AST classes anyways.
Later on I'll have to dump the RegEx stuff and write a more sophisticated tokenizer but at least this was a quick way to get started. For now I need to start writing the recursive descent parsing functions and the AST classes.
Thursday, December 11, 2008
Agent Language Preview
This is a preview of the Agent Language I'm working on. More details will go in a Wiki or something.Methods are triggered by the addition and deletion of facts within the state. Methods without triggers are evaluated upon state creation. Rules within the methods are evaluated sequentially. States are evaluated until no new information can be generated at which time any facts that were proposed will cause the creation of successor states into which those proposals will be added along with any other facts in the current state.
This is a work in progress therefore any and all comments or criticisms are extremely welcome!
$ = Logic variable
. = Property of the rule, method, state, or agent
;
; BwAi - Missionaries and Cannibals
; Based on the Soar Version
; Kurtis B Fields - 2008
;
(domain Mac ()
(method main ()
;state success
(rule
(topic $g (type goal))
($g object $bank)
($g missionaries $m1)
($bank missionaries $m2)
($m1 = $m2)
($g cannibals $c1)
($bank cannibals $c2)
($c1 = $c2)
($g boat $b1)
($bank boat $b2)
($b1 = $b2)
==>
halt
)
;state failure
(rule
(Bank-1 missionaries $m1)
($m1 > 0)
(Bank-1 cannibals $c1)
($m1 < $c1)
-->
(assert(.state fail "Too many cannibals on Bank1!!!"))
==>
fail
)
;state failure
(rule
(Bank-2 missionaries $m2)
($m2 > 0)
(Bank-2 cannibals $c2)
($m2 < $c2)
-->
(assert(.state fail "Too many cannibals on Bank2!!!"))
==>
fail
)
;state failure
(rule
(.parent (.goal missionaries $m1) (.goal cannibals $c1) )
(.goal missionaries $m2)
($m1 = $m2)
(.goal cannibals $c2)
($c1 = $c2)
-->
(assert(.state fail "State undoes parent goal!!!"))
==>
fail
)
(rule
(topic $g (type goal))
(not($g is achieved))
-->
(temporary(.agent achieve $g))
)
)
(method MoveMissionaryPropose (.agent achieve $g)
(rule
(topic $bank1 (type bank))
($bank1 boat $boat)
($bank1 missionaries $m)
($m > 0)
(topic $bank2 (type bank))
($bank2 <> $bank1)
-->
(propose((.agent move-boat $boat)
(missionaries 1)
(cannibals 0)
(source $bank1)
(destination $bank2) ) )
)
)
(method MoveCannibalPropose (.agent achieve $g)
(rule
(topic $bank1 (type bank))
($bank1 boat $boat)
($bank1 cannibals $c)
($c > 0)
(topic $bank2 (type bank))
($bank2 <> $bank1)
-->
(propose ((.agent move-boat $boat)
(missionaries 0)
(cannibals 1)
(source $bank1)
(destination $bank2) )
)
)
)
(method MoveMissionariesPropose (.agent achieve $g)
(rule
(topic $bank1 (type bank))
($bank1 boat $boat)
($bank1 missionaries $m)
($m > 1)
(topic $bank2 (type bank))
($bank2 <> $bank1)
-->
(propose ((.agent move-boat $boat)
(missionaries 2)
(cannibals 0)
(source $bank1)
(destination $bank2) )
)
)
)
(method MoveCannibalsPropose (.agent achieve $g)
(rule
(topic $bank1 (type bank))
($bank1 boat $boat)
($bank1 cannibals $c)
($c > 1)
(topic $bank2 (type bank))
($bank2 <> $bank1)
-->
(propose ((.agent move-boat $boat)
(missionaries 0)
(cannibals 2)
(source $bank1)
(destination $bank2) )
)
)
)
(method MoveMissionaryCannibalPropose (.agent achieve $g)
(rule
(topic $bank1 (type bank))
($bank1 boat $boat)
($bank1 missionaries $m)
($m > 0)
($bank1 cannibals $c)
($c > 0)
(topic $bank2 (type bank))
($bank2 <> $bank1)
-->
(propose ((.agent move-boat $boat)
(missionaries 1)
(cannibals 1)
(source $bank1)
(destination $bank2) )
)
)
)
(method MoveBoatApply (.agent move-boat $boat)
(rule
(.thought source $bank1)
(.thought destination $bank2)
(.thought missionaries $m)
(.thought cannibals $c)
($bank1 missionaries $m1)
($bank2 missionaries $m2)
($bank1 cannibals $c1)
($bank2 cannibals $c2)
-->
(retract
($bank1 boat $boat)
($bank1 missionaries $m1)
($bank2 missionaries $m2)
($bank1 cannibals $c1)
($bank2 cannibals $c2)
)
(assert
($bank2 boat $boat)
($bank1 missionaries (- $m1 $m))
($bank2 missionaries (+ $m2 $m))
($bank1 cannibals (- $c1 $c))
($bank2 cannibals (+ $c2 $c))
)
)
)
)
;
;
;
(problem Mac
(topic Boat-1
(type boat)
)
(topic Bank-1
(type bank)
(missionaries 3)
(cannibals 3)
(boat Boat-1)
)
(topic Bank-2
(type bank)
(missionaries 0)
(cannibals 0)
)
(topic Goal-1
(type goal)
(object Bank-2)
(missionaries 3)
(cannibals 3)
(boat Boat-1)
)
)
Syntax Highlighter Test
I found a way to insert code snippets into the blog. As long as you can find somewhere to host the files SyntaxHighlighter seems to be the best solution. Here is a good tutorial to get rolling.
class MyClass {
bool blah(){
return 2 > 1 ;
}
}
Sunday, May 11, 2008
Looks are Everything
Well, I managed to rearrange and rebuild everything with Visual C++ 2008 express.
Now it's time to get rid of the uglies!
I went over to a place called Psionic where most Ogre folks get their free models.
Thankfully I found a patch for the Ogre Blender Exporter that does the axis swapping again.
Only problem is that the Jeep model is still backwards. Either I research how to rotate vertices in Blender or I can just rotate the mesh in Ogre.
It's never easy.
Now it's time to get rid of the uglies!
I went over to a place called Psionic where most Ogre folks get their free models.
Thankfully I found a patch for the Ogre Blender Exporter that does the axis swapping again.
Only problem is that the Jeep model is still backwards. Either I research how to rotate vertices in Blender or I can just rotate the mesh in Ogre.
It's never easy.
Friday, May 9, 2008
Rock and a Hard Place
Now I'm in a real dilemma.
I'm having a problem with Boost 1.35, CeGui, and vc7.
There isn't a problem with vc9, so it must be a bug in vc7 that they haven't done a workaround for yet.
I could go back to Boost 1.34 but then I'd have to include ASIO separately and I'm not sure if I can use vc9 with it.
Hmmm...
I'm having a problem with Boost 1.35, CeGui, and vc7.
There isn't a problem with vc9, so it must be a bug in vc7 that they haven't done a workaround for yet.
I could go back to Boost 1.34 but then I'd have to include ASIO separately and I'm not sure if I can use vc9 with it.
Hmmm...
Thursday, May 8, 2008
Shaking the Tree
Sometimes when your stuck in a rut it's time to shake things up.
My way of shaking things up this time is to upgrade to Boost 1.35 and creating a build system for Visual C++ 2008.
The reason for upgrading Boost is that ASIO is now an official part of the library and I need to replace the socket classes I wrote to make Botworx more portable.
Unfortunately, they totally rewrote the thread library and the locks and mutexes I was using caused things to hang. All that synchronization stuff probably needs a rewrite anyhow.
I think I'm going to dump ODE and Bullet and just go with PhysX. I can't count the hours I've spent making a hybrid system work. It works, but ... time to move on.
My way of shaking things up this time is to upgrade to Boost 1.35 and creating a build system for Visual C++ 2008.
The reason for upgrading Boost is that ASIO is now an official part of the library and I need to replace the socket classes I wrote to make Botworx more portable.
Unfortunately, they totally rewrote the thread library and the locks and mutexes I was using caused things to hang. All that synchronization stuff probably needs a rewrite anyhow.
I think I'm going to dump ODE and Bullet and just go with PhysX. I can't count the hours I've spent making a hybrid system work. It works, but ... time to move on.
Subscribe to:
Posts (Atom)