# File vw1b.py # # Author: G.Doeben-Henisch # First date: July 21, 2019 # Last date: July 22, 2019 ''' ACTOR STORY 1. There is a human executive actor as a user who uses a program as an assisting actor by an interface with inputs and outputs. 2. The program tries to construct a 2D-virtual world in the format of a grid. The program needs the size of the grid as (m,n) = (number of columns, number of rows), which is here assumed by default as equal m=n. After the input the program will show the grid on screen. 3. Then the program will ask for the percentage of obstacles 'O' and energy objects (= food) 'F' in the world. Randomly the grid will be filled according to these values. 4. Then a finite number of virtual actors will be randomly inserted too. In the first version only one. POSSIBLE EXTENSIONS In upcoming versions the following options should be added: 1. Allow multiple objects with free selectable strings for encoding. 2. Allow multiple actors. 3. Allow storage of a world specification with reloading in the beginning instead of editing. 4. Transfer the whole world specification into an object specification. This allows the usage of different worlds in one program. ''' ############################ # IMPORTS import random as rnd import gridHelper as grh ############################ # SUPPORTING FUNCTION # # Now in a dedicated module gridHelper.py in folder 'code' # Complete path: C:\Users\gerd_2\code # This path has to be included for the python path search mechanism # # Show actual path values # # >>> import sys #>>> sys.path # ... # Extend the python path by appending the modul path: # # In my case the path is as follows: # #>>> sys.path.append('C:\\Users\\gerd_2\\code') ########################## # Main Programm ############### # Start main loop # # The loop will work as long as the value of the variable 'loop' is different to 'N' loop='Y' while loop!='N': ################### # The user will be asked for some parameters needed for the editing of a virtual 2-dimensional world # Number of columns (m) and rows (n); by default equal. m=int(input('Number of columns (= equal to rows!) of 2D-grid ?')) n=m mx=grh.nmlist(n) # Generate a first empty matrix n*m # Percentage % of obstacles in the 2D-world?\n) obstacles=int(input('Percentage (as integer) of obstacles in the 2D-grid?')) no=grh.numberObj(obstacles,n) mx=grh.placeObj(no,n,mx,'O') # Percentage % of energy objects in the 2D-world?\n) energyObj=int(input('Percentage (as integer) of Energy Objects (= Food) in the 2D-grid ?')) no=grh.numberObj(energyObj,n) mx=grh.placeObj(no,n,mx,'F') # Default placement of 1 executing virtual actor in the 2D-world?\n) print('Default random placement of one virtual actor\n') no=1 mx=grh.placeObj(no,n,mx,'A') # Clarify how to continue loop=input("STOP = 'N', CONTINUE != 'N' \n")