Outdoors, Green Living, Homesteading, Sustainable living, Green Building

Uncategorized

Introduction to Data Structures and Java Collections


We all know programs have data, in fact in OOP an object is Data and Related program logic packaged into this thing called an Object. In Java, we have primitives byte, short, int, long, float, double, boolean, char. A String is an object made of the primitive char. But in general, all objects can be broken down into these primitives. And of course, all primitives are made of bytes. So you can say the most basic data type is the byte. And the most basic data structure is a series of bytes. Or an array of bytes. And the most basic collection is the Array.

  • The bit (on or off, 0 or 1, true or false)
    • boolean actually its stored as around 1 byte in the JVM, but its JVM dependent.
    • BitSet is a class that stores and handles bits in bit size memory allocations.
  • The Byte (8 bits)
    • byte  1 byte signed whole -128 to 127  byte times 0xff will convert it to 0 to 255
    • short 2 bytes signed whole -32,768 to 32,767
    • int     4 bytes signed whole -2,147,483,648 to 2,147,483
    • long  8 bytes signed whole -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
    • float  4 bytes signed real 6-7 significant digits  ±3.40282347E+38F
    • double 8 bytes signed real 15 significant digits  ±1.79769313486231570E+308
  • Character
    • char 2 bytes  whole unsigned 0 to 65535  (for unicode characters) ASCII still fits in first 256 or 0 to 255 space.
    • String  a most common object that holds any number of char’s.
  • Reference
    • reference 4 bytes on 32 bit JVM, 8 bytes on 64 bit JVM so 8 bytes for most of us.

One might say a Java Reference value is a primitive whos value is a memory location. That would, however, be a pointer that languages like C use. But a reference is special in that you can’t see that value or use it. You can only swap values that you never see or use. References can have a value of null for example or be assigned a value with the new operator or assigned a value = to another reference’s value. Also in Java as of lambda’s you can pass a function by value, as well as an object. Object::methodName is a reference to an function.

If you want to see the size of something in Java, just use the Runtime object methods to determine free ram, make a bunch of that one thing or object, then subtract. Divide by the number of things or objects and it will give a rough estimate of its size. Java lang probably didn’t provide a sizeof operator because it wouldn’t be pretty. If you want to check the execution time of something you may do a similar feat. Just get the System.currentTimeMillis(); At the start of a method call, then again at the end of it. Subtract. You might even run it a hundred times then divide by 100 to get an average execution time.

  • make it work
  • make it right
  • make it fast
  • make it cheap

There are several methods used to determine the efficiency of algorithms. Big-O notation being one. I can not explain these because I have never really understood them. But I will simply tell you about them and you can research it for yourself. There are the Best case, Average case, and Worse case analysis. Also, IDE’s come with profiler tools. These tools can give you information on execution times for various parts of your programs. This can help to reveal “Bottlenecks” in performance. As a newbie, you may not need to be too worried about such issues. Java language Collections API will already be optimized for most of your needs. Just remember the following above list. Performance is not usually the first consideration when developing apps.

  • Classes
  • Objects
  • Arrays

So an object is made up of a list or collection of these values be it primitive or reference. This makes an object something like a data record. A data record is a list of name:value pairs in a given order. The data in an object is called fields and since methods are now referenced methods as well. The constructors are “constructor methods”. So yes I suppose they are references too. I’m not quite sure how inner classes are handled. But they are not part of the data of the class. They are a class (object) with their own data. I sometimes say Class and sometimes say Object.

A class is a blueprint for the objects. Any static fields and methods or other members belong to the class. Constructors cannot be static and are implicitly final. So the class has its set of name:value pairs also. But the distinction is that the class members are not copied. You can, however, make as many objects as you want from the class definition. This is what makes an object like a record in a database table. Make sense?

So an Array is a linear contiguous list of whatever data type you make an array of.  Each item in this list is an element and has a position number. So an Array[100] has elements numbered 0 to 99. Computers count starting at 0 if you recall. An array of a primitive is simply a list of numbers. An Array of an object of some kind is like a database table. Each object is then the record in the table. But the point here is that the two most basic data structures are Arrays and Objects.

  • Files
    • local storage
    • remote storage
    • archive storage
  • Streams
    • from input or to output
    • from memory to memory
    • storage to memory or memory to storage

A file on disk might also be considered to be a data structure. It is in its most basic form a series of bytes. As the bytes are read or written from memory, they are converted to and from primitives or objects. A line of text from a file is the object String. A file can be read as a series of bytes, or characters. And with utility classes other primitives and objects as well. IO Streams can be read and written as bytes, primitives, objects as well. But a stream is not a data structure. A stream is just a flow of data. You might say that data structures are stored in memory, passed through streams and stored in files on storage devices. The streams connect files with memory or computers with computers. So computer to computer is like a memory to memory stream. Streams may also come from input devices or go to output devices etc.

  • storing and retrieving
    • basic structures
      • Arrays
      • List
      • Hash Tables
      • Maps
      • Sets
      • Heaps
      • Dictionaries
      • Trees
      • Graphs
    • basic methods
      • random access
      • sequential
  • searching
  • sorting
  • traversing
  • recursion
  • randomization

