Thursday, October 5, 2017

Update on the "Four in a Row" app progress

10/5/17

I had put the Connect Four clone project on hold while I was in school. I finished the first part of my dissertation, so now I have a couple of week break before returning to school, so I worked on the game project a bit more. I added some sounds, and tweeked the code to make it simpler to play.

The goal is for anyone to be able to pick up and play the game without any coaching, so simplicity is the order of the day. I made it easy to click any region on the screen and drop a token into place. Also I added some instructions to carry out if the program "senses" that there are four of the same colored tokens in a row. It was pretty easy, until I realized that the diagonal four-in-a-row routines would require a different approach then horizontal and vertical.

But, I got that problem solved with some elbow grease. If you know a little about programming and algorithm design, I used a "Brute Force" algorithm to check all possible cases for diagonal four-in-a-row success.  Basically, it asks, "Are there four in a row for Case 1?  No, Ok, how about Case 2..." and so on.  If you've never heard of brute force algorithms, it's basically what it sounds like. It checks each possible outcome, one at a time until it reaches all possible outcomes.

It's kind of a pain in the neck, but it works.

I'm 100% certain that a better programmer would have created an easier way, but I suppose that the good news is that part is done. Yay!


Saturday, May 6, 2017

My Connect Four Clone Project


Project
A Connect Four clone (personal challenge)

Software Used
Clickteam Multimedia Fusion Developer
www.clickteam.com

Cool 3D
www.ulead.com

Screen Recorder
Blueberry Flashback Express (Free Edition)
www.blueberry.com

I have this vision of developing and marketing cross-platform games under my own label. They would be non-violent content and ministry tools for youth, and some retro-style simple games like the kind I enjoy.  I haven't had as much time to finish most of the projects because of all the fires I got going at the moment, but I sometimes sit down and try to build on an idea.

Recently I challenged myself to a personal project. I wanted to see if I could throw together a demo of Connect Four in one day.  I'll be transparent and say right away that I did not succeed, but that's okay.  The idea came up originally when I was in a statistics class, and thought about a Connect Four game board, and how many possible combinations there were to win. It's a nerd thing.

I drafted a quick mockup of a Four in a Row game board like the one in the video, which is not the official size of Connect Four, but a smaller version, and determined 68 ways to win, counting both red and black. Little disclaimer: I don't know if that's correct, but it's what I came up with.

I hadn't had time to play with the idea until my most recent class ended and I had a little free time, and decided to take up the challenge. I did not build the game demo in one day, but I built some rudimentary art and basic animations in a day. They are not up to commercial quality, but the point was just to see if I could do it. That was two days ago. 

Yesterday, I built the basic instructions into the play pieces. Where I got stuck is how to bring in a piece and drop it into the slot of your choosing. At first the method was to apply a drag-and-drop routine to the entity (the "checker" piece) and line it up with the slot and have it collide either with the bottom, or another piece.

The brick wall I kept hitting was that if the player didn't line the piece up just perfectly, then it would fall down haphazardly and might be barely visible. No problem, I thought, with my usual optimism. I'll just build barriers between each column, and make them real skinny and invisible to the player. I'd use instructions in the code that if the piece collides with the barrier, it would bounce off and keep it in line with the grid holes.

That didn't work, because the code took the collision to mean that the piece should just stop in place, and get stuck halfway down. Sometimes when programming a game with gravity and "platform" rules, you run into the same limitations you would in the physical world.

I settled on a different approach, which I fixed today. I have five buttons to pick from, and they are set up to spawn a piece which will fall perfectly in line. Not the most elegant solution, but it works for now. This is day three of my one-day challenge, lol  :-)

Tuesday, April 25, 2017

Should Taxpayers Continue to Give $2 Billion a Year to Fund Online Access in Public Schools?

By Dax Bradley
A University of Chicago study examined the impact of an E-Rate program and found that the number of poor schools going online had increased dramatically.  However, the study found no evidence that the program had any effect on students’ performance on the Stanford Achievement Test.  Should this be sufficient evidence to discontinue this program, which costs U.S. taxpayers roughly $2 billion per year?


The annual spending per student has seen a decline in recent years.  Balanced-budget rules have forced spending cuts to education in most states ("School Spending per Student Drops for Third Straight Year," 2016), which puts educators in the difficult position of determining how to spend the funds that are available.  The E-Rate program, provided through the Telecommunications Act of 1996, earmarked $2.25 billion to provide schools funds for upgrading their access to Internet resources (Reynolds, 2012, p. 325).

The problems unearthed by the press and by a Federal investigation highlight some very serious issues.  Among the discoveries outlined by House Representative James Greenwood (House Hearing: E-Rate Program: Waste, Fraud, and Abuse, 2004):
·         In Puerto Rico $28 million worth of improperly stored and stockpiled equipment
·         $58 million network equipment sitting unused
·         NEC allegedly rigged millions of US dollars in bids in several states
·         $101 million for setting up high-speed Internet yielded two computers per school, using dialup
·         $31 million paid for high-speed Internet access which went unused
·         Consultants paid high fees without doing any work, leaving schools with no equipment or with technology they had no idea how to implement
·         Government warehouses contained many pallets loaded with shrink-wrapped E-Rate computers paid for but never used

