PROGRAMMING WITH PYTHON – Simple Programming Environment with ubuntu 16.04

emerging-mind.org eJournal ISSN 2567-6466
Email: info@emerging-mind.org
10.-12.February 2018
Author: Gerd Doeben-Henisch
gerd@doeben-henisch.de
February 12, 2018

IDEA

This text describes a simple programming environment for python3
in an ubuntu 16.04 environment.

Contents

1 The Environment …  1
2 Steps To Prepare Python Environment …  2
3 Use Python Interactive Console …  3
4 Debugging with the Code Module …  6

PDF

Programming with Python. Part 6. First Demo Extended

emerging-mind.org
eJournal ISSN 2567-6466
(info@emerging-mind.org)
Author: Gerd Doeben-Henisch
gerd@doeben-henisch.de

ZIP-SW

VIDEO

Abstract

Part 4 was the first Milestone. For details see that document. In part 5 only small modifications and extensions happened.

Modifying Control Window Calls

There is only one simple call to start the control window without any other functions, this is ctrlWinStart(). All other calls do operate on features of the control window.

Extending Control Options With Percentage of Objects

A new control feature has been introduced: asking for the percentage of objects to be placed in the environment: ctrlWinLocateAct(winC). This allows a number between 1-100. The percentage of food-objects is still kept fixed with ’nfood = 1′.

The Whole Story Now

  1. A 7 x 7 grid is offered with empty cells.
  2. The user is asked for the percentage of objects in the environment (nobj) which shall randomly be distributed (black cells).
  3. 1% of cells is randomly occupied by food (i.e. here one cell) (green cell).
  4. The start position of an actor (red circle) can be selected by pointing into the grid.
  5. The number of cycles can be entered how often the environment shall be repeat the event loop.
  6. The type of behavior function of the actor can be selected: manually (:= 0), fixed (:= 1) as well as random (:= 2). With option 1 or 2 the demo is running by its own. With option 0 you have to select the next direction manually by clicking into the grid.
  7. While the demo is running it reports the actual energy level of the actor as well as the actual ‚Time of the environment‘ (which corresponds closely to the number of cycles).
  8. If either the maximum number of cycles is reached or the energy of the actor is below 0 the application will stop and after clicking into the grid  vanishes from the screen.

Asking for Percentage of Objects

ae5-Control Window asking for Percentage of Obstacles in Environment
ae5-Control Window asking for Percentage of Obstacles in Environment

Asking for Number of Cycles

AE5 - Control Window Asking for Number of Cycles to Run
AE5 – Control Window Asking for Number of Cycles to Run

ASKING FOR POINTING INTO THE GRID TO LOCATE ACTOR

AE5 - Control Window askeds to point into Grid to locate the actor
AE5 – Control Window askeds to point into Grid to locate the actor

Showing Env With Obstacles and Food

AE5 - Control Window Showing Actual Distribution of Obstacles (black), Food (green), as well as an Actor (green)
AE5 – Control Window Showing Actual Distribution of Obstacles (black), Food (green), as well as an Actor (green)

Select Behavior Type

AE5 - Control Window asking for Wanted Behavior Type of Actor (0-2)
AE5 – Control Window asking for Wanted Behavior Type of Actor (0-2)

Final Stage

AE5 - windows shows Grid with final state
AE5 – windows shows Grid with final state
AE5 - Control Windows Comments Final Stage with no moe Energy for Actor
AE5 – Control Windows Comments Final Stage with no moe Energy for Actor

The Importance of Freedom and Creativity

Although this environment is very simple, it can demonstrate a lot of basic ‚verities‘. It shows directly the inappropriateness of a fixed behavior even in a static environment. This implies that a non-fixed behavior realized as a random behavior is in principle strong enough to find a solution (if there is any). Whether a solution is possible or not depends from the available time which in turn depends form the available energy.

If one interprets‚random behavior‘ as a behavior based on freedom and creativity then one has here a strong motivation that a society based on freedomand creativityhas (other ‚bad‘ factors neutralized) the best chances to master an unknown future.

How to Continue

You can continue with Part 1 ‚How to Program with Python under ubuntu 14.04?‘

Programming with Python. Part 4. First Demo complete