Data structures become quite a bit more complex than what we have talked about thus far. A typical semester college course will cover them. And if you look you can find used textbooks everywhere about data structures. Look for Java Collections and Data Structures books. So what do these books cover?  Basically, storage and retrieval, sorting and searching.  As it turns out there are simple and quick to implement methods and more complex methods and difficult to implement methods. These methods have been pretty well standardized and are called algorithms. The name of the algorithm is sometimes named after the guy or gal who invented it. Or in the case of Bubble Sort, named based on how it works. All of these algorithms are used in varied situations throughout the computer world and even as a common computer user you see them in practical use every day.

Much can be said about Data Structures and Collections. I am going to be as brief as possible in this article, mostly listing and defining things for you. You can almost think of data structures as patterns for the way data has been kept for particular uses. These patterns sometimes seem like things we see in nature, a stream (List), branches (Tree), a web (Graph? Should have been Network) for example. So structures can have similar sounding names. Sometimes developers seem to misname things. Once the name is stuck, its there for good as if written in stone. For example, the Graph structure, in my opinion, would have been better called a Webb or a Net. Heck, a 2-dimensional array is more like a graph.  I hereby and from now on declare 2D arrays to be called Graphs and 3D arrays Cubes!

A 4D array a MultiVerse! A 5D Array is a Twilight Zone!  Naw… Let’s not overdo it.

One thing I want to note is that Java had collection classes originally that were synchronized. This means thread safe. There was a certain inefficiency in having any class to be synchronized so they decided to make new classes that were not synchronized. This is why we have Vector class vs ArrayList class. Vector is synchronized.

  • Arrays
    • Multi-Dimensional Arrays  (In Java these are Arrays of Arrays)
      • One Dimensional
      • Two Dimensional
      • Three Dimensional
    • Arrays of primitives.
    • Arrays of Objects.
    • The Arrays Class
    • The ArrayList Class
    • Treating a Random Access File like a storage-based array.
    • Stacks and Queues using Arrays

Using Arrays and Array-based objects is where you will start in programming data structures generally. One thing you will note is that you can use Arrays for stacks and queues, or linked list for stacks and queues. This is data structures within data structures more or less. You can also form trees within arrays. For example, you can do quicksort using trees in arrays or a dynamic tree structure. Same goes for other searching and sorting techniques. The Arrays class has some nice methods for search and sorting arrays. The ArrayList class is a wrapper for an array.  The ArrayList class has some handy methods for things you might normally have to code yourself, such as insert and delete. It will also give you a ListIterator for processing the array items sequentially.

  • Iterators
  • Comparable interface
  • compareTo() method

Iterator is something you will need to look into, its used much with List. It allows you to step through a list with hasMore() and next() methods. Otherwise, you would use a for loop to do the same. Also for sorting you will need to look into Comparable Interface and compareTo() method. Objects you want to sort will need to implement this interface.

  • Lists
    • ArrayList
      • ArrayList class
    • Vectors
      • Vector class
    • LinkedList
      • LinkedList class
      • Double Linked List
      • Circularly Linked List
      • Sorted Linked List
    • Stacks
      • Stack class
    • Queues
      • Sequences
    • Double Ended Queues
      • Dequeues
    • Priority Queues
      • Heaps

Lists are a series of some kind of data. The ArrayList and Vector above wrap an Array ( Static Data Structure) Whereas, Linked data structures are dynamic meaning they grow and shrink as needed. Sequences are ordered queues. A queue is a first in first out list (FIFO). Examples of a queue are keyboard buffer queue. A production queue worklist in a video game.   A priority queue is like multiple queues where each priority level has its own queue, higher priority queues are worked first. A stack is a last in first out list (LIFO). Imagine a stack of papers on desk where you you routinely add new things to the top of it. But you only work whats on top first. So you may work the stack down to half it size, or one day get busy and work it down to the bottom. I used a stack for a type of random surface generator a few years back on the Java Games and Graphics project, actually I did this many years ago with Pascal too. It generates a 3D surface that looks like a volcanic island.  Another example of a stack is the call trace stack that Java generates when exceptions are thrown. Heaps are randomly stored data of random sizes. Common examples are memory heaps. I also think of heaps as piles, mounds. Storage media manages data as heaps more or less. With heaps size and free space has to be managed properly or things run out of control. This is why we defrag occasionally. Memory can be defragged as well, I had a tool for this once but forgot what it was called.

  • Hash Tables
    • HashMap class
    • HashSet class
    • Hashtable class
    • LinkedHashMap class
    • LinkedHashSet class
    • WeakHashMap class

Has tables are lookup tables that store using key:value pairs. The way they work makes them very fast and efficient at storing and looking something up. You will see more data structures on data structures in the above.  Maps, List, Sets, Linked etc.

  • Maps
    • EnumMap
    • HashMap
    • Hashtable,
    • LinkedHashMap
    • TreeMap
    • WeakHashMap

Map, Dictionary, Hashtable all almost the same thing. Store using key:value pairs. Keys generally have to be unique.

  • Sets
    • TreeSet class
    • HashSet class
    • LinkedHashSet class
    • EnumSet class