It should be noted that the Congressional Hearing contains over 100 pages, and the summary above depicts a small portion of what was discovered.  The E-Rate program was designed with the goal of providing students with improved technology and Internet access, which would be a helpful tool in providing an education, particularly today where students must be prepared to enter the market already saturated with computer technology.  However, if a tool is not being used, or is being mishandled irresponsibly, then it represents a colossal waste.  The issue is not with the program itself, but an apparent lack of oversight.

The funds were controlled by a collection of telecommunication company representatives which calls itself the Universal Service Administrative Company.  The Federal funds earmarked for education should be distributed to the state, not one company handling bids for the whole country.  With better oversight, the E-Rate funds would be used to improve low-income schools rather than “over-building” existing networks in higher-funded schools in areas such as Washington (Eggerton, 2017).

The fault is not strictly with USAC, however.  Funds were distributed according to requests filed by the school districts, which entailed some restrictions.  For example, schools were instructed that only one service provider could be used to build the network.  The Russell-Tyler-Ruthton School District was ordered to repay over $42,000 when it was discovered that multiple contracts were awarded to different providers (Isaackson,2017).  Additional guidance is needed for districts to understand precisely what the restrictions are, and how to properly utilize the federal dollars allotted to them.  Confusion, rather than greed could be just as likely the cause for some situations.  For example, Idaho schools stand to lose $2 million of E-Rate funds because they negotiated telecommunication contracts independent of USAC’s guidelines, voiding their agreement (Richert, 2016).

All is not lost, however.  The program should not be eliminated, but should have more accountability across the board.  It is insufficient to blame the telecoms for charging and not fulfilling the contracts, or to crucify school district heads who do not follow up on equipment that might have been shipped and never installed.  There should be greater attention to detail from conception to installation.  There has been improvement since the 2004 hearings.  According to the State of States Report published by the Education Superhighway, 77 percent of districts have access to high-speed internet, more than double the amount which achieved the target set by the FCC in 2013 (Schaffhauser,2016).


Does shuffling more money into schools automatically guarantee gains in performance?  While there has never been conclusive empirical evidence that directly connects spending to school performance (Turner, 2016), the better question should be about how the funds are spent.  Proponents of technology integration argue that students should be given the latest tools to learn from (King, 2012).  The point of emphasis here is that as long as technology integration is exactly that, a tool, and not the focus of the education, then it can be a highly effective resource and deserves proper funding.

Reference:

Tuesday, March 7, 2017

Wheel of Scripture

Several years ago, I volunteered in Kids Ministry. We had to come up with original ways to keep them engaged and not too bored. Bored kids will eat you alive, even in church, lol! 

So anyway, I coded a basic "Wheel of Fortune" clone called "Wheel of Scripture". It helped them to memorize verses that had to do with our lesson. We had it up on the projector and made a kind of game show out of it.
Later my laptop crashed and I lost most of my projects. I found an old CD-Rom recently with the game on there and thought I'd share a screenshot of my cheesy game.



At the moment, there isn't much to it. The board is blank, save for the letter spaces. The game was pretty straight-forward: The players would simply guess a letter, and the operator, usually someone in the Media booth, would hit the key for that letter. If the letter was a correct guess, the game plays a *ding* sound and the letter appears in one of the blank spaces. If the guess is incorrect, it buzzes. The letter is crossed off at the bottom automatically, and the loop continues. 

There is no animation or music when the puzzle is solved. I may go back and finish the game at some point, and add that as a feature. Other ideas include:

-Adding scores
-Adding an actual wheel to spin, and include "Lose a Turn", "Vowel", "Spin Again" etc
-Adding more levels
-Adding the ability to "speak" the letter (language processing), so the game could work as a mobile game employing the microphone

This is one of those fun projects that kind of got abandoned. Game developers all have a huge graveyard of these, like little sketchbooks with incomplete drawings. Hopefully I'll be able to develop it into a fully playable game. Time will tell.

Thursday, February 16, 2017

TREK-NOLOGY: Tech Devices Predicted by Star Trek