emerging-mind.org
eJournal ISSN 2567-6466
(info@emerging-mind.org)
Gerd Doeben-Henisch
gerd@doeben-henisch.de
October 20, 2017

PDF

ZIP-SW

1 First Milestone Reached

The basic idea from the beginning was to check whether it is possible to
program in python a simple actor-environment demo with a graphical user interface (GUI).

During the parts 1-3 it could be proved step wise that all the wanted
features could be realized.

Clearly the actual code is far from being elegant nor is he completely
explained. But everybody can inspect the code delivered as a ZIP-folder.

This first GUI-based demo contains the following features:

1. A 7 x 7 grid is offered with empty cells.
2. 20% are randomly occupied by obstacles (black cells).
3. 1% of cells is randomly occupied by food (i.e. here one cell) (green
cell).
4. The start position of an actor (red circle) can be selected by pointing
into the grid.
5. The number of cycles can be entered how often the environment shall
be repeat the event loop.
6. The type of behavior function of the actor can be selected: manually
(:= 0), fixed (:= 1) as well as random (:= 2). With option 1 or 2 the
demo is running by its own. With option 0 you have to select the next
direction manually by clicking into the grid.
7. While the demo is running it reports the actual energy level of the actor
as well as the actual ’Time of the environment’ (which corresponds
closely to the number of cycles).
8. If either the maximum number of cycles is reached or the energy of
the actor is below 0 the application will stop and after 10 s vanish from
the screen.

2 How to Continue

There are many options how to continue. Actually the following ones are
considered:

ACTOR-ENVIRONMENT FEATURES

1. Enhance the actual version with with e.g. offering the selection of
more parameters to be eligible.
2. Allow multiple actors simultaneously.
3. Allow the automatic repetition of a whole experiment over n-times.
4. Allow storing of results and statistical evaluations.
5. Start explorations of different behavior functions like genetic algorithms,
classifiers, reinforcement, learning similar to alpha go zero,
etc.
6. Enhance perceptual structures and motor patterns.
7. Check different cognitive architectures
8. Enable basic dialogues with the environment
9. …

COMPUTING FEATURES

1. Transfer the windows implementation on ubuntu 14.04 too.
2. Compare the different versions.
3. Integrate the actor-environment pattern within the ros-architecture
4. Allow real-world sensors and actors especially for robotics, for sound
art work, for picture art work, for sculpture art works as well as for text
art work)
5. Rewrite the actor-environment demo as a distributed process network.
6. Realize a first demo of a Local Learning Environment
7. …

Continue to part 5

Programming with Python. Part 1. A simple Actor-Environment Demo

emerging-mind.org eJournal ISSN 2567-6466
(info@emerging-mind.org)
Gerd Doeben-Henisch
gerd@doeben-henisch.de
October 14, 2017

PDF

SOFTWARE AS ZIP-FOLDER

Contents
1 Introduction 2
2 Python Context 2
2.1 Python Language Source . . . . . . . . . . . . . . . . . . . . 2
2.2 Simple Graphics Library . . . . . . . . . . . . . . . . . . . . . 3
2.3 Python Console . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.4 Integrated Programming Environment . . . . . . . . . . . . . 4
2.4.1 PyCharm . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.4.2 WinPython (With spyder and numpy) . . . . . . . . . . 6
3 Problem to be Solved 6
4 Programming with Python 8
4.1 Testing an Environment . . . . . . . . . . . . . . . . . . . . . 8
4.1.1 A First Window . . . . . . . . . . . . . . . . . . . . . . 8
4.1.2 Rectangles, Lines, Circles, Text-Labels . . . . . . . . 9
4.1.3 Producing a Grid . . . . . . . . . . . . . . . . . . . . . 10
4.1.4 Grid with Vertical Lines . . . . . . . . . . . . . . . . . 12
4.1.5 Grid with Vertical and Horizontal Lines . . . . . . . . . 14
4.1.6 Introduce Helper Functions . . . . . . . . . . . . . . . 15
4.2 Introducing Objects . . . . . . . . . . . . . . . . . . . . . . . . 17
4.3 Introducing Actors . . . . . . . . . . . . . . . . . . . . . . . . 22
4.3.1 First Requirements for an Actor . . . . . . . . . . . . . 22
4.3.2 First Considerations How to Program . . . . . . . . . 23
4.3.3 Let an Actor Move: Environment . . . . . . . . . . . . 27
4.3.4 Let an Actor Move: Actor Self . . . . . . . . . . . . . . 37
4.3.5 The Final Main Procedure . . . . . . . . . . . . . . . 41
4.3.6 Final Helper Functions for the Environment . . . . . . 45
4.3.7 Final Helpfer Funtions for Actors . . . . . . . . . . . . 50
5 Close Up 54

