February 28, 2012

February Multisession Chess Tournament Part 4/4

Tonight, I was paired with a player rated about 300 points above me who also happened to have been my chess coach a few years ago.  I was playing the black pieces.  He opened with a king pawn.  We began the Scotch opening.  Play continued evenly until I did a discovered attack that won a pawn.  This also traded some minor pieces and gave me doubled pawns and an isolated edge pawn.  I traded a bishop for a knight, doubling a set of his pawns.  He almost gained a rook for a bishop, but I took away the opportunity by trading one set of rooks and getting the trapped one out of the way.  Unfortunately, this allowed him to come down and attack my weak pawns.  I was also able to get up into his pawn structure with a rook, and each of us was left with one isolated passed pawn on that side of the board.  Mine was farther, and I got to the second rank before I had to trade the pawns.  After that, we were each left with a rook and a wrecked castle position on the other side.  Our pawns would run into each other, and when I locked my rook into the pawn structure, obstructing two of his pawns, he accepted a draw.

After losing to a 1200, beating an 1150, drawing a 1550, and drawing again to a 1650, I think my rating will increase after this month.  My new rating will most likely be about 1360.

February 27, 2012

USACO

One of my mom's friends told her about the USA Computing Olympiad (USACO).  She told me about it, and I looked into it.  This organization has young programmers doing online exams in programming and eventually going up to the internation level if they do exceptionally well.  There are three divisions: bronze for students recently introduced to programming and algorithm design, silver for students working on learning more advanced algorithmic concepts like dynamic calls, and gold for students with a deep understanding of a wide range of algorithmic ideas.  I think I would fit into the silver division and might be able to get up to gold by doing some of their training exercises.  I might eventually get to a high level of computing competition.

Not too long ago, I had an idea for a competition that could be had between programmers of slightly lower-level applications that interface with OS API functions.  Programmers would create a program that would be run on the same computer as a program similar to it and each program would try to terminate the other first.  Termination would be defined as a file on the computer being updated every so often and being checked by a "referee" program which would declare a process dead and the other the winner.

February 26, 2012

Infinite Precision in VB .NET

In Visual Basic, there are a few different data types to hold numbers.  They each have their different sizes and what types of numbers they hold.  The U-prefixed types only hold positive numbers (like UShort), while the non-U types hold both signs (as in Short).  Some of them hold decimals (like Double) while others only keep the whole number part (Integer).  While all of these allow for varying degrees of precision, none can represent finely something like pi, which goes on forever.  They also do not allow for enormously large numbers without losing data (as in 9.384e73).  If there was a variable type that stored arbitrarily precise numbers as a string and exposed methods and operators to work on them, this would greatly expand the range of mathematical computing.  I did a bit of searching and found something written in Miranda, a strange, non-.NET language about which I know nothing.  As .NET is growing, it would be nice to have something similar for it...

And so I began working on the BWACG Infinite Precision Library (IPL).  Variables of type Infinite (named similar to Single and Double) have various methods to gain information about the value.  Right now, the only things that work are the FromString(Text As String), ToString(), Sign, and the unary - operator.  There are also in-progress DecimalPart() and WholePart() functions.  I have also defined an InfinitePrecisionException which is thrown when the programmer has an illegal action done on one of the package's components.  It shadows the normal Exception.Message (As String) with a IPFailReason enumeration type.  I plan on performing mathematics by the first-grade columns method for addition/subtraction and the one-digit-of-bottom-by-all-digits-of-top multiplication method (division is a little more complicated).  If I get anything complex working, it will certainly be a useful component to financial and scientifical programs.

It's slightly amusing when Visual Studio appends "Events" to the name of the class, resulting in "Infinite Events."  Also, I've never seen the VS icon for an operator declaration.  It's very colorful.

February 25, 2012

MATHCOUNTS

Today was the MATHCOUNTS competition!  I arrived at the testing center in the morning and waited for my teammates to arrive.  They did and we waited until the event began.  The first round was the Sprint round.  In this round, the testees have to do 30 problems in 40 minutes.  This is an individual event.  I was able to complete all of the problems in time, but I'm sure I didn't get them all right.  Something about circles touching hexagons and creating strange shapes confuses me.  The next round is the Target round.  This round is also individual.  We are given a sheet with two problems and have six minutes to complete it.  After that, we receive three more sheets in the same manner.  Finally, the Team round is a team event.  There are ten questions that need to be done in 20 minutes.  We were able to do all of the problems, but there was one about rainy/sunny vacation days that we didn't agree on.