For a generation of nerds (and I use that term affectionately, for they are my people) growing up in the late 60’s, 70’s, and 80’s, Star Trek was essential viewing.  Every week, Gene Roddenberry’s most famous creation brought us a vision of a hopeful future: a progressive, highly-evolved environment, where mankind has grown up and defeated racism, broken through social barriers, and explored the universe in the name of peace.  On the surface, the show was a sci-fi Space Western. However, it has always been about social issues and bold statements, cleverly hiding behind a veil of popcorn entertainment. While the complex social issues were lost on many of us young viewers, the cool gadgetry was not. Everyone in my neighborhood held toy pistols backward, pretending it was a classic Starfleet phaser. And who didn’t dream about using a Transporter to get somewhere in an instant?  It’s easy to see that modern examples of technology can trace their lineage back to Star Trek. One glance around the world of science and technology, and it’s easy to spot Star Trek’s unquestionable influence.  Here are ten modern technological marvels that we sometimes take for granted, but were predicted decades ago in Star Trek.

iPad    
When Steve Jobs took to the stage in 2007 and unveiled the iPad, he cemented Apple’s grip on technology must-have items.  There was a certain “cool factor” in using the iPad, which, like the iPhone that preceded it, had a slick interface, groovy apps, and flexibility as a work tool, toy, and multimedia device.  It was for many the neatest new item. Thing is, it wasn’t a new concept, with early examples in the original series (TOS in fan-speak), and especially later in The Next Generation, bearing a strong resemblance 20 years prior to Apple’s entry. 


Universal Translator
How do you travel across the cosmos and understand races from other worlds? Star Trek solved the problem of speaking to alien races across the universe by the Universal Translator trope.  Everyone carries a device capable of understanding an alien’s speech, and translating it for humans in real-time (I’m still curious as to why their lips don’t move out of sync like on Kung Fu Theater, but I digress).  The technology seemed light-years ahead in 1966, but is now a reality.  Both Google and Waverly Labs are working hard to disrupt the market first with real-time translation devices (Templeton, 2016), capable of allowing the wearer to communicate with native speakers in French and other languages. No word on how long we’ll have to wait until travelers can speak to a Klingon.

Replicator
This one might be a small stretch, but it is worth mentioning.  We may be a few years away from ordering earl grey tea, hot, but the ability to build small items with 3D printing technology is becoming more common, and cheaper than ever.  For a little as $267, budding entrepreneurs and generally bored artists can fabricate small items, normally out of high-impact polystyrene or other thermoplastic media (Hoffman, 2017).


Tricorder
 In the future, according to Star Trek, humans who were sick or injured were just a few minutes away from the best in high-tech treatment.  Starfleet physicians like Dr. McCoy and Dr. Crusher would quickly scan a patient and receive a diagnosis as well as an X-ray scan with a medical tricorder.  We may not have to wait for the 23rd century for a similar device, thanks to Scanadu’s Scout health sensor.  While it is not nearly as advanced as something you might see on Star Trek, it does claim to provide accurate data on heart rate, core body temperature, blood pressure, and respiratory rate in a painless, efficient manner (Williams,2015).

Natural Language Processing
One optimistic feature seen since the inception of Star Trek is the ability to speak to a computer and retrieve information.  While efforts to achieve this have been underway since the early days of computer science, the greatest leap has occurred in the last few years.  Advances in language processing algorithms have made it easier for computers to grasp the very difficult lexical variations of how humans express themselves. Amazon Echo and Google’s Pixel are two competing examples of NLP research tools that employ keywords for activation (Bhartiya, 2017).  Instead of saying “Computer, dim the lights”, users say “Echo, dim the lights”.

Planet Scanners
A trope virtually invented by Star Trek is the ship-scans-the-planet trope, in which our intrepid crew scans for life signs, planetary conditions, or other details to move the story along.  The technology is no longer the stuff of science fiction, however.  Since the late 1980’s researchers have planned to use earth-based scanners to observe the NIR spectra of light reflected from asteroids to determine their composition, surface minerology, and lithology, and claim that the technology can be used to make the same observations of other planetary bodies (Burns, 1989).

Video Conferencing
As difficult as it is to imagine now, video conferencing has not been ubiquitous for long.  Video conferencing has been around since at least 1982 ("Video ConferencingTimeline," 2015), when Compression Labs commanded $1,000 per hour for the service.  The technology, while extremely pricey, was not a new idea, appearing on Star Trek from day one.

Bluetooth
In early TOS episodes, it was not unusual to see a rogue robotic entity come along and steal data from computers, change settings, or sabotage systems through a wireless connection.  While it must have seemed like sorcery in 1966, and an easy plot device, this could be construed as an early depiction of Bluetooth technology, decades before it became standard fare with wireless headphone enthusiasts.  In fact, Uhura’s earpiece is another prime example of wireless audio, rendered via Bluetooth-style technology. 

Hypospray
According to Star Trek’s optimistic future, painful needles will be a thing of the past.  If a character needed to be inoculated after a brush with an alien disease, a quick shot of Bones’s hypospray would do the trick.  No longer the stuff of science fiction, hypospray technology, or painless injection without breaking the skin, has actually been available since 2012 (Humphries, 2012).