Sets contain no duplicate elements. No objects who are equal when using the equals() method and only one null value at most. A set is really not as much of a data structure as a data requirement or restriction.

  • Trees
    • General Trees
    • Binary Trees
    • AA-Trees
    • Threaded Trees
    • Balanced and AVL Trees
    • NonBinary Trees
    • B-Trees
    • Binary Search Trees
    • Multi-Way Search Trees
    • (2,4) Trees
    • Red-Black Trees
    • Splay Trees
      • Bottom-Up
      • Top-Down
    • TreeMap Class
    • TreeSet Class

Trees are a common structure in nature. It’s talking about a branching structure. Other similar structures might be a river, stream system for water flow. A ridge structure branches a lot as well. The lungs have a branching structure whereas the circulatory system is more of a graph structure. Graphs or Networks can be broken down into a tree structure. Of course, a file system is a well-known tree structure that everyone uses and knows. Document object models are tree structures, such as XML or HTML DOM. This is a structure that developers should learn and know well.

  • Dictionaries
    • Log files
    • Hash Tables
    • Ordered Dictionaries
    • Lookup Tables
    • Skip List

Dictionaries are more or less like Hash tables or Maps

  • Graphs
    •  Networks
    •  Paths
      • Shortest Paths
        • negative  weighted path
        • positive weighted path
        • acyclic path
      • critical path
      • backtracking
    • Weighted Graphs
    • Directed Graphs
    • Undirected Graphs
    • Spanning Trees

As I said before I think Graphs data structure was misnamed. Net, Network, Mesh, or Web might have been better. Common graph structures in nature are spider webs, highway systems, electrical grids, and the internet itself. A cave system might be mapped out like a graph if it is a complex one. A graph is basically like a tree except that branches can connect to other branches. So in traversing a graph structure, you could end up going in circles. With graph structures, you get into Paths and pathfinding, for example finding shortest paths. I can see great uses for this in AI and game coding.

  • searching
    • linear searching
    • sequential search
    • binary searching
    • interpolation search
    • tree search

Java has some built-in implementations for searching, Look at the Arrays class. Its easy enough to code a linear search with for loop or an iterator.

  • sorting
    • Bubble Sort
    • Selection Sort
    • Insertion Sort
    • Shell Sort
    • Merge Sort
    • Tree Selection Sort (Tournament Sort)
    • Heap Sort
    • Quick Sort
    • NonRecursive QuickSort
    • Bucket Sort
    • Radix Sort

Why so many sort algorithms? Some are more efficient than others in given situations. Each one has a different best case, worst case and average case execution time. Java has some built-in implementations of the quicksort. Look at the Arrays class. Bubble sort is an easy one to code and is quick if the list is already in a mostly sorted state. You must iterate the list as many times as there are elements and simply swap higher with lower ones as you go. Lower values rise and high values sink. Or vice versa depending on how you set up the comparison. A very efficient sorting algorithm would analyze the data somehow and then pick the best one of the above to use for the given situation.

  • recursion
    • indirect recursion

Recursion is where a function calls itself. You would think this would end up in an infinite loop, but if set up properly it will not. Recursion is used heavily in sorting and traversing and working with trees. Though you don’t have to use recursion, you can code just about anything with or without recursion using loops and conditions instead. Indirect recursion is where function a calls function b and function b calls function a.

So this is an outline and guide for you to use in your computer science studies. It was taken from 4 textbooks about data structures. You should also search for things on Wikipedia such as “sorting algorithms”. Wikipedia list one I have not listed here Comb sort. Sometimes an algorithm has two names. I think this article could be made better, so consider this version 0.1 apha. As time goes by I will amend it. This is going to be the first in a series of articles I will do over the next one or two years where I make up my own examples of how to use everything talked about in the article using Java and hopefully eventually Javascript as well.

 

 

Advertisements

Learn to Code Java!


How easy is it to begin learning Java? I will explain steps needed to get started. What tools are needed? Which tools to avoid at first. Ask yourself a few questions. Why do you want to learn Java? What are your main goals in learning Java? What do you want Java to do for you? What kinds of problems do you want it to solve? You can use Java to code console apps, desktop apps, web apps, phone/tablet apps etc. Are you learning it because of school or because of work? For hobby? For self-education?

  • Get the JDK (Java Development Kit)
  • Get a console or command line, either Linux shell or Windows shell.
  • Get a text editor JEdit, Atom or Editpad Pro.
  • Get a java.exe interpreter and javac.exe compiler.
  • Get a google, and with a google get an Oracle Java documentation or tutorial.
  • Get a HelloWorld.java example.
  • Consider getting Ant build tool, though it’s not necessary for learning and I don’t use it for simple things, it’s a good tool to begin to become familiar with. And it’s easy to use at the command line.

This is all you need to begin learning Java but there are a couple of more steps in getting started.

  • add JDK bin folder to the system path variable.
  • set the classpath variable to ‘.’ current folder.

Other tips I have, make a c:\dev\java\work  folder to put things in as you learn. If you do not know how to use the console begin to learn simple things. Even learn to make a simple batch file on Windows or shell scripts on Linux. You can use Windows notepad.exe or even the vi editor on Linux if you wish to begin with, no text editor need be installed. I install jdk under c:\dev\java\jdk9  where 9 is the version major version number. so my bin folder is in c:\dev\java\jdk9\bin  which is what you need on the path so that you may use the command line tools. Ant will also have to be added to the path environment variable.

