Martin | 7 Sep 13:35

Re: Tools for high level game AI

On Fri, Sep 05, 2008 at 07:34:25PM -0700, Steven Johnson wrote:
> If you don't mind Lisp, chapter 22 of this book has a good summary (#23 and 24 may be useful too):
> 
>   http://paulgraham.com/onlisptext.html
...
> Here's a quick example of the parlor trick with sum 7 (Fig. 22.3 in the book)

I have read that chapters. thanks for pointing them out.
After some code testing (in scheme) I have two question (both about lua):
- When I tried to use your two files I got error:
> /usr/share/lua/5.1/Coroutine.lua:6: attempt to index global 'callops' (a nil \
value)

  Where this module callops can be found?

- Can you show me how to modify your lua parlol example by supplying
  function that will return all possible combinations of two numbers?
  I have been trying to do it in scheme but with no success. I could though
  get them one by one by manually typing (fail).

Martin

Steven Johnson | 7 Sep 15:45
Favicon

Re: Tools for high level game AI

Hi.

> I have read that chapters. thanks for pointing them out.
> After some code testing (in scheme) I have two question (both about lua):
> - When I tried to use your two files I got error:
> /usr/share/lua/5.1/Coroutine.lua:6: attempt to index global 'callops' (a nil \
> value)

>  Where this module callops can be found?

Sorry about that. That was my quick comment about utility functions :). These
are all basically just "saves typing" / "saves function / table creation" functions.
It ought to be fine to use the following:

   local type = type

   local function IsCallable (object)
      return type(object) == "function"
   end

or in C as:

   int AuxIsCallable (lua_State * L, int index)
   {
      if (lua_isfunction(L, index)) return 1;
      if (luaL_getmetafield(L, index, "__call") == 0) return 0; // __call

      lua_pop(L, 1);

      return 1;
(Continue reading)

Steven Johnson | 8 Sep 20:42
Favicon

Re: Tools for high level game AI

>  > - Can you show me how to modify your lua parlol example by supplying
>  >  function that will return all possible combinations of two numbers?
>  >  I have been trying to do it in scheme but with no success. I could though
>  >  get them one by one by manually typing (fail).
>  
>  
> As I hinted, it's not very mature yet. After the first non-fail the Choose
>  returns and the internal coroutine is lost. Maybe I'll add a ChooseMulti or
>  ChooseAll variant function with an accumulator table as argument or return
>  value, where in place of this line in coroutineops.lua
>  
>  
>     return choice
>  
>  
>  it would have
>  
>  
>     choices[#choices + 1] = choice
>  
>  
>  You would also need to pass a fail function, which could just be a no-op,
>  to the outer Choose so that it terminates gracefully (otherwise, in the best
>  case, it'll error on Reset).
>  
>  Hope that helps / makes sense. If not, I blame trying to reason about this
>  without coffee. :D I'll mess around with it tomorrow morning and post an
>  example if it works and you haven't already done it.
 
The new version is attached.
(Continue reading)


Gmane