Augmented Vision Glasses
We take our vision for granted. Patients who are legally blind struggle with the most basic tasks.  In the future, perhaps that will no longer be the case.  In Star Trek: The Next Generation, Geordi La Forge, a blind character, saved the day many times, partly due to his extraordinary vision thanks to his hi-tech visor.  His character showed that even people who were disabled in some way can be an integral part of the crew, thanks to innovative tools.  The concept has inspired developers who have introduced eSight, a visor that corrects genetically malformed retinas in patients with no central vision (Fox News, 2015).  The tool is helping people who have been blind since birth to see for the first time.  Similarly, Oxford Scientists created Smart Specs, a visor that captures real-time imagery and heightens the contrast, assisting legally blind users in everyday life (Matchar,2015). Plus, they just look insanely cool.
                                       
Conclusion
For many, the show impacted the career choices of many an astronaut, pilot, or scientist. I myself have been fortunate enough to study engineering and computer science, inspired in no small part by Trek.  The show has impacted our culture in profound ways, perhaps more so than any science fiction franchise.  For most of us die-hard fans, the optimism of the series lives on.  Perhaps in some small way, our modern hi-tech tools can help usher in an era of peace depicted in classic Trek, and take us where no gadgets have gone before.

About the author:

Dax Bradley is an author with non-fiction books on movies and technology, and can be found at Amazon.com and Indyplanet.com. Visit his Facebook page on B-movies and say hi!

Wednesday, February 15, 2017

C++ Tips: Two Approaches to Find an Average of Numbers

by Dax Bradley

On occasion, I will drop notes on programming some basic code here and there.  In this entry, we examine how to use C++ to prompt the user to enter a set of positive integers and average them up.  The code is pretty straightforward, when you have a fixed number of integers pre-determined.  For example, you might know you have 20 numbers to add up and average out. 

However, it would be more useful to be able to specify how many numbers you need to add up and discover the average for.  Here are two methods.  The first is not using Dynamic Memory Allocation, and the 2nd one does use it.  I'll explain the difference.

Dynamic memory allocation is crucial if there is a chance you could enter a null value, such as a negative number by mistake, or possibly that you use so much memory with your data that you crash the program.  The second example below will address that, with a few comments thrown in for good measure (Denoted by the /*...*/ symbols).

Find the Average of n Integers 
(without Dynamic Memory Allocation)

#include <iostream>
using namespace std;
int main()
{
   int n, count;
   float sum, avg;
   sum = 0;
   cout << "How many numbers?  ";
   cin >> n;
   int a;
   for (count=1; count<=n; count++) {
        cout << "Enter Number:  ";
        cin >> a;
        sum = sum + a;
   }
   cout << "The sum is " << sum << endl;
   avg = sum / n;
   cout << "The average is  " << avg << endl;
   return 0;
 }



Online compiler: C Shell

And finally, here is another version with a little more code in it, and some comments that highlight the need for pointers and other tidbits...

Find the Average of n Integers 
(with Dynamic Memory Allocation)
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
int main ()
{

int sum=0, avg, i;
int how_many;
int *p;
printf ("Enter number of values you want to input: ");

scanf ("%d",&how_many);
/* This next block uses malloc dynamic memory pointer to make sure the pointer value is not null*/
p = (int *)malloc(how_many * 4);
if (p == NULL)   
      
{
printf(" Out of memory!\n");
printf ("Press any key to close.");
exit(0);
}

for (i=0;i<how_many;i++)

     /*printf returns the number of characters written or a negative value if an error occurs*/

printf ("Enter value of %dth integer: ",i+1);

     /*scanf returns data items successfully assigned a value, like the opposite of printf*/

scanf ("%d",&p[i]);

     /* %d is a format specifier that stands for Signed Decimal integers */

sum = (sum + p[i]);
}

     avg = (sum / how_many);
     printf ("Sum = %d\n\n",sum);
     printf ("Average = %d\n\n",avg);
     free (p);

/* where malloc allocates memory, free needs to be at the end to free up the memory */

     printf ("press any key to close.");

}

Did I get anything wrong? See something you'd do differently? Drop me a note, leave a comment in the comment section, and let me know. Let's do some coding!

Thursday, January 19, 2017

Bayes' Theorem in Technology

by Dax Bradley

The Bayesian model for statistical analysis is highly popular in settings that require predictive strength to succeed.  Industries are numerous, from academic areas such as astronomy, to industrial applications to include telecommunications and pharmaceutical companies (May, 2014).  In the telecom sector, the method has been employed for some time.  Akamai Technologies in Cambridge uses Bayesian methods to better understand network latencies, internet traffic, and to identify clusters of users (Galkowski, 2014).

The computational complexity of the Bayesian model would suggest that primarily technology-based efforts would embrace this form of analysis (Edelsbrunner, 2014).  Google’s robotic cars, and Microsoft’s own early spam filters stood on the strength of Bayes theorem (McGrayne, 2011).  Google’s strength lies not only in the high level of technical prowess, which is obvious, but also by a factor not apparent: the large amount of data to draw from.

