Monthly Archives: January 2016

chess4j 3.0 is released!

After a long period of inactivity I’m happy to announce the release of version 3.0 of my Java chess program, chess4j. This version is a good bit stronger than the previous version, though still not as strong as my C/C++ program Prophet (see below). The key areas of improvement are:

  • The addition of an opening book, which I discussed here.
  • Improvements in the positional evaluation function
    • Passed pawns are rewarded
    • Isolated pawns are penalized
    • Doubled pawns are penalized
    • Rooks on open files or half open files are rewarded
    • Rooks and queens on the 7th rank, particularly when connected to another rook or queen are rewarded
    • There is some attempt to keep the king sheltered until the endgame, and then encouraged to move towards the center
  • Almost 2x speed increase

The table below compares the performance of chess4j v2 against v3 on several different test suites. Each suite was run twice and the results averaged. I highlighted changes of +10% or more in green (good), and -10% or more in red (bad). The top 4 suites are tactical suites. There weren’t any significant changes here, despite the 2x speed increase. However, the ‘SBD’ suite and all the ‘STS’ suites below that are positional suites, and there were some differences there. Key areas of improvement (according to these tests) were ‘undermining’, ‘open files and diagonals’, ‘bishop vs knight’, ‘offer of simplification’, and ‘queens and rooks to the 7th rank’. The one suite marked in red measures advancement of the f/g/h pawns. I think the added king safety code has something to do with that: the program is less willing to push those pawns if the king is castled on that side.

Suite/Time v2 raw v2 % v3 raw v3 % Delta raw Delta %
WAC/5 258 86.0% 266 88.7% 8 2.7%
WAC/10 270.5 90.2% 273.5 91.2% 3 1.0%
WCSAC/5 775 77.4% 784.5 78.4% 9.5 0.9%
ECMGCP/10 35.5 19.4% 37 20.2% 1.5 0.8%
SBD/60 45.5 34.0% 96.5 72.0% 51 38.1%
STS1/5 30 30.0% 48.5 48.5% 18.5 18.5%
STS2/5 19.5 19.5% 39.5 39.5% 20 20.0%
STS3/5 45 45.0% 41.5 41.5% -3.5 -3.5%
STS4/5 36.5 36.5% 41.5 41.5% 5 5.0%
STS5/5 41 41.0% 59.5 59.5% 18.5 18.5%
STS6/5 47 47.0% 48 48.0% 1 1.0%
STS7/5 22.5 22.5% 33 33.0% 10.5 10.5%
STS8/5 31 31.0% 20.5 20.5% -10.5 -10.5%
STS9/5 30 30.0% 37 37.0% 7 7.0%
STS10/5 55.5 55.5% 57.5 57.5% 2 2.0%
STS11/5 19 19.0% 28 28.0% 9 9.0%
STS12/5 42 42.0% 48.5 48.5% 6.5 6.5%
STS13/5 45.5 45.5% 48 48.0% 2.5 2.5%
STS14/5 31 31.0% 62.5 62.5% 31.5 31.5%
STS15/5 22 22.0% 29.5 29.5% 7.5 7.5%

The table below shows chess4j’s performance in a head-to-head match verse four other engines (the bottom one being my engine, Prophet). The match conditions were: only one processor could be used, no thinking on the opponents time, and no opening book libraries or endgame tablebases. The matches were done using a set of 20 starting positions called the ‘Nunn Test Suite’. The engines play from each position twice- once as white and once as black, making the entire match 40 games. One thing that may jump out is that the results don’t seem consistent. Why the variability against the same opponent using different times? It very well could be that chess4j is better at longer time controls, but it would take thousands of games to prove that theory. This game set is too small to be statistically significant. The main point was to get a feel for how strong the engine is.

Opp 1 min 3 min 10 min
Gerbil 5-31-4 9-23-8 10-23-7
Horizon 4.3 6-31-3 8-28-4 4-31-5
Lime 6.2 5-32-3 4-29-7 6-29-5
Prophet 2.0e 2-32-5 4-35-1 2-35-3

While there is certainly a lot to do with the evaluation, it’s not so far behind Prophet’s that it would explain such a lopsided result. I’m afraid the main disadvantage chess4j has comes down to speed. On my laptop I typically see chess4j search between 180,000 and 200,000 positions per second. That may sound like a lot but this (32 bit compile of Prophet) searches between 800,000 and 1 million positions per second (and there are programs out there that search much faster than that!). To test that theory I ran another set of matches against the same opponents using time odds. In the table below, the 2x, 4x, and 8x columns show how chess4j would fare in a 1 minute match if it were 2x, 4x, or 8x faster than it is now. As you can see, if chess4j were 5-10 times faster than it is it would be much more competitive against this group.