So pull up the editor, get the hello world example text and paste it into a blank buffer, save it as HelloWorld.java and then you will see that the editor should highlight the syntax in color for you. If not then you need to search for how to turn on syntax highlighting. It’s not necessary but it is nice. Sorry, no highlighting for Notepad users. Next compile with javac HelloWorld.java, if no errors then run with java HelloWorld. If all went well, then you should see something like “Hello World!” output to console. Congratulations you are now a Java programmer!

The next thing to learn will be more about System.out.println() or other System.out methods.  You can also use the Java Scanner class to get input from the command line easily.  Sorry, no color at the windows consoles at least. That is without using a 3rd party library such as JCurses.

You can code GUI apps with text editors and you should. Except for phone/tablet apps because they are a bit more complex you will need to install the Android Development Kit and Studio. If you want to learn web development then download Tomcat web server and run it. With Tomcat learn Servlets and very basic Java Server Pages. Learn Java Server Faces and Facelets. Learn Spring and Hibernate. And don’t expect to learn all of that in a day. I’d say a year of constant hard work maybe. You will also need to learn HTML 5, CSS 3 and at least some Javascript would be nice. Firebug is a good plugin for Javascript. And you will need several browsers for testing and development and testing. Then pick one probably Firefox for main development browser.

But for graphical fun just use java AWT, and Swing API’s. And begin to learn the replacement for those called JavaFX. And you can do this with text editors and command line tools and should.  I recommend coding applets for starting GUI and use appletviewer.exe tool to run them. Applets make it easy to get started drawing some graphics, using color and playing sound. You can move on after you get little better at GUI coding to Java frames for desktop and Java Web Start apps, which are basically the web replacement for applets.

For databases get SQLite or H2, find the appropriate JDBC drivers and get the JDBC Api’s and tutorials. Get an SQL tutorial from the Google.

Finally, if you must, get you an Eclipse IDE and check it out.  Or try out IntelliJ Idea or Netbeans, or one called BlueJ. There are probably others. There is a learning curve to using any tools, and using IDE’s do not make learning to program Java easier but can do the opposite. You can get by without an IDE for much by using Jakarta Ant build tool at the command line. You simply create a build.xml file and put it int he folder with your source. Then in that folder simply type ‘ant’ and it reads that file and builds your project, it removes old class files, recompiles all source files building new class files. It can build javadocs with the javadoc.exe tool which is the java documentation from your project and much more. It can even create jar archive files and deploy them to websites.

If you want to help out on opensource projects you will need to get you a GIT or SVN tool installed. CVS was the old tool and may still be used on some projects. There is a learning curve to using these tools so be prepared. Once you pass over a few hurdles its not bad at all.

The Java language comes with some very simple testing functionality. But you may want to look into testing frameworks such as JUnit for Java. There is one for javascript as well. You can write your own test without that, these are called drivers.  You simply make a class that sole purpose is to create an object and call its methods to test it out.

First things first. Learn Objects first. In Java, everything is an Object. The quicker you learn Java OOP the better. And let me warn you that Javascript OOP is similar but different and somewhat confusing compared to Java OOP.  Just begin some basic class definitions with constructors, methods, and fields. Make everything public ( a bad habit you will break later) and don’t use static class members, to begin with.  Later you will learn about inner classes, local classes, and anonymous classes. Anonymous inner classes are the more practical and useful. Though you are better off just making outer classes for now. You should always just put one class in one source file, it must be declared Public and it must be named the same as the source file. You can put other non-public classes in the same source file, it’s just not normally recommended because it can make it harder to find a class in amongst many source files when you go to look for it.  You will want to learn about Interfaces and Abstract classes and methods fairly quickly.

Public access means a class member can be seen by any other class anywhere, in the same package or others. Private means a member can only be seen by the class that it is a member of, not even sub-classes. You will need to learn about inheritance and polymorphism fairly soon too.  If a member has no access modifier then it can be seen by all classes in the same package (folder).  BTW ‘.’ is the current folder which is the default package in Java. If you include no package statement then the class is in this default package. Import in Java simply imports the name so that you do not have to use the full path to the class name such as java.awt.Button. If you import it then all you need to use Is Button. And java.lang.* is automatically imported in all classes. So you do not have to use java.lang.Integer, for example, only Integer and with no import java.lang.*; or import java.lang.Integer; For classes to be available to use in your app all that is needed is that they are found in the classpath.  So look into how to add classes or archives jar files to the classpath. There are a number of ways to do this.

I hope this is a good starting point for you if it is please let me know by emailing me admin@softwaredeveloperzone.com And read my articles at Software Developer Zone, softwaredeveloperzone.com

 

 

https://www.amazon.com/Thinking-Java-Introduction-Object-Oriented-Programming/dp/0131002872/ref=sr_1_5?ie=UTF8&qid=1530578420&sr=8-5&keywords=Thinking+in+Java

 