The Bayes approach relies heavily on what is known already to make a successful prediction on what is likely to happen (Russell & Norvig, 2010).  Google translate uses Bayes Theorem in the translation services, by drawing on a large pool of translation data already completed by humans (King, 2015).  So, rather than undergoing large amounts of translation algorithms, the software instead draws from experience, samples the data, and predicts the highest certainty.  The method has been applied by Google not only in translation and mapping, but also in controlling driverless cars. 

The tech giant claims that their autonomous vehicles have logged as many as 140,000 miles along the Pacific Coastal highway, all without incident (Matyszczyk, 2011).

It is easy to see how Bayesian methods are highly prized in the technology sector.  The approach is also critical in health technology assessment.  While no formal definition of Bayesian tools in healthcare technology has been established, proponents believe that it provides for conclusions in a form most appropriate for decisions specific to patients and decisions affecting policy.  That is based upon the following conclusions (Spiegelhalter, Myles, & Jones, 1999, para. 4):
  • Data are interpreted from a study in the light of external evidence and judgement
  • The form in which conclusions are drawn naturally contributes to decisions
  • Prior plausibility of hypotheses is taken into account
  • Skepticism about large treatment effects are formally expressed and cautiously interpreted
  • Use of Bayesian methods in healthcare technology assessment are to be pursued carefully; guidelines, software, and critically evaluated case studies are needed

References

Edelsbrunner, P. (2014, November 17). Bayesian statistics: What is it and why do we need it? [Blog post]. Retrieved from JEPS Bulletin: http://blog.efpsa.org/2014/11/17/bayesian-statistics-what-is-it-and-why-do-we-need-it-2/

Galkowski, J. (2014, October 17). How companies use Bayesian methods [Online forum comment]. Retrieved from http://andrewgelman.com/2014/10/17/companies-use-bayesian-methods/

King, M. (2015, July 20). Bayes’ theorem and what we do [Blog post]. Retrieved from https://www.whitehatsec.com/blog/bayes-theorem-and-what-we-do/

Matyszczyk, C. (2011, March 4). Google’s self-driving car goes all Dale Earnhardt. Cnet. Retrieved from https://www.cnet.com/news/googles-self-driving-car-goes-all-dale-earnhardt/

May, J. (2014, October 17). How do companies use Bayesian methods? [Online forum comment]. Retrieved from http://andrewgelman.com/2014/10/17/companies-use-bayesian-methods/

McGrayne, S. (2011). Why Bayes rules: The history of a formula that drives modern life. Retrieved January 19, 2017, from https://www.scientificamerican.com/article/why-bayes-rules/

Russell, S., & Norvig, P. (2010). Artificial Intelligence: A modern approach (3rd ed.). Boston, MA: Pearson.

Spiegelhalter, D., Myles, J., & Jones, D. (1999, August 21). An introduction to bayesian methods in health technology assessment. The BMJ, 319(1), 7208. Retrieved from https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1116393/

Bayesian Model Challenges

By Dax Bradley

Possible disadvantages to Bayesian learning methods can be significant.  For one thing, the information gleaned from the effort could be theoretically infeasible.  The act of specifying a prior datum is challenging.  Generally, it is necessary to specify a real number for every setting in the real-world parameters (Langford, 2005).  One potential solution is to acquire languages that allow more compact specification of priors.  The task of learning a new language may be prohibitive.  Another solution is to simply lie.  In other words, create a specification that is not accurate.  As deceitful as this sounds, it is not meant that way; in fact, it has been shown to be effective (Langford, 2005).

Another known disadvantage to Bayesian modeling lies in the analysis of causality.  There is a great challenge in analyzing the conditional probability links between various nodes.  Even with physical causal models and known variables, the computational burden is great, since the task equates to inverting a finite-element model (Sankararaman, 2015).  This is especially daunting if the analysis revolves around an acyclic model.  The assumption of independence among variables implies no latent cofounding variable in Bayesian modeling; however, often there are acyclic latent cofounding variables which can force the model to be seriously biased (Shimizu & Bollen, 2014).

Prior choice problems present challenges in the Bayesian methodology.  Another scenario in which researchers using the model is in astronomy.  Scientists have attempted to predict the number of extra-solar planets in this way.  Improper priors are generally disallowed here, so other strategies have been suggested, such as Intrinsic Bayes, Fractional Bayes, and Expected posterior factors (Jeffreys, 2006, p. 11).  The potential defeat of using such methods is that data may be inadvertently duplicated, so allowances must be made.

Many forms of industry employ the Bayesian model of statistical probability.  In drug development, the approach is widely regarded for its accuracy and natural interpretation.  It does, however, demand no small degree of planning.  The flexibility of this method creates an environment prone to potential computational errors.  Without proper planning, the various outcomes of intense computation may be unreliable, prompting some teams to opt instead for a frequentist model (Gupta, 2012).