Opp 1 min 2x 4x 8x
Gerbil 5-31-4 10-22-8 12-21-7 21-8-11
Horizon 4.3 6-31-3 8-26-6 11-21-8 12-21-7
Lime 6.2 5-32-3 6-30-4 14-20-6 16-12-12
Prophet 2.0e 2-32-5 6-29-5 10-27-3 15-9-6

Is it possible to make chess4j that much faster? Maybe. I was able to improve the speed of this version by a factor of two by doing a careful analysis of the data structures being used (mostly Collections stuff, like ‘ArrayList’ vs ‘HashSet’ and such), and looking up their runtime complexities for different operations (like adding, or iterating…) and changing the data structures where appropriate. But, I think I’ve gone about as far as I can down that road. This is a Java program after all. It’s not as “close to the metal” as a C program. I think to squeeze much more out of I’d have to scale back on how much object instantiation it does. But then it would look less like an object oriented program, and would probably be less readable and possibly harder to test… all of which go against what I want to accomplish with this program.

So, what’s next? My next areas of focus are:

  • It’s time to establish a proper testing routine. Meaning that, going forward, all changes to the program need to be measured in terms of ELO gain. This is a lot harder than it sounds but it will ensure changes are good changes.
  • Add a pondering search. Instead of sitting idly as the opponent is on move, try to guess what the opponent is going to do and start formulating a response. If we’re right often enough we can allow more time to think about each move.
  • Use all the machine’s processors! Most computers these days have multiple processors, yet chess4j is only capable of using one. (using multiple processors is easy. doing it efficiently [in the context of a computer chess] is MUCH harder than you might think)

If you’d like to try your hand against chess4j, you can download it from the
project website. It’s a console program though, not graphical. However, you can download a GUI and set it up to use chess4j… see the readme.txt file.

Enjoy!

Swafford Family Tour de States – Chapter I Part II

This is part 2 of a post where I was describing a trip my family and I took across the southern part of the United States. If you missed it you can click here to read it.

Oct. 18-21 – Visalia CA. We finally got out of the desert on this stop. Just two days before traveling through this area one of the roads we would have been traveling on was covered over with mudslides. This massive mudslide kept a major road closed for days as crews worked to unearth the road. Unfortunately some people did lose their lives, so we were really thanking God that the timing of our trip wasn’t just a little different. We ended up detouring around the closed section, on a road not really suited for bigger vehicles. I remember being high up on a mountain area with heavy fog and limited visibility. Not fun!

This stop and the next are in the central part of California, around the Sierra Nevada mountains. The main attraction in Visalia was to be Sequoia National Park. This is the home of the giant redwoods. The largest tree in the world is here – the General Sherman, in Sequoia’s Giant Forest. Some of the trees here are up to 3000 years old. Its incomprehensible how old and big these trees are. There are lots of trails in the Giant Forest. We took one just a few miles long called the “Congress Trail.”

20151020_132541

20151020_135911

20151020_140213

Oct. 22-25 – Coarsegold CA. Coarsegold is a little less than 100 miles north of the Sequoia area, east of San Francisco, close to Yosemite National Park. The KOA campground was probably my favorite. A lot of the campgrounds are really more “RV parks” than campgrounds, but this one was large, spread out, and really had more of a camping feel to it. Not long after getting there we noticed a lot of quarter sized holes in the ground. We discovered that these are tarantula holes! Apparently this area is known for their tarantulas!! They were even having their annual “Tarantula Festival” that very weekend!!! Jamie spotted one as he was riding around on his bike. Fortunately though, we arrived at the very end of the season so we didn’t see any more, to Amy’s great disappointment.

We had one day set aside to drive into Yosemite. On the way in, just outside the park we came across the Sugar Pine Railroad. This railroad was once part of a logging operation. Today it’s a tourist attraction, offering one hour rides on restored steam locomotives through the areas that were once logged.

Yosemite is one of the most beautiful places I’ve ever seen. The park covers a large area but there are only a few gates. Inside the park there is a large loop that circles around a valley area, with breath taking views. The trees are tall, with giant cliff faces and waterfalls all around. Towards the back side of the loop is a “village” with some shopping and eating. Unfortunately it was very busy while we were there, but I think it’s like that pretty much all the time now. Despite that we were able to find some quiet moments to just enjoy the scenery.

20151024_113951

20151024_142532

20151024_150213

Oct. 26-30 – Paso Robles CA. As we left the Yosemite area we traveled south and west towards central California’s Pacific coastline. We finally made it to the “other side!”