After the Team round, there was a noncounted Countdown round.  The top eight individuals from some subsection of the tests compete against each other in a single-elimination tournament.  I was paired with an older girl who was a very quick thinker.  I lost, and she eventually got to the final round and also lost.  This round gave the people time to score the tests.  We were escorted back to the library for the awards.  My team got third place - just under the place necessary to go to the next level.  It is still possible for us to go to state due to a wildcard (we don't know that yet).  Next, they announced the individual awards.  They started with 10th place and climbed up to 1st.  I was totally stunned when I got first!

Even though the team might not advance to state, I will still go as an individual (the top five or so can proceed).

February 24, 2012

ACT

A few weeks ago, I took the ACT because of my high score on the school's cognitive tests.  The ACT just mailed the results to me today.  I was stunned when I saw the result...

30

The result sheet says that my score has been reported to the Middle School Talent Search... it's possible that they might call me.

Yaaaaay


February 23, 2012

Woah

The Internet scares me sometimes.  My parents just got two mysterious phone calls in a row from a person looking for a mattress store (wrong number).  Just for fun, I typed the phone number into a search engine.  It immediately understood that it was a phone number and linked me to a few web sites that reverse-lookup phone numbers.  It promptly gave me the address of the caller (I won't give any information about her here).  Clicking that showed me the name, phone carrier, and other interesting information about the caller.  Most of this information could be typed into another personal information lookup service and learn even more about this person.  Don't you think it's kind of scary that I can read all about some person --who I have never known anything about-- who entered a simple wrong number?

February 22, 2012

Poor Code = Code Security

With such tools as Telerik's JustDecompile in existence, it becomes impossible to hide proprietary algorithms in your published assemblies.  Even when I had given JustDecompile the SupaChat Server executable, it was able to give me my original code (or something the compiler had done to make my code faster).  If I had put any secrets in its code, they would be available for all the world to see.  Unfortunately, it would be very bad for someone to find the code it uses the create and transfer the encryption keys.  While browsing through it's decompilation of the SupaChat Lobby Server code, I noticed that it was missing a segment of code, displaying something like, "Exception occured in Telerik.dll: Object reference was not set to an instance of an object."  This was certainly the result of my using string variables without actually defining them properly.  The decompiler didn't like that and couldn't display code fragments that used it.  I had done this in the section of SupaChat Server that contained the key calculation and transfer methods.  I had apparently written it so badly that Telerik couldn't understand anything in that subroutine, much less see my algorithms.  So, it turns out that poor coding can save the day for sensitive data.  Of course, in situations which do not require such secrecy, solid code is the way to go.

February 21, 2012

February Multisession Chess Tournament Part 3/4

Tonight, I was paired with a player rated over 1500!  Since my rating is only 1337, this predicted a challenge.  The opening was pretty normal, him doing one of the knight-pawn fianchetto openings while I put my pieces in the center.  He got a pin on my knight, winning my rook for a bishop.  Other than that, we were even for about 20 moves.  I then was able to get my bishop threatening a discovered attack on the king while being defended by the queen.  My other bishop got up into his castle position and made the king's escape difficult.  However, his rook blocked the pawn from advancing, so I couldn't do the discovered attack.  My rook eventually got on an open file next to his king, but I couldn't come down with the bishop's support because of one of his rooks on the same rank.  If he had moved any one of most of his pieces, the game would have been over.  Unfortunately, I couldn't move very much without messing up the attack.  Since the position appeared locked, we both accepted a draw.  I think that's pretty good for playing a 1500 player.

Also, my name is permanently inscribed on the club website for being the most improved player of 2011.

Last on the list


February 20, 2012

SupaChat Server/Client Update 2/20/2012

I did a little more work on SupaChat's encryption today.  The problem left on the table was that of insane lengths being passed to the decryption function.  Suprisingly, they were totally numeric strings.  It is essentially impossible (might as well be a probability of ħ) for a bitwise encryption to generate anything like that, so something must be wrong.  The server was sending it properly, writing the correct length and broadcasting the right string.  The client also properly received the length, but upon getting the data, it got one of the insane numeric strings.  It turns out that the compiler decided it would "help" me and turn my byte value into a string representation of its ASCII character code instead of giving me the actual character.   I simply encased the Reader.Read() call in a ChrW (returns the actual character for an ASCII code), which fixed the problem.  This needed to be fixed in a few places, so it took a while to find them all and correct the errors in transmission and reception.  That worked, and to make sure everything was working inside the networking, I fired up the client on another computer and had it connect.  It worked fine until I tried encrypted transfer.  The server promptly crashed with an IOException in a place where the only thing that should happen was a TimeoutException.  After a bit of looking around, I found that the call to Reader.Read() was expected to return instantly (something that never happens on networks) and gave a message, "Non-blocking method call did not return instantaneously."  All Streams have a Position property which I could use for the alternative Read(buffer[] As Char, index As Integer, count As Integer) call, but NetworkStream is strange and doesn't support that property.  It does, however, have a DataAvailable property which I used to wait until all the bytes had been written before reading anything in.  It now blocks execution of other functions until it receives all promised data.  This isn't a security hole because it only happens in encrypted mode, which can only be entered by a special determined-on-connection client/server key.  Since the only person who knows how to derive and transfer the key (as well as create a client) is me, there is no possibility of any malicious entity freezing a SupaChat Server EncryptedClient session.  All I need to do is make sure there are no other oddities in the transfer, and encryption will be done!

What's ħ?

February 19, 2012

ERGH

Encryption in a line-based-transmission system is a real pain, especially when the encryption algorithm doesn't care if my data is text or binary.  I've been trying to add encryption to SupaChat for a while now.  Yesterday, all I could get was "Invalid key length" messages.  I found out why: my declaration of using a different algorithm came after the line used to tell it the key.  I switched the lines around, and it worked.  The next error I got was, "IOException was unhandled by user code."  The encrypted transfer mechanism had somehow messed up my basic transmission methods.  The fact that a huge amount of code was peppered with generic Catch statements didn't help in identifying where the errors occured; the program simply gulped them down and proceeded with insanity.  I went through and replaced a lot of the generics with specific catchers (usually for IOException or SocketException).  This made it a lot easier to tell when something bad happened, as execution didn't jump back to the "Syntax error" message.  This allowed me to find an error: it was complaining about the padding of the message.  I discovered that I hadn't kept the algorithms quite in sync (bad copy/paste).  I corrected the error (differing key lengths) and it got past that error.  The next bad thing was another length error.  Sometimes the algorithm would transform a few bits into the combination for a line break, messing up the stream transmission.  The thing I did to fix this was make it send a "length" data piece before the encrypted transmission and read out by bytes instead of lines.  This worked, and now the only errors are some mystery "insane lengths" which I haven't figured out.