https://aax-us-east.amazon-adsystem.com/x/c/QoynvVDh_VlclRt7zaObCu8AAAFkXZZ0FgEAAAH2AR2TOCU/https://www.amazon.com/dp/1118008189?aaxitk=afv9FcmFIR2GCq8swZ817w&pd_rd_i=1118008189&pf_rd_m=ATVPDKIKX0DER&pf_rd_p=3930100107420870094&pf_rd_s=desktop-sx-top-slot&pf_rd_t=301&pf_rd_i=eloquent+javascript&hsa_cr_id=5124701090801

 


Im a Columnist on Brink of Freedom


Brink of Freedom (dot net) is a new web site and community for survivalist and preppers (pioneers). Their main topics are Fire Arms, Tactical, Economics, Politics, Homesteading, Health and Wellness, Outdoor Activities.

I have about 8 articles there so far and will be publishing one per week every Friday.

www.brinkoffreedom.ent
Author Listing
My author page with a list of my articles thus far


Java Accounting Ledger V2


WANTED! Comments. Not wanted! Compliments. If you want your comment to be accepted first you must not be a spammer that WordPress recognizes and second you need to comment specifically on some of the article’s specific material or facts.

The Survival Pod Cast
Off Grid Net

I will work this article up over the next few days about The simple free accounting app version II. This project may be found at Source Forge Java Ledger Project

A simple free accounting app I wrote. is the first post about this app.
It describes the data files. I have not changed the data file format so I won’t repost that info here.

What I have done is in upgrading the console interface significantly. Now we have a screen that is 90 columns wide and about 40 rows long. Instead of scrolling the console you now use the arrow keys to scroll a table on the report screen. Escape exits the report screen.

I’m not sure what happened here but some of these screen shots were changed in the upload. At any rate they give you an idea of what the app displays for you. Keep in mind I’m writing this app for a programmer, me. And its functional at this point. I only reads two data files and then presents these reports.

You will notice some of these are blurry.This is because wordpress resized the images
to fit the articles column width. I made them links to the full size images, simply click to view in full size on any image. Also after you bring up the image you get a zoom mouse pointer, click again to get max size.

These first two are of a balance sheet for a single month.



These next two show a multi column balance report for 5 months.




The next two show chart of accounts.




The next 3 are a journal report for a single month showing day to day transactions.





The last screen shots are Ledger account reports for different accounts.










These last two are ledger account reports for same account different months.

/a>

After downloading the ledger.zip file from sourceforge unzip it in a temp folder.
You should already have Java installed and the system PATH variable set to include the jdk/bin folder. Google for that if you do not understand how to do that. I show here
the folder structure. I show changing directories to the accounting/bin folder. I then
list the .bat(batch) files. The batch files contain examples of command line commands for getting various reports. They also function to get certain reports as is by running them. First you must run the classpath.bat file which will setup the jcurses and jdom libraries for use. You must run that batch file first! Then in the bin folder you may
run any of he other batch files to generate reports.

Two of the batch files take arguments. ledger.bat and journal.bat. Ledger takes Month Year and account number in format mmmyyyy ###. journal.bat takes Month Year in format mmmyyyy. You can edit the journal.xml file and accounts.xml file. You can set it up for yourself and customize it for your accounting situation and use it as is.

I admit there are some things that still need to be fixed in the reports. However the data is accurate and useful.












Range Finding, Mil Dot, DuPlex (Plex) Reticle, Parallax, MOA.


WANTED! Comments. Not wanted! Compliments. If you want your comment to be accepted first you must not be a spammer that WordPress recognizes and second you need to comment specifically on some of the article’s specific material or facts.

The Survival Pod Cast
Off Grid Net

mil dot reticle

Mil Dot Reticle

I’m working on understanding scope adjustments and use. I had always thought mil dot stood for Military Dot Reticle System. Nope, it means Milli-Radians. A Radian is PI at 180 and 2PI at 360 degrees. Milli-Radian is 1/1000th of a Radian. Or it means that the image in the scope at 10x power is 1/1000th the actually size of the object. So a 1 meter tall target at 1000 meters is 1 mil dot tall. A 1 yard tall target at 1000 yards is 1 mil dot tall. A 1 foot tall target at 1000 feet is 1 mil dot tall. A 1″ target at 1000″ is 1 mil dot tall. A 1 cm target at 1000 cm(10 meters) is 1 mil dot tall.

Remember that is at 10 power. So 5x power and the target is now 1/2 mil dot tall. 4x power and its slightly less than 1/2 mil dot tall. A Mil dot at 100 yards is 3.6″ (1/10th of 1yd(36″) at 1000yrds) There is nearly 17 Mil dots in 1 degree and 1 degree is 60 MOA. Or there is .28 or close to 1/3rd mil dots in one MOA. And one MOA at 100yrds is close to 1″. 200yrds 2″ and so on. So you can see that once you get this straight in your head you can really fine tune your POI (point of impact).

Could a mil dot reticle be used for short ranges such as air gun ranges? sure. A table could be made to help you with this. I’m not totally convinced that my math is correct here. So check me on this. I made a spreadsheet as such. Mil Dot is 1/range/(%of10x*1000). % of 10x is power /10.  In this case 4 power scope.