20151028_110924

We would be here for Halloween. We did a little decorating outside the trailer, and went downtown Paso Robles to do a little trick-or-treating.

pasorobles_halloween

Paso Robles is in the heart of wine country. There are lots of vineyards and wineries all around that offer tours and tastings, though we didn’t do any of that (it might be frowned upon with two kids). It’s also close to Hearst Castle, once the home of William Randolph Hearst. Hearst was a media mogul of the early 20th century. Anyone who was anyone in that day knew Hearst and spent time at his estate, which sits high up on a hill overlooking the Pacific ocean.

20151028_142334

20151028_142340

20151028_144215

Nov. 1-6 Malibu CA. From Paso Robles we headed straight down the Pacific Coast into southern California. Amy and I used to live in San Diego so we were really looking forward to getting back to our second home. Honestly though I was a little intimidated about the traffic we would be facing, but by this time I had thousands of miles of experience pulling the trailer so we did OK. The views driving down the Pacific Coast Highway were really spectacular. At one point we had the ocean less than 100 feet to our right and a mountain less than 100 feet to our left! The campground we stayed at was set up on a hill with a nice view of the ocean. We were able to see the ocean from the trailer. Some days we would pack a lunch and walk down to the beach.

20151104_131059

20151101_170448

20151101_170229

20151101_165135

There was a state park called Solstice Canyon within walking distance from our campground. One day we walked up to the park and then did some hiking. There were two old, abandoned houses on the trails. One had been occupied as recently as the 1980s but was destroyed by fire.

20151106_141110

20151106_142203

One day we drove down into Los Angeles to the Le Brea tar pits. Le Brea is right in the middle of town, and is actually an active (bubbling) tar pit! Over the course of 10,000 years or so that tar pit has swallowed up countless animals, some that are extinct today, so there is a lot of excavation and research going on. There are areas that are roped off, with warnings that you’ll become a fossil too if you cross the line!

lebrea1

lebrea2

We also went to the famous Getty Art Museum. Amy said she was a little disappointed with it overall. Of all the things we saw at the Getty the thing we’ll remember best is the parking deck! It became evident pretty quickly that driving our big truck into that parking deck was a mistake, but there was no room to turn the truck around and too much traffic behind us to back out. The parking deck at the Getty goes down into the ground, not up like most. As it goes down the overhead clearance gets a little shorter. At one point there was a sign that said if you couldn’t get under the sign you were too high. We slid the moon roof in the truck back and crept forward, clearing that sign by a few inches! I think Amy almost hyperventilated. I pulled that trailer about 7,000 miles, but it was in the parking deck at the Getty that I scared her most.

20151103_150039

20151103_162244

Another day we drove into Hollywood. I was really not looking forward to this, as it’s very crowded and not really somewhere you want to drive a big vehicle. However, we did manage to get to a scenic view of the Hollywood sign, got into Hollywood, found parking, and walked around for a couple hours. There was a red carpet event going on, which we later learned was some kind of Latino radio awards.

hollywood

20151105_151907

20151105_151938

20151105_152131

Nov. 7-13 San Diego CA. We were very much looking forward to our stay in San Diego. We went to San Diego a few years ago on a family vacation, but it’s such a great city and there’s always something else to do. We pulled in on a Saturday, so the very first item on our agenda was to visit Pacific Beach Christian Church (our “second home” church) the next morning. We hadn’t told anyone we were coming so we were really hoping Pastor Brian and some of our old friends would be there. Brian was really surprised! And we did indeed see some old friends. The lady in the picture below with Amy and the kids is Leona. Her and her husband Ed were members of PB Christian in the late nineties when Amy and I were attending. The church has changed a lot since then, and most of the faces have changed, but it still felt like a homecoming to us. We had a meal with the Daly family later in the week at their home. It was so great to catch up with them.

20151108_102217

20151108_115535

There is a small cafe at the end of Ocean Bean (OB) pier that we used to eat at. Had to do it!

obpier

cafe

One of the things we love about San Diego is the beautiful scenery at Point Loma. There is a small Coast Guard station on Point Loma, and an old light house that is no longer used. The light house actually isn’t very tall at all. It didn’t need to be because Point Loma is already so high above sea level. As you walk around Point Loma you see picturesque views of the city and the bay. (I used to love pulling into that bay in my Navy days. I knew when we passed beneath the Coronado Bridge that we were almost home.) There are some really nice walking trails around Point Loma, with surprisingly little to keep you from plunging into the ocean below! We stayed around long enough to see the sun set over the Pacific, an absolutely gorgeous sight.

20151108_143351

20151108_143248

20151108_154257

