Welt 2

//*************************************************
// WORLD v2
// 
// AUTHOR: G.Doeben-Henisch
// First: 12.Nov.2013
// Last: 10.Dez.2013
//*************************************************
//
// IDEA
//
// A WORLD W consist of the 
//
// - WORLD structure GRIDSPC (for the spatial structure and the objects)
// - WORLD structure GRIDAUD (for the sound structure)
// - WORLD structure GRIDIMG (for an image structure) (optional)
// - a WORLD population POP
// - a WORLD INPUT BUFFER (WIB)
// - an a WORLD FUNCTION wf()
//
// The GRIDSPC represents a 2-dimensional field  with (Y,X)-coordinates
// The GRIDAUD represents a 2-dimensional field parallel to the spatial GRID
// containing sounds emitted at that position
// The GRIDIMG represents a 2-dimensional field parallel to the spatial GRID
// containing images associated with the objects at that position
// The POP represents a list of all learning semiotic systems present in the GRID
// The WIB represents the planned actions of all LSSs in a list. 
// The wf() manages possible changes according to the actual GRID, the content
// of the WIB and according to some world laws.
//
// wf1 = newPOS o newACT o newSOUND
//
// The change of the images happens associated with the newACT operations
// 
//****************************************************************************
// WORLD STRUCTURE GRIDSPC
//
// PRECONFIGURED GRIDS
// 
// - Fixed data structures as n x m arrays
// 
// AUTOMATIC GENERATED GRIDS
// 
// - functions to generate n x m arrays according to some rules
// 
// OBJECTS
// 
// - Possible objects: 'O', 'F', '.', '*i' with 'i' in {1,...,4}
// - The 'plan' of a map is always without the systems 
//
//****************************************************************************
// WORLD STRUCTURE GRIDAUD
// 
// Fixed data structures as n x m arrays (spatial copy of GRIDSPC)
// 
// FORMAT of a CELL:
// [SAY, SNDC]
// SAY := ASCII-String of a saying
// SNDC := CODE for some sound-file of some sound (optional)
//
// COMMENT: Because in this world only one object can be placed at the same position = cell, 
// only one soUnd can be emitted at a world cycle
//
// SOUNDLIB
// Is a library of preinstalled sounds, which can be activated in world W1. 
// Format:
// [[SNDC, SOUND]; ...]
//
//****************************************************************************
// WORLD STRUCTURE GRIDIMG
// 
// Fixed data structures as n x m arrays (spatial copy of GRIDSPC)
// 
// FORMAT of a CELL:
// [IMG, IMGC]
// IMG:= ASCII-String of an image
// IMGC := CODE for some BINARY FILE OF AN IMAGE
//
// COMMENT: Because in this world only one object can be placed at the same position = cell, 
// only one graphical representation can be placed at this position = cell
//
// IMAGELIB
// Is a library of preinstalled images, which can be activated in world W1. 
// Format:
// [[IMGC, IMAGE]; ...]
//
//****************************************
// POP
//
// List of LSSs
//
// [[ID, SYMBOL,POSOLD, POSNEW,FLAG, NEWENERGY], ... ]
// System 1 := 0000 := '*0'
// System 2 := 0001 := '*1'
// System 3 := 0010 := '*2'
// System 4 := 0011 := '*3'
//
// POSOLD := actual position (Y, X)
// POSNEW := new position (Y, X) which results when the system makes a movement
// FLAG := To control a random selection procedure 
// NEWENERGY := new energy when the system makes an eat-action

// Example: 
POP1=[['0000', '*0', '5','5','0', '0','0', '0']; ['0001', '*1', '5','6','0', '0','0', '0']; ['0010', '*2', '5','7','0',
'0','0', '0'];['0011', '*3', '5','8','0', '0','0', '0']]
//
// The population POP has 4 members. The ID of the first member is binary 'OOOO', which will represented in 
// the GRID as '*0'. The system will start at position (5,5) with first position Y pointing to the row 5 
// and second position X pointing to the column 5
// The other parameters ar actually set to zereo.

//***************************************************
// POPRAND
// (Dummy random population for test cases)
//
// FORMAT:
// [[ID, ENERGY-STATUS, ENERGY-CONSUMPTION], ...]

POPRND1=[['0000', '100', '2']; ['0001', '100', '2']; ['0010','100', '2'];['0011', '100', '2']]

//**************************************************
// WORLD INPUT BUFFER (WIB)
//
// List of Messages
//
// [[ID, ACTION], ... ]
//
// ACTION = [MOVE, NONMOVE, SAY, SNDC]
// Remark: One should extend the WIB with 'IMGC' for possible image codes later

// 
// MOVE in {'000', ... , '1000'} (Binary notation)
// NONMOVE = {'1001'} (:= 'eat')
//
// SAY in ASCII-Strings
// SNDC := some code for a sound
//
// Example:
WIB1 = [['0000', '000', '0', 'abab', '-']; ['0001',  '000','0',  '-', '-'];['0010', '000','0',  'xxxx', '-']; ['0011',
'000','0',  '-', '-']]
//    
// Sysdtem with ID '0000'  plans to make no move '000', has no nonmove-action '0', says 'abab' and indicates no further
spound '-'.

//**********************************
// GRID 'WOOD1' 
//
// Y = r=1...15, X = c=1...55
// The Y-axis is from above (north) to bottom (south), the X-axis is from left (west) to right (east)
// '.' := empty space; encoded '00'
// 'O' := Obstacle (Rock); encoded '10'
// 'F' := Food; encoded '11'
// Attention: scilab assumes GRID(Y,X) rows first and then columns!


