In the meantime, code that probably mostly should work for a simple maze gen:
// no enums yet...public goose class PathState{}public goose class Wall: PathState{}public goose class Clear: PathState{}public Wall wall = new Wall;public Clear clear = new Clear;public goose class TileState{}public goose class Unvisited: TileState{}public goose class Visited: TileState{}public Unvisited unvisited = new Unvisited;public Visited visited = new Visited;public goose class CardinalDirection{}public static CardinalDirection direction from int (int DirectionCode){ if(DirectionCode == 0){ return(north); }else if(DirectionCode == 1){ return(east); }else if(DirectionCode == 2){ return(south); }else if(DirectionCode == 3){ return(west); }else{ return(null); }}public static CardinalDirection random direction{ return(direction from int rng.Next(0,4));}public goose class East: CardinalDirection{}public goose class North: CardinalDirection{}public goose class West: CardinalDirection{}public goose class South: CardinalDirection{}public East east = new East;public North north = new North;public West west = new West;public South south = new South;public Random rng = new Random; public class Coordinate{ public int x; public int y; public bool this exists in (Map map){ if(x < 0 || map.Tiles.Count < x || map.Tiles.Count == x){ return(false); } if(y < 0 || map.Tiles[x].Count < y || map.Tiles[x].Count == y){ return(false); } return(true); } public Coordinate this move (CardinalDirection direction){return(null);} public Coordinate this move (North direction){ local Coordinate rtn = new Coordinate; rtn.x = this.x; rtn.y = this.y - 1; return(rtn); } public Coordinate this move (East direction){ local Coordinate rtn = new Coordinate; rtn.x = this.x + 1; rtn.y = this.y; return(rtn); } public Coordinate this move (South direction){ local Coordinate rtn = new Coordinate; rtn.x = this.x; rtn.y = this.y + 1; return(rtn); } public Coordinate this move (West direction){ local Coordinate rtn = new Coordinate; rtn.x = this.x - 1; rtn.y = this.y; return(rtn); }}public class Tile{ public PathState EastPath = wall; public PathState SouthPath = wall; public TileState Status = unvisited;}public class Map{ public int maxX; public int maxY; public List> Tiles = new List>; public void Initialize(){ Tiles.Clear(); // no for loops yet... local int x; local int y; do{ Tiles.Add(new List); do{ Tiles[x].Add(new Tile); y=y+1; }while(y x=x+1; }while(x } }public static void display( Map TargetMaze ){ local int x; local int y; x = 0; print "#"; do{ print "##"; }while(x print " \r\n"; x = 0; y = 0; do{ print "#"; do{ print "."; if( TargetMaze.Tiles[x][y].EastPath == wall ){ print "#"; }else{ print "."; } x = x + 1; }while(x print " \r\n"; x = 0; print "#"; do{ if( TargetMaze.Tiles[x][y].SouthPath == wall ){ print "#"; }else{ print "."; } print "#"; x = x+1; }while(x print " \r\n"; y = y+1; }while( y < TargetMaze.maxy ); }public static bool done in (Map workMap) at (Coordinate Cursor){ local Coordinate workCoordinate = new Coordinate; workCoordinate = Cursor move north; if(workCoordinate exists in workMap && workMap.Tiles[workCoordinate.x][workCoordinate.y].Status == unvisited){ return(false); } workCoordinate = Cursor move east; if(workCoordinate exists in workMap && workMap.Tiles[workCoordinate.x][workCoordinate.y].Status == unvisited){ return(false); } workCoordinate = Cursor move south; if(workCoordinate exists in workMap && workMap.Tiles[workCoordinate.x][workCoordinate.y].Status == unvisited){ return(false); } workCoordinate = Cursor move west; if(workCoordinate exists in workMap && workMap.Tiles[workCoordinate.x][workCoordinate.y].Status == unvisited){ return(false); } return(true);}public static void MazeStep( Map workMap, Coordinate Cursor, List Path){ workMap.Tiles[Cursor.x][Cursor.y].Status = visited; Path.Add(Cursor); while( !done in workMap at Cursor ){ local CardinalDirection RandomDirection; local Coordinate NewCursor; do{ RandomDirection = random direction; NewCursor = Cursor move RandomDirection; }while( !( NewCursor exists in workMap && workMap[NewCursor.x][NewCursor.y].Status == unvisited)); if( RandomDirection == east ){ workMap.Tiles[Cursor.x][Cursor.y].EastPath = clear; }else if(RandomDirection == south){ workMap.Tiles[Cursor.x][Cursor.y].SouthPath = clear; }else if(RandomDirection == west){ workMap.Tiles[NewCursor.x][NewCursor.y].EastPath = clear; }else if(RandomDirection == north){ workMap.Tiles[NewCursor.x][NewCursor.y].SouthPath = clear; }else{ print "!!! Unknown random direction?!?"; } MazeStep(workMap,NewCursor,Path); } Path.RemoveAt(Path.Count - 1);}public static Map create (int xsize) by (int ysize) maze{ local Map rtn = new Map; rtn.maxX = xsize; rtn.maxY = ysize; rtn.Initialize(); local Coordinate Cursor = new Coordinate; Cursor.x = rng.Next(0,xsize); Cursor.y = rng.Next(0,ysize); MazeStep(rtn,Cursor,new List); return(rtn);}public static void main(){ display (create 40 by 40 maze);}
For loops don't exist yet, nor do enums, nor does the increment operators, nor does class static methods. Plus the language currently doesn't respect private/public/etc, but does include that info for type compares (so everything is public and there's no property use). And Dictionarys are dubious yet.
Included are some examples of this-method use, explicit identifiers, and polymorphism on parameters. Feedback encouraged, even if (/especially if) it's less than complementary. Some of the naming and structure conventions are a little varied. Still trying to get a feel for writing in the new language since making it and using it are not really complementary at all. But now sleep. Tomorrow debugging and hopefully some final code and some output.