20151108_154345

20151108_154413

20151108_154549

20151108_154753

20151108_165350

The Wild Animal Park (now known as the Zoo Safari Park) is world famous, for good reason. There are a lot of exotic animals there, and the grounds and landscaping are amazing. It is (or was) the home of the only black rhino in North America. There are only three other black rhinos in the world, all in Africa. Sadly this rhino died just days after we saw it. The species will soon be extinct.

20151110_105640

20151110_131647

We also went to Legoland! This had been a dream of Amy’s for the last 16 years! Construction on Legoland was completed in 1998, while we still lived in the area. Amy had applied but they took so long to even respond that she took another job. To this day she still plays with Legos. She’s passed her love of Legos on to Jamie.

I wasn’t really sure what to expect out of Legoland, but it was very much a theme park with rides, and of course massive displays constructed entirely of Legos. There are different areas of Legoland, each with a different theme to it. One area was entirely Star Wars. In another area, there were reconstructions of world famous cities, like New York, Paris, and New Orleans. The weather hasn’t been kind to these displays over the years but it was still really something to see.

legoland

20151113_115138

20151113_131650

20151113_134008

When we left San Diego on Nov. 14th, it was a little bittersweet. We would be heading east, towards home. The trip was starting to wind down.

Nov. 14-17 Tuscon AZ. After a month of being in California we were finally back in Arizona, but further south than we were on the trip out west. Tuscon isn’t far at all from the Mexican border. There were two things on our agenda for Tuscon: to see the Airplane Boneyard and Tombstone.

Ever wonder where military planes go when they are retired from service? Most go to the Airplane Boneyard at Davis-Monthan Airforce Base in Pima. Since Davis-Monthan is an active Airforce base, one doesn’t just walk around at will. There is a museum outside the base that has an arrangement with the Airforce. The only way to view the boneyard is aboard a tour bus through this museum. There are acres and acres of planes here. Some could easily fly again, but other planes have been torn apart for their parts. The planes range from WWII era all the way up to modern planes. Unfortunately we couldn’t get off the bus and walk around the planes. The tour guide was a former military pilot and very knowledgeable about most of the planes out there.

20151116_141327

20151116_144513

20151116_144534

Tombstone is of course the location of the OK Corral, where the Earp boys and Doc Holliday got into a gun fight with Billy Clanton and the McLaury brothers. The town has done a good job of preserving their history. There is an unpaved street with wooden walkways that has an old west feel to it. There are even a few saloons! We went to a reenactment of the gunfight at the OK Corral and ate at “Big Nose Kates” – a restaurant named for Doc Holliday’s girlfriend and in the location of the “Grand Hotel.” There is a graveyard just outside of town that you can walk through. Clanton and the McLaury brothers are buried here.

tombstone

20151117_135915

20151117_142123

20151117_153820

20151117_162032

Nov. 18 – Las Cruces NM. Our next destination was Carlsbad, which was too far for one day so we stopped here overnight. By this point an electrical issue we were having with the truck was becoming a real problem. The turn signals had been starting to fail, and now were even malfunctioning to the point that a left signal would turn on the right blinkers! Las Cruces was going to the the last major town for a while but unfortunately none of the dealerships could get us in that day, so we said a prayer and pressed on.

Nov. 19-22 – Carlsbad NM. On the way to Carlsbad we drove through the Alamogordo and White Sands areas, then up through some mountain roads. On the way down the mountains I let the truck sort of “glide along,” trying not to use the gas at all. We were able to get up to 98 miles per gallon! If only we could maintain that!!

The KOA campground was a nice place, just north of Carlsbad and about an hour’s drive south of Roswell. The coldest nights of the trip were here. One morning I went to make coffee, and no water would come out of the faucet! The water hose completely froze up. I had to pull it off and stretch it out in the sunlight. I wasn’t happy about having to wait for my coffee.

Carlsbad Caverns was probably my favorite National Park. The entrance is just a big hole, like a cave. As you enter and start descending, the natural light slowly fades away until it’s completely gone. Of course the walkways are lit, but you can look off in the distance to see just how dark it is down there. The walkway descends around 800 feet or so, until you get to a large expanse known as the “big room.” The walk around the Big Room is about a 1 mile loop. The water pools there don’t move at all, yet they are crystal clear. One pool is known as “mirror lake.” There is an area known as the “bottomless pit.” Of course it’s not really bottomless, but it appears to be and must have really appeared so to early explorers.

20151120_115828

20151120_123153

20151120_135331