BASIC IDEA

What you see here is the content of the attached PDF.  The text is somehow a protocoll of an experiment to learn the programming language python from scratch. No pre-knowledge, no tools, no teachers! If you are in the same situation and you like to learn python since long, here you can enter and follow the steps.

STARTING WITH A REAL PROBLEM

Many years I opposed to learn python because in my view the language is really disgusting from the point of view of mathematics. But, one has to accept, that python has made its way in many areas including technology, science, and the arts. And because I needed urgently an acepptable software environment for all my theories and experiments there is sometimes the day of decision: you have to start or you can’t show many things.

There is another point: meanwhile I identified as main framework for our theories (which we are discussing on uffmm.org) the combination of ubuntu + ros (robot operating system) + tensoflow. Here python is the main langauge besides C/C++. Furthermore  I detected many applications for our art projects, which are also strongly supported by python. Thus the motivation became stronger than my disgust about this quirky style of thinking.

In the attached PDF you can see how I battled through the python-jungle in 3 days producing a first outcome.

After these 3 days I would say, yes, python is a worthful tool to work with. I am convinced that we can solve most of our problems with it.

Therefore it is highly probable that you will find here more documents with python programs in the future. The idea is indeed to set up a local learning environment (LLE) which is small, flexible, portable,  and very powerful. It should enable really intelligent machines to help people, not to substitute people. The future will belong to new men-machine couplings.

CONTINUE with Part 2

SOME BACKGROUND STORY

some background story

Gerd Doeben-Henisch
info@emerging-mind.org
gerd@doeben-henisch.de

PDF

abstract

Some information about the motive behind this project; some historical remarks.

RELAUNCHE

This relaunch of the eJournal emerging-mind.org (ISSN 2567-6458) is motivated by an international book project rewriting the ideas of systems engineering (SE), actor-actor interaction (AAI) as part of systems engineering, as well as intelligent machines (IM) as part of AAI. There is also an introductory part which talks explicitly about the implicit philosophical assumptions which underlie a systems engineering approach in general. This book is written embedded in a public process documented on the uffmm.org website.

SOME GENERAL REQUIREMENTS

While the above mentioned book develops a strong formal framework for all the mentioned topics, such a pure formal approach is not enough. The processes described in the book are intended real processes in real environments relying heavily on software. Therefore it is an equally important question which kind of software framework can help in the application of the theory. The following requirements are considered as being important for the development of the emerging-mind lab.

AAI Theory

As one can read on the uffmm-site a radical formal approach is applied there to describe the analysis phase of systems engineering as it is realized by an actor-actor interaction approach. But for the real work this is not enough, one needs for the practical (industrial) work in the end software tools which support the formal theory to do the real work.

Intelligent Machines

Intelligent machines are analysed in the book as actor models within actor stories. Thus models can only be used as real dynamic processes if they are translated into real software within real computers. And this should be done in accordance with the AAI-paradigm.

Local Learning Environments

There is a third requirement which stems from the context of education and experimental research.

Today everybody has a computer or a smart-phone to log into some network which provides lots of services from somewhere. The network as such also the services as such are usually not open for experimental usage. But in education as well as in research one needs complex settings and one needs open structures, which can be changed.

For this one needs a local learning environment which contains its own network server with different clients (computers, smart-phones, raspi, robots, and so on) which can have more smaller clients like sensor, actors etc.

Solution Candidates

Although the search for an optimal hardware and software environment has not yet finished we have two first interesting candidates as main part of the intended structure: It is (i) the robot operating system (ROS) (see: http://www.ros.org/) running on ubuntu (actually only on the long term version 14.04), and, with a different scope, (ii) the tensorflow framework (see: https://www.tensorflow.org/).

How to Continue?

The next possible readings are:

  1. EML ROS-Environment. Basic Ideas
  2. Python Programming. Part 1. Simple Environment-Actor Demo