foot mil dot range ft x power % of 10x
1 20.0 20 4 0.4
1 13.3 30 4 0.4
1 10.0 40 4 0.4
1 8.0 50 4 0.4
1 6.7 60 4 0.4
1 5.7 70 4 0.4
1 5.0 80 4 0.4
1 4.4 90 4 0.4
1 4.0 100 4 0.4
1 3.6 110 4 0.4
1 3.3 120 4 0.4
1 3.1 130 4 0.4
1 2.9 140 4 0.4
1 2.7 150 4 0.4

MOA is Minute of Angle or 1″ at 100 Yards. Actually 1.047″ at 100 yrds. My new BSA scope has 1/4 MOA adjustment for both windage and elevation. This means 1/4″ at 100 yards. So this would be 1/8″ at 50yrds or 1/16″ at 25yds.  I have decided to zero my Chinese air gun at 20yrds because it is shooting at only 420 fps. This gives me a kill zone from 4yds(12ft) to 22yds(66ft) of 2″ diameter.

Once zero is set it can be moved with the elevation adjustment. At 20yds 1″ is about 20 clicks. A person could also re-zero at 25yds, 30yrds and 15yrds noting how many clicks is needed to reach each zero point. However the ballistics and kill zone changes dramatically when you change the zero point. You really need to know at each 0 point how high the pellet will rise above the line of sight. Will also need to know where it drops a few inches below line of sight.

plex reticle

DuPlex Reticle

Above is a common reticle which can be used for range finding. This is the reticle on my BSA 4×32 scope. I have yet to find out specs for it such as MOA of the thick to thin line transition you see in the image. Or how many inches that is at 100yrds from left to right or up to down. Many of these scopes are 30″x30″ at 100yds. So with lack of proper information I may have to use empirical methods for figuring this out with my particular scope. Once I have done that I will publish the results here. This process should be simple enough. I will setup something with 1″ or 2″ marks on it at 100yds from viewing position. Then count the number of marks from center to left or whatever. Double the results.

Saying the inner cross hair boxes 30″x30″ at 100yrds that means a coyote at 100 yards would nearly fill the box. A crow 8″ tall would be half the distance from outer box to center of cross hair. If the crow is at 25yrds then it would fill the box top to bottom. Its a matter of ratios. Its also a matter of knowing the average sizes of the game you are hunting. Also one can range objects such as fence post, pop can, bottle or other refuse. Just about anything you already know the size of in the field of view. Then when game moves into that position you have a jump start on estimating its range.

Using Parallax adjustment to determine range.  I think this blog link can explain better than I so here it is     “Parallax and Scopes”. This BSA Air Gun Scope I bought has a parallax adjustment on the objective bell up front. It shows 7.5yds to 100yds to infinity. It has markings on it for ranges between 7.5 and 100yds. As that article suggest they probably are not accurate. Also the article says that on lower powers such as this 4 power scope and at closer ranges such as air gun ranges parallax is not a huge problem. This may mean it will be more difficult to use this adjustment in ranging targets.

Basically you change your gaze or focal point forward and back, this will cause some movement to appear in the reticle between the target and the cross hairs. If you notice this movement you have parallax and then can adjust the setting until there is no parallax. The markings on the bell adjuster will give you the range. Conversely if you know the range by some other method, then you can reach up and set it to that range and know that most of the parallax is removed. Also that article said that parallax has nothing to do with focus adjustments. My scope comes with a focus adjustment on the front.


Small Projects I want to do sometime (todo list)


WANTED! Comments. Not wanted! Compliments. If you want your comment to be accepted first you must not be a spammer that WordPress recognizes and second you need to comment specifically on some of the article’s specific material or facts.

The Survival Pod Cast
Off Grid Net

When will I get to work on these projects and complete them? Maybe never. At least I have time to make up a list. And these will require funds and tools as well.

  • charcoal maker
  • making activated carbon with salt solution and charcoal maker
  • homemade water filter with both charcoal and ceramic if possible
  • 5 gal charcoal foundry
  • wood gassifier  generator
  • steam engine generator
  • vacuum packer from car a/c compressor.
  • freeze dryer from 1/2 horse vacuum pump.
  • auto alternator welder
  • hydrogen welder
  • auto alternator power gen
  • wind powered water pump
  • ram pump
  • program the heat sensors with java and that phigits controller
  • Shaving horse
  • riving horse
  • foot powered wood lathe
  • log arch
  • boring machine
  • test: air cooling with pipes and ground, cost per btu to power fans
  • test: liquid cooling with ground and hand dug wells or other. geothermal. cost per btu to circulate liquid and operate heat exchangers.
  • home made wood cook stove using kwool and steel.
  • cob bread oven
  • brick wood cook stove and oven.
  • setup security system using linux and zone minder software
  • rotary inverter using auto alternator
  • solar oven
  • solar toilet
  • solar powered electric furnace for melting metals.
  • put a motor on a bicycle
  • two man and one man go cart
  • small plywood boats and canoes based on some plans I found on the internet
  • ethanol still
  • methane digester
  • solar water still
  • stove top water still
  • hand water pump single person operation
  • hand water pump larger volume double person operation.
  • solar hot water heater
  • rocket stove
  • rocket mass heater
  • wood drying kiln
  • sand forge
  • micro-hydro power
  • home made battery cells
  • fire piston
  • wood and leather below
  • veggie oil lamp
  • Tallow candles
  • astrolabe
  • soup can propane torch forge

