Monday, November 27, 2017

Artificial Intelligence and Following Instructions

Artificial intelligence isn't true intelligence.  Computers do not yet have the ability to think; to learn.  A computer is only able to do what it is told.  If you're playing a game, the character in the game basically follows a flow chart to know what to do.  If you walk into the virtual room, the character you encounter will react in certain ways -- if you have already found the magic sword the guard may attack... or if you are a magician the guard may run afraid... or if you have joined a guild the guard may welcome you in and show you the attack plans.  The guard will only follow the instructions given.  The guard will never think of something on his own... or be in a bad mood and act a certain way...  or decide to take the treasure for himself.

As a programmer, you have to think of all of the possibilities and program for those choices.  We aren't [yet] making a cool video game where characters are interacting with each other, but we will be creating programs with logic problems.  Flowcharting helps, but we have to remember to be specific.  If you have ever used Siri on an iPhone or iPad, you're probably encountered this.

You may have also played with "bots" in "shooter games" (like Counter Strike or Team Fortress) where the bots get confused over simple situations.  Sometimes you'll find them running at full speed, but they are stuck in a corner or behind a box.  The programmer neglected to write a "what if" scenario for whatever got them stuck.  Computers (and "artificial thinkers") can only do what you tell them to do.

For example, there's an old joke about a man who discovers a Genie in a bottle.  For one of his wishes, the man says, "Genie -- make me a chocolate milkshake."  Poof -- the Genie turned him into a chocolate milkshake.

Here's an example [from a JAVA for Dummies book] illustrating this principle:

Just yesterday, I was chatting with my servant, RoboJeeves. (RoboJeeves is an upscale model in the RJ-3000 line of personal robotic life-forms.) Here’s how the discussion went:
Me: RoboJeeves, tell me the velocity of an object after it’s been falling for three seconds in a vacuum.
RoboJeeves:
All right, I will. “The velocity of an object after it’s been falling for three seconds in a vacuum.” There, I told it to you.
Me:
RoboJeeves, don’t give me that smart-alecky answer. I want a number. I want the actual velocity.
RoboJeeves:
Okay! “A number; the actual velocity.”
Me:
RJ, these cheap jokes are beneath your dignity. Can you or can’t you tell me the answer to my question?
RoboJeeves:
Yes.
Me:
“Yes,” what?
RoboJeeves:
Yes, I either can or can’t tell you the answer to your question.
Me:
Well, which is it? Can you?
RoboJeeves:
Yes, I can.
Me:
Then do it. Tell me the answer.
RoboJeeves:
The velocity is 153,984,792 miles per hour.
Me:
(After pausing to think . . .) RJ, I know you never make a mistake, but that number, 153,984,792, is much too high.
RoboJeeves:
Too high? That’s impossible. Things fall very quickly on the giant planet Mangorrrrkthongo. Now, if you wanted to know about objects falling on Earth, you should have said so in the first place.
Your Challenge: Write Exact Instructions for Making a Peanut Butter & Jelly Sandwich:

  1. Get a piece of paper and a writing implement ready.
  2. Create a list (set) of instructions for making a PB&J
  3. Label your instructions "PB&J Alpha"
  4. Exchange instructions with a partner and exchange feedback for possible problems.
  5. Create a new list (set) of instructions to fix any possible problems from before.
  6. Label your instructions "PB&J Beta"
  7. Exchange instructions with a new partner and exchange feedback.
  8. Create a new list (set) of instructions to fix any possible problems from before.
  9. Label your instructions "PB&J Beta 2"
  10. Watch the following video:


  11. Make adjustments to your previous instructions to eliminate potential issues.
  12. Label your instructions "PB&J 1.0"
Here's an interesting video from a game developer doing "AI":

Flow Charting: An Intro to Coding

The first example is lengthy, but the first 6+ minutes are the part I want you to focus on -- unless of course you want to learn C++ programming.  The professor does a great job of demonstrating a basic problem that we need to solve, lays it out in steps, and then applies to steps to a flow chart.





This is a flow chart of making decisions in your life:
This is a useful tool for figuring out what to do:

Here's a funny flow chart in action:  http://www.youtube.com/watch?v=k0xgjUhEG3U


Programming is about solving problems.  The entire purpose of writing a program is to solve a problem which, in general, consists of multiple steps:
  1. Understanding the problem.
  2. Breaking the problem into manageable pieces.
  3. Designing a solution.
  4. Considering alternatives to the solution and refining the solution.
  5. Implementing the solution.
  6. Testing the solution and fixing any problems.
After we understand a given problem, we can break the problem into manageable pieces and design a solution.  For example, if we wanted a program to figure out the least possible number of coins to give a customer as change, we might want to first subtract the amount owed from the amount paid, then figure out how many quarters would go into that, take the remainder and figure out how many dimes would go into that, and then move on to nickels and then pennies.  For more complex problems, making a flow chart can help to organize your thoughts and identify potential issues before you begin programming.

Below are some potential "problems" for you to solve using flow charts.

Flow Chart Practice: 
  1. A movie theater wants a program that will show admission price based on age.  They want to charge children (under 12) and seniors (65 and older) $5.25.  Everybody else will pay $9.25.  They want to ask "How old are you?", let the person put in their age (in years), tell them the price, then tell them to "Enjoy the show!".
  2. A daycare provider wants to give gumballs to their kids, but they want a program that will ask the worker, "How many gumballs?" and then "How many kids?".  Then it should divide the gumballs per kid (gumballs/kids).  Finally it should say, "Each kid gets X gumballs."
  3. You decide to write an app for a SmartPhone.  You want to do a Magic 8 Ball app where you ask a question and it gives you a "Yes" or "No" answer.
  4. You want to write a program that will pick a random number between 1 and 1000.  Ask the player to guess a number and tell them if they are too high, too low, or if they get the number correct.  The program should keep running until they guess the number correctly.

Tuesday, November 7, 2017

Getting Started with TinkerCad


Download the Instruction Guide: (HERE)


Finally, click on: Enter Invitation Code and enter Z2HI9DF


Thursday, November 2, 2017

Bryce: Landscape - Lake or Pond

Today we will use the Bryce Terrain editor to create a lake scene:
  • Insert a Terrain
  • Paint the entire Terrain with a dark gray (very low elevation)
  • Use the soft-edged, smaller brush on the lowest (black) elevation to paint a lake shape
  • Exit the Terrain editor (check mark) to view your new Terrain
  • Click EDIT and drag the Y Axis (Resize) down to flatten your terrain
  • Add a Water Plain and use the  Y Axis (Reposition) to move the water to the appropriate level (so that it shows inside your lake cut-out but doesn't cover the entire Terrain
  • Add finishing touches (additional Terrains for background, adjust textures, change your sky, etc.)
When finished:
  • Save As (as a .BR7 file) to your Thawspace
  • Render your picture
  • When finished Rendering, "Save Image As" and  select JPEG
  • Upload your JPEG to your portfolio blog