References

Gupta, S. (2012, June). Use of Bayesian statistics in drug development: Advantages and challenges. International Journal of Applied & Basic Medical Research, 2(1), 3-6. http://dx.doi.org/Use of Bayesian statistics in drug development: Advantages and challenges

Jeffreys, W. (2006). Current challenges in Bayesian model choice: Comments [Lecture notes]. Retrieved from Department of Statistics University of Vermont: http://astrostatistics.psu.edu/scma4/Jefferys.pdf

Langford, J. (2005, April 23). Advantages and disadvantages to Bayesian learning [Discussion group comment]. Retrieved from http://hunch.net/?p=65
Sankararaman, S. (2015). What are the limitations of Bayesian Networks? Retrieved January 18, 2017, from https://www.quora.com/What-are-the-limitations-of-Bayesian-Networks

Shimizu, S., & Bollen, K. (2014, August). Bayesian Estimation of Causal Direction in Acyclic Structural Equation models with individual-specific confounder variables and non-Gaussian distributions. Journal of Machine Learning Research, 15(1), 2629-2652. Retrieved from http://jmlr.org/papers/volume15/shimizu14a/shimizu14a.pdf

Bayesian Theorem - Advantages

by Dax Bradley

Creating complex models from complex data can prove to be an arduous task, even in a system of computers.  Using even existing data, a computing system must perform many calculations, often at the expense of vast resources.  It can be difficult to express a problem mathematically, particularly using highly details models available through direct or indirect complex mechanisms.  It would be no small challenge for a computing tool to interpolate shapes and behavior from raw video footage, providing a prohibitively large amount of variability and noise (Hertzmann, 2004, p. 5).

Bayesian reasoning provides a methodology for many data-modeling problems.  By searching for logic in uncertainty, Bayesian methods provide a unified approach that on the surface is like human logic.  Bayesian logic provides three main areas of interest:

1. Principled modeling of uncertainty
2. General purpose models for unstructured data
3. Effective algorithms for data fitting and analysis under uncertainty


Courtesy: CBS

There are advantages to Bayes learning method.  One area is in interpolation.  When faced with a challenge in engineering, there is always a balancing act to determine whether the time and resources a human would consume vs. a computing system.  With the formulation of an engineering system, a world model must be built, along with a “controller” for that environment.  Bayesian methods interpolate this to the extreme because the Bayesian prior can be a delta function on one model of the world (Barak, 2005).

The Bayesian method also obeys the likelihood principle.  In a case where two proportional likelihood functions come from two distinct samples for , then all inferences about both groups will be similar (Jones & Huddleson, 2015).  It also provides interpretable answers in a convenient setting for a wide range of models.  This includes hierarchical models as well as missing-data problems.  Less training data is also required; in fact, lower training data is preferred with the Bayes naïve approach (Chen,  2011, para. 3).  A naïve Bayes classifier will converge more efficiently than discriminative models such as logistic regression.


References

Barak, B. (2005). Advantages and disadvantages of Bayesian learning. Retrieved January 17, 2017, from http://hunch.net/?p=65

Chen, E. ( 2011, April 27). Choosing a machine learning classifier [Blog post]. Retrieved from http://blog.echen.me/2011/04/27/choosing-a-machine-learning-classifier

Hertzmann, A. (2004). Introduction to Bayesian learning [Lecture notes]. Retrieved from https://www.dgp.toronto.edu/~hertzman/ibl2004/notes.pdf

Jones, A., & Huddleson, E. (2015). Bayesian analysis: Advantages and disadvantages. Retrieved January 17, 2017, from https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_introbayes_sect006.htm

Tuesday, January 10, 2017

Bots for Gaming and Ethical Questions

by Dax Bradley
For the most part, the discussion of bots in gaming revolves around those that fall within uses of morally and legally acceptable standards. Bots and macros that are widely regarded as legal appear to be distinguished by the factor of a human operator being present. However, the question persists as to what happens if an intrepid programmer creates a bot capable of playing an online game. This topic is a hot-button issue in the gaming community, and partly rests about intent. A player may program a bot to carry out commands in sequence for the game’s avatar. For example, suppose a player in a game can score a large amount of points by attacking an enemy with a hack-slash-slash-jump back sequence, but the keyboard commands are complex and difficult to execute. A bot could be created to carry out the keyboard combination automatically if the user simply presses ALT-1.
One argument for this scenario is that the bot is merely an extension of the player. The human must be present to initiate the command, and is thus not fully relying on an AI tool to play for him. However, users can (and already have) created routines that fully control a character’s actions, including searching an environment, taking up resources and “killing off” other players to win the game. This brings to the front a concern in the gaming community. A player in one forum expresses it in this way (User Aceboy1993, 2015, June 23):