PC Game Free Civilization


WANTED! Comments. Not wanted! Compliments. If you want your comment to be accepted first you must not be a spammer that WordPress recognizes and second you need to comment specifically on some of the article’s specific material or facts.

The Survival Pod Cast
Off Grid Net

Free Civ (Civilization)

This post is about my favorite free pc game Free Civ at http://www.freeciv.org
This is a free version of a game based on Sid Myer’s Civilization II. Which is a game I have also spent much time playing in the past. I bought and played Civilization IV as well and like it. I don’t recall a Civilization III. Another great game by Sid Myer was “Alpha Centauri” Which is “beyond Civilization” where mankind sets out to colonize a planet in the nearest solar system 16 light years away. I’ve spent many hours playing that one as well.

Alpha Centauri (example)

What do I like about these games? Well its the game play. I’ve heard folks say the graphics sucks. That all depends on your perspective. The graphics is light and the game play is heavy. This type of game is similar but more complex than board games of the past such as Chess, Risk, Axis and Allies to name a few. It plays exactly like a computerized board game. Imagine Chess with 100’s of pieces! Imagine instead of a board that is 8×8 one that is 64×64 or much larger. Instead of being played in an hour or so a free civ game usually can take days to play. And instead of 20 to 50 turns try 400 or more.

In the case of free civ the game board can be laid out in almost any configuration you have seen in board games. I go with the traditional Civilization Diamond shaped board. The diamonds give a slight isometric perspective that is psuedo 3D. I believe you can do square or hexagonal as well in the game options. One thing about free civ is that the game is highly configurable with many many options. In this post I’ll tell you about a few I like.

Civilization begins in the year 4000 BC and continues turn by turn up to as far as you can go but generally 2000AD and further. In the early years a turn is 50 years long and as you reach 1900 the turns are shorter in years at only 1 year per turn. This is why you can do 6000 plus years in only 400 turns. Generally the game is getting close to being over by 2000 AD and beyond where technologies are maxed and only a few players are left. In free civ all players begin in the stone age with basic stone age abilities. Though there are options which allow each player to begin with a few random technologies. However you will quickly find that if you do not manage research your nation will be left behind and conquered rapidly. If you do not research properly then you must ally with a nation that is on top to keep from being eliminated.

In Civilization you are the head of state and make all decisions for your nation and its progress. I’ve heard this type of game called a God game but I’d rather not call it that. You are playing an emperor, president, general, dictator, king etc. And in free civ you may choose your government over time. Each type of government has various benefits which affect the growth and management of your nation.

The city in free civ is a huge part of the game. City management can become quit a chore. The free civ writers have made a great effort towards AI(artificial intelligences) assistants called Governors. Use the governors wisely and it will make game play much more enjoyable. Though don’t trust them completely, often I have to alter them or turn them off. Also they tend to select items for production that I’d not prefer at the time.

The game has a great set of reports which I use constantly. Research, Cities, Nations, Demographics are among the most important. The others are sometimes useful. The Cities report is very important and allows you to perform batch operations on sets of cities. It allows you precise control of selections of sets of cities based on all kinds of criteria. Number one most important city improvement is ‘city walls’. As long as no enemy can get to you no walls are needed but once you are found the walls must come up. Walls will work well until far into the future tech. If you don’t know exactly what you are doing going up against a walled city is suicidal in the first 3/4’s of the game which is about the first 300 moves or up until about the 1800’s to 1900’s.

The world wonders that your nation may construct over time are incredibly important. And through each age different wonders are more important than others. Once one nation constructs a wonder no other nations may construct it. To name a couple Great Wall, Pyramids, Statue of Liberty, Eifle tower etc. Wonders take many turns to complete, into the hundreds. However there are three ways to construct them much faster. One is to disband more expensive units in the city which is constructing the wonder. The best way is to use trade caravans or trucks to help build the wonder but you must first research trade technology. The third way is to finish off the construction by buying it with money. Usually wonders are far too expensive to buy from the start however.

Each of the civ games had various units that over time change because they are obsoleted by technological changes. I am going to provide you with a spreadsheet for analyzing free civ units for defending and attack strength with given modifiers. freeciv.xls. In free civ terrain, roads, railroads, cities, forts, walls, fortification (different than forts ‘dug in or entrenched’), veteran status and situations affect units movement, attack and defend stats. Its good to learn these as you can. Different civ games have had different and interesting units and just because free civ has a given set doesn’t mean it couldn’t have other interesting types of units and game rules. The problem is that if you get too many types of units and too many rules the game is no longer a game but work. Still its interesting to play the different civ games to see different rules and units. For example I think Civ IV had slavery and slaver units.Alpha Centauri has a completely new set of space age units.