We also went to Roswell, the location of all the alien sightings in the late 40s. Roswell is a small town, and naturally they play up their reputation. There are alien statues all over the place. The street lamps light up green and look like alien heads. There is a small (but interesting) ‘UFO Research Center’ museum in town that we visited. Here you can learn all about the sightings and conspiracy theories and judge what really happened for yourself.

roswell1

roswell_streetlamps

Nov. 23 – Ft Stockton TX. Just passing through!

Nov. 24-28 – San Antonio TX. We spent Thanksgiving here. It was strange to not be with other family, but we had a good day together. We went out to eat at a really nice restaurant and then just spent a relaxed day with each other.

San Antonio is right in the heart of Texas. It’s a beautiful city. The Alamo is here, beautifully preserved in the downtown area. This was another opportunity to teach the kids some history by showing them firsthand. We started our tour of the Alamo by going into an old frame shop that’s right across the street. In this frame shop there was a large display of the Alamo as it once was, where (for a reasonable fee) the shop owner would tell you all about the battle. We then walked across the street, into the walls of the Alamo itself to see all these things. (Side note: if you’ve ever watched Pee Wee Herman — Ailsa asked an employee where the basement was. He wasn’t amused.) (Site note 2: I finally got the truck fixed here!)

20151125_142240

alamo

20151125_151657

San Antonio has a gorgeous downtown area. The river walk is lined with shops and restaurants.

20151125_154923

20151125_161347

There were also lots of hiking and biking trails within walking distance of our campground. Amy and I walked as the kids did some biking.

20151127_142142

20151127_142111

Nov. 29-Dec 2 – Houston TX. Houston is on the eastern side of Texas, near the gulf coast. It’s here that we noticed the land had shifted away from desert to green. It was starting to look and feel like home. The traffic in Houston is insane. Fortunately we weren’t staying in Houston, but just north of it, so I didn’t have to pull the trailer through all that crazy traffic.

We went to a zoo in Houston. The zoo is in their downtown area. It was a weekday (I think a Tuesday) and the weather wasn’t great, so it felt like we pretty much had the place to ourselves.

zoo

20151130_120132

Houston, we have a problem! We went to NASA’s Johnson Space Center! For me, this was a childhood dream come true. We sat in a room that presidents have sat in, looking in on the Mission Control of the Mercury and Apollo days. It was truly awe inspiring to me to consider what had been accomplished using technology that is far inferior to an average phone today. Incredible! We were also able to tour a facility where real research is happening that is relevant to today’s space program.

20151202_131752

20151202_135447

20151202_140354

We were also able to see (very closely) a Saturn V rocket – I believe the last. This is the actual rocket that was slated for Apollo 18, but the government shut down the program before it was launched. The thrusters are so big that it’s hard to fathom the power and force that comes from them as the rocket is launched.

20151202_142502

20151202_142804

20151202_143025

There is also a museum just outside of NASA’s gates that has some really interesting displays. Space suits, moon rocks, shuttle mock ups, movies, and even an old Star Trek movie set.

20151202_161757

20151202_115952

One final random memory from Houston: we went out to eat one night at a steak house. It seemed like the parking lot was full of trucks. Big trucks. I was glad we had a big truck. I would’ve felt out of place without it!

Dec. 3-6 – Baton Rouge LA. Houston was our last sight seeing stop, but there was one more item on the agenda before going home. Amy has a lot of family on her dad’s side in the Baton Rouge area. We stayed at a nice campground around a lake.

cheerio

On Saturday we went to her Aunt Beverly’s and Uncle Kenneth’s house. Lots of family came over to see us. Sunday we went to her Uncle Darryl’s and Aunt Minta’s house. Lots of family came over that day too! It was a great way to end the trip.

Dec. 7 – Toomsuba MS. There is just about 1000 miles between Baton Rouge and our driveway. We could have pushed to do it in two days, but we opted to do it in three. That was a good thing, because we had our first roadside incident on this day. We blew the right rear tire on the trailer. I got the trailer off the road but because of the slope of the road shoulder I couldn’t lift the trailer high enough to get the blown tire off. We had to call for help. Fortunately help arrived quickly and we were on our way.

Dec. 8 – Anderson SC. This was our first stop of the trip, and our last.

Dec. 9 – Farmville NC!! The state sign was a very welcome site! Everyone was super excited to that we’d soon be seeing family and home!

20151209_132800

It turns out that the spare tire had a leak! This was the tire the morning after pulling into our driveway. The morning after that it was flat!

20151210_151335

We estimate that we put about 7,000 miles on the trailer and about 10,000 on the truck. We saw and did a lot of amazing things. But, in the end it was the time together that made the trip so special. We are planning, Lord willing, to do a similar trip this year in the northern states. I can’t wait.