This question has been on my mind for a while...mainly because I see bots for all sorts of games like WoW and others. My question is; how do the bots know what is appearing on the screen? I don't play WoW so my example may be wrong but if for example there is a monster, how does the bot know where that monster is on the screen and how does it know how to interact with it?Can you apply this to any game or is it specific for each game? I'm sorry if the question isn't clear...and I'm not asking how to make a bot, more asking how they detect things on the screen as its quite fascinating to me! Thanks in advance :)
The question also points out an interesting angle: the applications are available that play the games such as the above-mentioned World of Warcraft, but how? How do they perceive the environment well enough to interact? One answer is the software Netshark, which reads encrypted net code and “announces” loot to the bot, triggering whatever actions are wanted to acquire the loot (Nilly, 2013). Besides gobbling up the loot and other rewards, bots have created a dilemma for online gamers by clogging up networks with drones, creating trouble for humans who pay monthly fees for the gaming service.
Game developer Blizzard responded to bots on their World of Warcraft server by aggressively flagging and banning suspected bots, resulting in the removal of over 100,000 accounts (Grayson, 2015). Bot makers have responded by coming up with tools to avoid being flagged, ranging from highly complex algorithms to simple techniques. One such project, RsBot, manages to copy the contents of the game client to its own memory, check the state locally, and make decisions there without risk of detection (Kaslai, 2015).
Another reason bot makers draw the ire of game makers is in how they profit off of a game they had no hand in developing. Developer Josh Phillips of Kapersky Lab, claims to have sold 100,000 copies of his creation, which gives users invulnerability in online games (David, 2012). The industry has even taken a bite out of online gambling. Ray Bornert developed an AI program capable of counting cards on an online Poker site, allowing users to play Poker and Blackjack with the precision of a computer (Kushner, 2005). Gambling sites have caught on to the nonhuman players, however, and responded by including a chat feature, allowing players to chat in a sidebar. The feature has been used successfully to flush out bots incapable of human conversation.

References
Aceboy1993. (2015, June 23). Bots in WoW. [Discussion forum]. Retrieved January 4, 2017 from https://github.com/PokemonGoF/PokemonGo-Bot/issues/2578
David, B. (2012). Hacking online games: Josh Phillips and Michael Donnelly at Defcon 19. Retrieved January 4, 2017 from http://privacy-pc.com/news/hacking-online-games-josh-phillips-and-michael-donnelly.html
Grayson, N. (2015). World of Warcraft bot maker calls it quits after massive ban wave. Retrieved January 4, 2017 from http://kotaku.com/world-of-warcraft-bot-maker-calls-it-quits-after-massiv-1704809117
Kaslai. (2015). How do gamebots perceive the game world & other entities? [Discussion forum]. Retrieved January 4, 2017 from http://gamedev.stackexchange.com/questions/102849/how-do-game-bots-perceive-the-game-world-other-entities/102853
Kushner, D. (2005, September 1). On the internet, nobody knows you are a bot. Wired.
Nilly. (2015). How to read packet data using Wireshark? [Discussion forum]. Retrieved January 4, 2017 from http://www.mpgh.net/forum/showthread.php?t=700530

Bots and AI

The legality of using bots in programming is a grey area presently. While it is open to some legal interpretation, it is generally accepted that bots used to save time on a task that is 100% in control of a human is perfectly reasonable. Used as an advanced macro, a bot can make a complex task more efficient, saving time. The most basic example is a simple mouse and keyboard recorder application. Essentially, the user would load the application, and then allow it to record whatever actions are needed to achieve the desired result. Ideally, the goal is to begin at the home screen, record the action, and return to the same screen in order to make the sequence loopable.
The ideal bot recorder includes an editor to facilitate custom scripts (Zhang, 2016). One such application is Auto Hotkey, and is unique among other script programs as it requires some coding knowledge. The tradeoff is that besides being a simple recorder, it is customizable. Users have shared scripts to perform such tasks as instantly turning off a PC monitor, changing the function of the accent key above the TAB to a backspace, or even automatically clean up an email account on a daily basis (Glenn, 2013). Bots and other recorders are highly useful in making mundane tasks more efficient. There are certain pitfalls to avoid when using macro recorders, however.
A dedicated PC is highly recommended for customized scripts. If any settings are different, such as window size or resolution, the results will likely be undesirable (McCreath, 2016). Open source tools such as Slash allow users to write custom bots capable of performing an almost limitless number of mundane tasks, such as following a GPS tracking web site and instructing the bot to report back coordinates to the user at regular intervals (Haughley, 2015). Bots of this variety are examples of basic artificial intelligence programs designed to mimic human responses, and are widely used by troubleshooting sites and other businesses.
Bots that are legal are also built into established services, as an optional feature. Customizable news and notifications are available that can report content as soon as it becomes available via products like Forbes Bot, and Tech Crunch Bot (Bridgewater, 2016, November 22). Chat bots assist travel companies to help consumers narrow down their travel needs in an automated process, eliminating the need to pore through thousands of options. Similarly, news agencies use bots to help users consolidate their consumption, citing how readers don’t like to load multiple apps. Readers on average have only one or two news apps installed on their devices (Upbin, 2016).