AI (Artificial Intelligence) in free civ is pretty good, however I often think the “Normal” AI is cheating, and I’m sure the harder AI’s are cheating. This is because cheating is a technique used by AI programmers to increase difficulty level. I think they cheat by giving production bonuses mainly. Or by reducing production time. However you may select before game play the AI level for each AI and let me suggest you begin with Novice or Easy AI for all of them. If you want however you can make one Normal AI then if in the game you get see that he is about to end it you can let that process go through and loose the game or you can change the AI level for that AI during the game play in the Nations report. Another way you can cheat is to save the game, then leave the game and load it back, just before you start you can take the strongest player over and start it up as the strongest player, then give his cities to your player, again save and leave. Then switch players and start again.
Why would I want to cheat? After playing a game for 10 hours or more its sad to realize that I don’t get to play with the advanced technologies and units. It seems you pass through certain ages and never get to do combat with the units of that age. So its a way of changing the scenarios.

In free civ there are many nations to choose from or you may let the computer pick one at random for your player on start. There are ancient nations and medieval nations and modern nations. You may even find aliens and smurfs in the list. The main thing that different nations do is give different flags and city names. In some versions of civ one nation may begin with different technology than other nations. The nation without the technology to start must research it or steal it with a spy.

Free civ has great support for network play between multiple human players over the net or otherwise. You may even notice to play solo you have to start the free civ server. I have not played it much this way however because its difficult to find another player that is online when I am and has the same time available that I have. Though let me say that two players might play for a couple of hours then one would save the game. I think the game can be restarted at a later time so that it could be played over multiple sessions. There is a version of free civ called “Long Turn” free civ where only one turn per day is run. This means that a single game will take a year or more to complete. I have not done this but it looks like an interesting alternative. Google for “Long Turn Free Civ” I think you have to sign up and wait for games to begin. You could be in multiple long turn games at once. In this type of game you are playing against all human players I think.

Free Civ has an extensive help system both in the game interface itself and online in a wiki at http://www.freeciv.org. Use them. There is more to the game that I have not touched on such as different Government types i.e. Democracy, Republic, Communism, Monarchy, Anarchy and more. And some of the games in the series have different governments such as Dictatorship and Fascism which free civ does not have. I didn’t talk about taxes, science and luxury and citizen happyness. One comment about money, for the longest I didn’t build markets. If you are having trouble with taxes and are in the red every round add markets and trade routes. You can’t always raise taxes to solve the money problems, though I think our modern politicians seem to think that’s the only answer.

Some improvements to the game that I’d like to see are grouping of land and sea and air units for mass movements. The only way you may do that currently is with a transport ship or a carrier. I’d like to see the ability to set one unit to follow another unit. They don’t have to catch up until the leader stops. Or even formations for sea, and air units where one leads. Also why can’t the APC unit carry 2 to 5 foot units. Why can’t a special helicopter or plane carry 2 to 5 foot units and the plane could carry a few mounted or mobile units. The flight carry is emulated with the air drop feature later in the game. I guess they didn’t want the follow thing because any unit set as leader then becomes a carry transport unit in effect. But when moving large numbers of ships and planes across the map it can become quit a chore during game play. So I’m not exactly sure what a good answer might be. I guess though when following a leader the terrain modifiers would still affect units differently meaning either the leading unit must slow or the other units must catch up. This might be a difference between transport and follow.

I didn’t talk about worklist and production list. But its easy to setup list of build items for cities. Another improvement I’d like to see is that when you hover population it will show number of cities, and number of all citizens.

I haven’t talked about shields, trade and food. Each square around a city produces shields which is used to produce units and city improvements and wonders. Food makes new citizens. Trade becomes gold, science and luxury. And there is much more to know about these three in various situations.

Some of the important up front game options you may set that I like are size of the map, and distance between cities. For the longest I liked large maps and cities 3 tiles a apart. But the your city list can become quit large and the management task can become overburdening. I now like cities to be 4 or even 5 tiles apart. This waste some of the map in unused tiles but it lightens the burden both the computer resources and the player. This brings another point on lower end computers fewer cities or smaller maps is better. Fewer players is better as well. I have experienced white outs of parts of the user interface and a computer AI taking forever to move 100 ships or planes or land units around. Sometimes the game interface even locks up. The answer is fewer players, smaller maps and more distance between cities. Another option I like is to be able to colonize single square islands. Though these may only be captured with a few unit types when attacking. There are options for varying the type of random terrain generated that I like to mess around with as well. That breaks up the monotony of playing on maps that look exactly the same all the time. Once you get the game going
go to the options, local client, overview, borders layer ‘on’. This is a nice option which shows the tile ownership in player colors. It helps you to locate enemies when they get down to only a few cities.

Also I’d like to see a stats panel that shows graphs for all kinds of information that you may add to the view. This will compare your civilization to the others over time. Similar to say Microsoft’s Age of Empires game. I think the game does log to a log file if you like. So a person could review a game stats if he made his own graphing app. Also free civ recently went to a Lua api for making game enhancements which might be good for mods such as this. I have not looked into it and I am not sure when I’d ever get such time to write a mod for it. This Lua api is used in other popular games such as World of Warcraft for mod writers.

You may at the beginning set up teams between you and other players or AI, these can’t be changed at all once set not even through diplomacy. For example you can pair yourself with a few novice AI and pit yourself and those AI against a Normal AI just for fun. Also if you want to see the full overview map click the vertical control on the left to detach it from the main window then drag it open until the whole map is revealed. Most of the time I have it this way and drag it around if needed.

Good luck and have fun.