//********************************************************************
// DYNAMIC GRID GENERATION
// Using the wood1-structure as building blocks
//
// YYMAX := Max number of rows multiplied by 5
// XMAX := Max number of columns multiplied by 5


function[GRID]=gridgen(YYMAX,XXMAX)
  
  if (YYMAX < 1) | (XXMAX < 1) then printf("gridgen:ERROR WITH YYMAX, XXMAX\n\n"), end
  
  for k=1:5:5*YYMAX
  i=k
    for j=1:5*XXMAX, GRID(i+0,j)='.',end
  i=k+1
  for j=1:5:5*XXMAX, 
    GRID(i,j+0)='.'
    GRID(i,j+1)='O'
    GRID(i,j+2)='O'
    GRID(i,j+3)='F'
    GRID(i,j+4)='.'
  end
  i=k+2
  for j=1:5:5*XXMAX, 
    GRID(i,j+0)='.'
    GRID(i,j+1)='O'
    GRID(i,j+2)='O'
    GRID(i,j+3)='O'
    GRID(i,j+4)='.'
  end
  
  i=k+3
  for j=1:5:5*XXMAX, 
    GRID(i,j+0)='.'
    GRID(i,j+1)='O'
    GRID(i,j+2)='O'
    GRID(i,j+3)='O'
    GRID(i,j+4)='.'
  end
  i=k+4
  for j=1:5*XXMAX, GRID(i+0,j)='.',end
  end
  
  disp(GRID)
  
endfunction

//*************************************************************
// TOLMAN's MAZE 1
//
// A grid according to the paper 
// "COGNITIVE MAPS IN RATS AND MEN"
// by Edward C. Tolman (1948)
//First published in The Psychological Review, 55(4), 189-208. 
//
//

// TOLMAN1 - grid for 1 system

TOLMAN1=['O' 'O' 'O' 'O' 'O' 'O' 'O';'O' '.' 'O' 'O' 'O' 'F' 'O'; 'O' '.' 'O' 'O' 'O' '.' 'O'; 'O' '.' '.' '.' '.' '.'
'O'; 'O' 'O' 'O' '.' 'O' 'O' 'O'; 'O' 'O' 'O' 'O' 'O' 'O' 'O' ]

// TOLMAN1s2 - grid for 2 systems

TOLMAN1s2=['O' 'O' 'O' 'O' 'O' 'O' 'O' 'O'; 'O' '.' '.' 'O'  'O' 'F' 'F' 'O'; 'O' '.' '.' 'O' 'O' '.' '.' 'O'; 'O' '.'
'.' '.' '.' '.' '.' 'O'; 'O' 'O' 'O' '.' '.' 'O' 'O' 'O'; 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O']

TOLMAN1s4=['O' 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O'; 'O' '.' '.' '.' '.' 'O'  'O' 'F' 'F' 'F' 'F' 'O'; 'O' '.'
'.' '.' '.' 'O' 'O' '.' '.' '.' '.' 'O'; 'O' '.' '.' '.' '.' '.' '.'  '.' '.' '.' '.' 'O'; 'O' 'O' 'O' 'O' '.' '.'  '.'
'.' 'O' 'O' 'O' 'O'; 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O']



TOLMAN2=['.' '.' '.' '.' '.' '.' '.' '.' 'O' 'O' 'O' '.' '.' '.' '.' '.' '.' '.' '.' '.' '.';
'.' '.' '.' '.' '.' '.' '.' '.' 'O' '.' 'O' '.' '.' '.' '.' '.' '.' '.' '.' '.' '.';
'.' '.' '.' '.' '.' '.' '.' '.' 'O' '.' 'O' '.' '.' '.' '.' '.' '.' '.' '.' '.' '.';
'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O' '.' 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O';
'O' '.' '.' '.' '.' '.' '.' '.' '.' '.' 'O' '.' '.' '.' '.' '.' '.' '.' '.' '.' 'O';
'O' 'O' 'O' 'O' '.' 'O' 'O' 'O' 'O' '.' 'O' 'O' 'O' 'O' '.' 'O' 'O' 'O' 'O' 'O' 'O';
'.' '.' '.' 'O' '.' 'O' '.' '.' 'O' '.' 'O' '.' '.' 'O' '.' 'O' '.' '.' '.' '.' '.';
'.' '.' '.' 'O' '.' 'O' '.' '.' 'O' '.' 'O' '.' '.' 'O' '.' 'O' '.' '.' '.' '.' '.';
'O' 'O' 'O' 'O' '.' 'O' 'O' 'O' 'O' '.' 'O' 'O' 'O' 'O' '.' 'O' '.' '.' '.' '.' '.';
'.' '.' '.' '.' '.' 'O' '.' '.' '.' '.' '.' '.' '.' '.' '.' 'O' '.' '.' '.' '.' '.';
'O' 'O' 'O' 'O' '.' 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O' 'O' '.' 'O' '.' '.' '.' '.' '.';
'.' '.' '.' 'O' '.' 'O' '.' '.' '.' '.' '.' '.' '.' 'O' '.' 'O' '.' '.' '.' '.' '.';
'.' '.' '.' 'O' '.' 'O' '.' '.' '.' '.' '.' '.' '.' 'O' '.' 'O' '.' '.' '.' '.' '.';
'.' '.' '.' 'O' 'O' 'O' '.' '.' '.' '.' '.' '.' '.' 'O' 'O' 'O' '.' '.' '.' '.' '.']



Gerd Doeben-Henisch 2014-01-14