A Systems Approach to Visualization of the Problem Solved Algorithms and the Programming Language LOGO
Total Page:16
File Type:pdf, Size:1020Kb
Advances in Sensors, Signals, Visualization, Imaging and Simulation A systems approach to visualization of the problem solved algorithms and the programming language LOGO MICHAL MUSILEK, STEPAN HUBALOVSKY Department of Informatics University of Hradec Kralove Rokitanskeho 62, Hradec Kralove CZECH REPUBLIC [email protected], [email protected], http://www.musilek.eu/michal Abstract: - One of the most important tasks in teaching of algorithm development and programming is to use a suitable method of developing theoretical knowledge of this area. Drawing on their experience, the authors have found that the best method to be used is the system approach. This method, described in the paper, is presented through the simulation and visualization of two real processes – Tower of Hanoi brain teaser and decrypting of the Daisy cipher. The solution is demonstrated step by step – it starts with the problems definition, then the strategy solution analyses are shown and finally visualization of the processes is presented in illustrative form in LOGO programming language. Key-Words: Algorithmic thinking, LOGO programming language, system approach, multidisciplinary learning, problem solving, education, computer simulation and modeling, visualization, turtle geometry. 1 Introduction The process can be understood as series of The term algorithm can be also connected with transformations that changes the input values to the terms system, model, simulation, output values. From the system point of view the multidisciplinary approach, which are important in process is dynamic system in which the values of current approach to scientific, technological and the characteristic of the system elements are professional practice. Many universities are changed under the influence of the external realizing that modeling and simulation is becoming elements. an important tool in finding the strategy for solving The models are always only approaching of the and understanding numerous and diverse problems. reality, because the real systems are usually more The examples can be found e.g. in [1], [2], [3]. complex than the models are. The model is always In this paper we first briefly introduce the theory to be understood as simplification of the original. If of system approach, modeling and simulation as a the relation of isomorphism is between the model method of multidisciplinary and system approach to and real system the original model we could not education of algorithm development. distinguish between the model and the original, Secondly we introduce a case study illustrating which is discussed e.g. in [4], [5], [6]. step by step process of algorithm development and computer simulation of a two real processes – solving of Tower of Hanoi brain teaser and 1.2 Simulation decrypting of the Daisy cipher. The process of modeling closely relate to the simulation. Simulation can be understood as process of executing the model. Simulation enables 1.1 Modeling representation of the modeled real system or real Modeling is a method that is often used in process and its behavior in real time by means of professional and scientific practice in many fields of computer. The simulation enables also visualization human activity. and editing of the model. The main goal of modeling is not only describing A typical simulation model can be described both the content, structure and behavior of the real through specialized programming languages that system, which representing a part of the reality, but were designed specifically for the requirements of also describing the processes. simulations, or the simulation model can be created ISBN: 978-1-61804-119-7 205 Advances in Sensors, Signals, Visualization, Imaging and Simulation in standard programming languages. The computer simulation of the case studies will From the above considerations, it is clear that be realized and visualized in LOGO programming simulation is in many cases a process that runs on language. the computer. In some publications, therefore, can be found the term ”computer simulation“. It generally is valid that computer simulation is a 2 Solution of problem of visualization computer-implemented method used for exploring, in the programming language testing and analysis of properties of the conceptual (mathematical or process) models that describe the LOGO The term visualization is closely related to the term behavior of the real systems or real process which simulation. Visualization is a technique that cannot be solved using standard analytical tools, se transforms, selects and shows the output data and e.g. [8]. data obtained from the simulation, allows the The simulation models represented by executable investigation, analysis and interpretation. Among computer program have to be isomorphic with the the commonly used tools in scientific visualization conceptual model that is a representation. It means are 2D and 3D charts, tables, flowcharts, animated that the mathematical model and simulation model diagrams and others. have to represent the real system, its elements, internal interactions and external interaction with the environment in the same way. 2.1 A programming language developing logical and creative thinking - LOGO 1.3 Significant function of the simulation The first programming language designed to Simulation has from the scientific point of view teaching and to developing logical and creative several functions – see e.g. [8]. thinking at all in both children and adult students is We will focus two of them in this paper and they the language LOGO. Its creation was influenced by are: the work of Swiss developmental psychologist and - replacement the real process; spiritual father of the constructivist school in theory - development of educational process. of education - Jean Piaget (1896 - 1980). LOGO Replacement of the real process was designed by Seymour Papert (* 1928), Piaget's This is an important and indispensable feature of student, one of the pioneers of artificial intelligence, simulations and simulation model because it allows known American mathematician, computer scientist realize a situation of the process that cannot be and educator. Papert worked with Piaget in the years investigated conventionally. The main advantage of 1958 to 1963 at the Geneva University. "Nobody understands my ideas as well as Papert," Piaget simulations is that simulations model allows said. Pappert created LOGO programming language providing rather big number of the process steps in in 1967 after his arrival at MIT (Massachusetts relatively short time, changing of input parameters Institute of Technology). LOGO is partially based and its visualization and optimization of the process. on the LISP programming language (called Development of educational process "artificial intelligence language"), from which it The simulation is very useful from educational took over working with lists. A completely new idea point of view. Using the simulation model and was the socalled turtle geometry. visualization of simulation results on the screen, students can better understand the basic features of the processes and systems and develop their 2.2 Tower of Hanoi brain teaser intuition. It is also essential that the teaching by The challenge is to find a suitable solution to means of simulation is much cheaper and faster than visualize the well-known puzzle Tower of Hanoi. the teaching carried by real experiment. In some This puzzle was devised by French mathematician cases providing the real experiment cannot be Édouard Lucas (1842 – 1891) in 1883. The brain feasible. teaser consists of three pins, which can be pulled on Above mentioned functions of simulation will be circular disks of different radii. represented in following part of the paper by two All n disks are deployed on the left pin at the case studies - Tower of Hanoi brain teaser and beginning, where they are sorted from the largest to Transposition cipher determined by the figure – the smallest disk. The task of the solver is to move the Daisy cipher all the discs on the middle pin, while the right pin is ISBN: 978-1-61804-119-7 206 Advances in Sensors, Signals, Visualization, Imaging and Simulation used as an auxiliary storage space. It is necessary to observe the following rules: a) You can relocate only one disc in one move. b) A move consists of taking the upper disk from one tower and placement on top of another tower. c) It is forbidden to put a bigger disk on a smaller one. Simple and elegant solution can be found on the Internet [7]: to move :n :from :to :via if :n = 0 [stop] move :n-1 :from :via :to (print [Move disk from] :from [to] :to) move :n-1 :via :to :from end Fig. 1 The daisy cipher with counting-out game move 4 "left "middle "right to overedge :b :a if (:b <= :a) [output :b] But this solution is not at all illustrative, if (:b > :a) [output sum mod :b :a 1] because it provides a text-only output. It is end possible and necessary to build on this simple recursive solution of a system of interconnected to daisycipher :n :k :text :countingout components. make "outward list 1 2 make "i 2 repeat :n-2 [make "i :i+1 2.3 A Transposition Cipher Determined make "outward lput :i :outward] by the Figure – The Daisy Cipher make "i 0 make "position 1 Figure 1 shows the daisy cipher with countingout make "counter 0 rhymes. For decryption of this cipher we start with repeat :n the letter at the top (0 ° azimuth) and then expect [make "i :i+1 other letters in a clockwise direction using counting- make "outward replace :outward :position out rhymes.