References
Bridgewater, A. (2016, November 22). Come fly with AI, IBM cloud builds ‘chatbot’ virtual travel agent. Forbes. Retrieved January 4, 2017 from http://www.forbes.com/sites/adrianbridgwater/2016/11/22/come-fly-with-ai-ibm-cloud-builds-chatbot-virtual-travel-agent/#5ceb7d671f39+
Glenn, W. (2013). Show us your best Autohotkey script. Retrieved January 4, 2017 from http://lifehacker.com/show-us-your-best-autohotkey-script-507227185
Haughley, M. (2015). A beginner’s guide to your first bot. Retrieved January 4, 2017 from https://slackhq.com/a-beginner-s-guide-to-your-first-bot-97e5b0b7843d#.nvclmr6pb
McCreath, D. (2016). Your first custom slash command for Slack. Retrieved January 4, 2017 from https://github.com/mccreath/isitup-for-slack/blob/master/docs/TUTORIAL.md
Upbin, B. (2016). Introducing the Forbes newsbot on Telegram. Retrieved January 4, 2017 from http://www.forbes.com/sites/bruceupbin/2016/02/23/introducing-the-forbes-newsbot-on-telegram/#64b8ee03117c
Zhang, G. (2016). 8 free macro recorder that automate your traditional mouse and keyboard. Prohavit. Retrieved January 4, 2017 from https://www.prohavit.com/blog/8-free-macro-recorder-automate-traditional-mouse-keyboard/

Bots!

The advancement of artificial intelligence has fostered many tools designed to both mimic human behavior and make mundane tasks easier. One area which has seen an explosion of innovation in online interaction is the development of “bots”. Put simply, bots are applications designed to respond within another program to automatically achieve some result. They come in a variety of styles. There are telegram bots, game bots, and telegram bots, to name a few. Each bot performs unique functions. For example, telegram bots autonomously answer inline queries in HTML5-based games (Martin, 2016, October 17).

Using the software available through a company called The Botfather, users are able to automatically follow a game’s lifecycle through the following process:
1.The user requests a game through the /play prompt
2.A sendgame function is remotely sent in response by the API setting the buttons
3.The user taps the play solo button, and the game bot responds by sending the game’s URL and sets parameters
4.When the player scores in the game a setScore function is established in the cache

The tool in the above example allows players to remotely handle many games and gather resources, points, and other rewards. The performance of bots is based on a machine-state flow process. Bots are designed to “read” the screen (pixels, text, packets or memory) to discover the state, and then respond per the programming (Mai, 2009). This is where the key distinction between bots and macros lies. A macro has been defined on Tech Target in terms of programming as (Griffen & Lowery, 2015):

“…in Microsoft Word and other programs, a macro is a saved sequence of commands or keyboard strokes that can be stored and then recalled with a single command or keyboard stroke.”

In other words, a macro performs when it is instructed to do so by a human. It is merely a shortcut command designed as a time-saver. A bot takes the concept to the next step; performing autonomously. In games and other online applications, it uses artificial intelligence to read a state and respond. Still, users tend to use the terms interchangeably. In C++ programming, developers have devised a method for automating a basic process such as a send key.

Effectively, developing a macro (or bot as many programmers will call it) allows the user to send a virtual key, defined in winuser.h as VK_XXX and a flag noting whether the key is up or down to express whether the virtual key is expressed. The ALT-TAB sequence could be set up in this manner (Bachaalany, 2004):

//press down Alt-Tab
Keybd_event (VK_MENU, 0, 0, 0);
Keybd_event (VK_TAB, 0, 0, 0);
::Sleep (1000);
//stop pressing Alt-Tab
Keybd_event
(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
Keybd_event
(VK_TAB, 0, KEYEVENTF_KEYUP, 0);

As shown above, the event requires four lines of code. The mac o simplifies the process through simply calling a library: #include “Sendkeys.h”

References

Bachaalany, E. (2004). How to do ‘send’ keys in C++. Retrieved January 3, 2017 from https://www.codeproject.com/kb/cpp/sendkeys_cpp_article.aspx

Griffen, T. & Lowery, P. (2005). Definit-ion: Macro. Techtarget. Retrieved January 4, 2017 from http://whatis.techtarget.com/definition/macro

Mai, S. (2009). 10 tips for writing game bots. [Bog post]. Krypted. Retrieved January 2, 2017 from http://krypted.com/sites/5-rules-for-writing-bots-in-games/

Martin, A. (2016, October 17). How to create a game bot and publish your html5 games on Telegram. [Blog post]. Retrieved January 2, 2017 from https://blog.ludei.com/how-to-create-a-game-bot-and-publish-your-html5-games-on-telegram/