Windward Core is now Fluent by Apryse. Click here to experience the new and improved platform!

Code Wars 2014 Windwardopolis

The Game

Transporting Passengers

There are 12 CEOs, each at their own office. Each CEO wants to visit the other 11 offices, in a specific order (their route). Your job is to transport 8 of the CEOs on one leg of their trips.

In addition, each CEO has a list of enemies (other CEOs they dislike). A CEO refuses to disembark the limo at a bus stop that one of their enemies is at. The enemies list of the CEOs presently at a bus stop do not stop a CEO from disembarking (the enemy check is one-way).

  • Example: Larry Page has Tim Cook as an enemy. But Tim Cook does not have Larry Page as an enemy. So Larry Page will not exit a limo at an office where Tim Cook is waiting. But Tim Cook will exit a limo at an office where Larry Page is waiting.
  • The number of enemies each passenger has in rand.Next(Passenger.PointsDelivered, Passenger.PointsDelivered + 3). So Shirley will have 3 – 5 enemies while Larry Ellison will have 1 – 3.

Transporting a CEO (passenger) from one company to another is a transit. If you abandon the passenger at a company other than their destination, that is still a transit, albeit one that you gain no points from.

Coffee Stores

Your passengers expect coffee to be provided in your limo. After three transits, you must restock the coffee by travelling to a coffee store. You can restock sooner and the count of 3 restarts. You cannot restock with a passenger in the car.

The number of coffees you have in your car are displayed in the status window with the power up icons in effect. When transporting a passenger, the coffee for that passenger will be removed when the passenger is delivered.

Power-Ups

You get a bunch of power-ups. You can play these at any time, but some have restrictions depending on the state of other players.

  • MOVE_PASSENGER – You specify a specific passenger that is presently at a company and it will move that passenger to a random company, other than the passenger’s destination. If you specify a passenger that is presently in a limo, the card has no effect and is discarded.
  • CHANGE_DESTINATION – You specify a specific player and if that player has a passenger in their limo, it will change the passenger’s destination to a different random company. If this player has no passenger, the card has no effect and is discarded. If the passenger is within 3 squares of their destination, the card is not played, but it is returned to your hand.
    Note: you do not set the passenger for this powerup, you set the player.
  • MULT_DELIVERY_QUARTER_SPEED – When you pick up your next passenger, your car’s speed will be reduced to ¼ the normal speed until you complete the transit. When you complete the transit the points for the transit will be multiplied by 1.5.
  • ALL_OTHER_CARS_QUARTER_SPEED – All other cars are dropped to ¼ speed for 30 seconds. These are cumulative so if 3 other players play this, you will be at ¼ speed for 90 seconds. You generally will not be stuck behind these cars (see movement below)
  • STOP_CAR – Will stop the specified car for 30 seconds. If the specified car is in a coffee stop, bus stop, or within 3 squares of its destination, this card has no effect and will be returned to your hand. These are cumulative so if 3 other players play this on you, you will be stopped for 90 seconds. You generally will not be stuck behind these cars (see movement below).
  • RELOCATE_ALL_CARS – All cars will be relocated to random locations on the map.
  • RELOCATE_ALL_PASSENGERS – All passengers that are at companies will be relocated to a different random company that is not their present destination, except it will not relocate enemies of your current passenger at your passenger’s destination.
  • MULT_DELIVERING_PASSENGER – There are 9 of these cards, one for each 1 point passenger (you get a random subset of them) and each specifies the passenger they apply to. You do not set the passenger, the card defines it. When playing this card before picking up the passenger, when you deliver them you get 1.2 times the points for that transit. This has no effect if you carry a different passenger for the transit (but they still drink the extra coffee).
  • MULT_DELIVER_AT_COMPANY – There are 12 of these cards (you get a random subset of them) and each specifies the company they apply to. You do not set the company, the card defines it. When playing this card before picking up a passenger, when you deliver them to this company you get 1.2 times the points for that transit. This has no effect if the passenger does not have the specified company as their destination (but they still drink the extra coffee).

MULT_DELIVERY_QUARTER_SPEED, MULT_DELIVERING_PASSENGER, & MULT_DELIVER_AT_COMPANY

  • You may only play one of these for a given transit. If you play several of these the last one is applied and the others are discarded.
  • Playing this card doubles the passenger’s coffee consumption. Therefore you must have 2 (or 3) orders of coffee in your car when you pick up. And both orders will be consumed during the trip. This occurs even if the card has no impact (MULT_DELIVERING_PASSENGER and not that passenger, MULT_DELIVER_AT_COMPANY and not delivered to that company).

The challenges you face are:

  1. You need to arrive at a bus stop (each office has a bus stop) when the passenger is still there. Another car may get there first and then you don’t have anyone to transport.
  2. You have a passenger you want to drop off and one of their enemies is at the drop off bus stop – which stops you from dropping them there. In this case you can abandon them at a different bus stop, but that does not count as a completed trip.
  3. A passenger delivered you may not pick up again. But a passenger abandoned you may pick up again.
  4. You want to find the shortest trips, near where you are. The points are identical for completing a trip that is 5 squares long and one that is 60 squares long.
  5. Restock coffee when you can do so quickly.
  6. Playing the power up cards when they can be best used.
  7. They can be used offensively. Playing STOP_CAR when you are racing another car to pick up a high point passenger.
  8. They can be used defensively. Playing MOVE_PASSENGER to (hopefully) move the passenger you want to a closer company.
  9. You may duplicate the card played by another player (STOP_CAR on the player about to win) which may not be the best use.

Game Setup

  1. The map is randomly selected at the start of each game.
  2. The companies are randomly assigned to the bus-stop locations.
  3. Each CEO starts at their company but the order of their destinations to the other 11 companies are randomly assigned each game.
  4. The enemies of each CEO are randomly assigned each game.
  5. There are 9 power-ups that each provide a point multiplier for a specific 1 point passenger and 12 that provide a point multiplier for delivery to a specific company. You will receive a random 7 of these 21 power-ups.
  6. For the remaining power-ups, you will receive one of each.

What Information you are provided

  1. At game start you are given the map, list of players, list of companies, and list of passengers.
  2. The game is “real-time” but in practice that means everything moves once per tick. You will get a status update every 16 ticks. This will provide the position and passenger of every car, the status of every passenger (where they are, their next destination), and your car’s path and list of passengers to pick up. This will also provide the power-up a player has in effect for the passenger they are presently transporting.
  3. When a power-up is played, you will receive a message telling you what power-up was played.
  4. When anyone arrives at any bus stop all players get a status listing if the passenger was dropped off and if one was picked up.
  5. When your car’s path is used up or bad you will receive a status message.

Sending Orders to the Game

You can send orders at any time. These orders may contain:

  • A new path
  • A new list of passengers to pick up, in preferred order, at the next bus stop.
  • A power-up to play.

Move Orders

The path and pickup are the only movement orders you can send. When your car arrives at a bus stop, if the passenger in your car can disembark, they will. If your car is empty and a passenger in your pickup list can embark, they will. There is no option in your orders to override this.

If the orders you send has no path, it will not update the path (just the pickup list). If the pickup list is empty it will not update the pickup list (just the path).

Note: The game is running when messages are sent to your A.I. and when you’re A.I. sends orders to the server. The messages are asynchronous and the server does not wait for a reply.

Power-Up Orders

PowerUps are all in your card deck. You can draw N cards into your hand. The limit of the number of cards in your hand is:

  • Score < 0.5 –> 4 cards
  • Score < 6 –> 3 cards
  • Score < 8.5 –> 2 cards
  • Score >= 8.5 –> 1 card

When you draw a card, it goes from the deck to your hand. At that point, if you have a score of 0 (starting), it is immediately available to play. If you have a score greater than 0, the card cannot be played until you stop at a company or coffee store.

If your score increases to reduce the cards allowed in hand, a card will be randomly discarded from your hand. In this case it is gone, it is not returned to your deck.

You can send orders to draw, discard, and play cards at any time, subject to the restrictions of a given card.

Power-up orders that effect a transit go through two steps.

  1. They are first assigned as the card to use at the next bus stop. At this point the card is no longer in your hand (and does not count for the total), it is your next stop card. Only 1 card can be your next stop card so if you then assign another transit power-up as your next stop card, the previous one is discarded.
  2. When you arrive at a bus stop, the next stop card is assigned as your transit card. You can only have one transit card and this card is now in effect until you arrive at the next bus stop. This card will be applied when you arrive and is then discarded.

Other players will see the card you have assigned to both the next stop and transit. Consider these cards you place face up when you play them.

The remaining power-ups take place almost immediately. Due to the communication between client and server, there is a quick two steps:

  1. They are first assigned as the card to apply on the next tick of the game engine. There can only be one card assigned to this. Once assigned, it does not count as the total in your hand.
  2. On the next tick of the game the card is processed and then discarded.

Therefore, do not send 2 cards to play with no delay between the cards. You must give the system time to process the first before playing the second. The other players will see this card when it is processed, but not when it is submitted.

Points

  1. The game will be played in 10 rounds with the score from all 10 rounds added up for a final score.
  2. There are 12 passengers who need to go from one company to another.
  3. Each passenger has a series of destinations so after arriving at one, they then want to go on to another.
  4. Each passenger starts at one office and has the other 11, in a random order, to visit.
  5. If a passenger has visited all 12 offices, they can no longer be transported.
  6. A passenger is in a car or waiting at a bus stop (or if they have had 11 trips – done).
  7. There are 9 other cars (you have the tenth) so there are always at least 3 passengers somewhere available for you to pick up.
  8. The round ends when one car has transported 8 passengers to their destination.
  9. Players receive 1 – 3 points for each complete delivery. Each passenger has their point value as a property. Shirley Clawson as CEO of Windward has 3 points, the CEOs of all contest sponsors (HP, Salesforce.com, and JetBrains) have 2 points, and the rest are 1 point.
  10. If a delivery is in process, the percentage complete of the trip measured by the Manhattan distance times 0.5 will be added to the score. This part will be 0 if the car is further away than the pick-up bus stop when the round ends.
  11. The player who delivered 8 passengers receives an additional 2 points.

Passengers

  1. You can only successfully transport a specific passenger once (if your trip is incomplete, you can pick them up again later).
  2. You can only have 1 (or 0) passenger in your car.
  3. Every passenger refuses to go to a bus stop that has any of their enemies.
  4. Each Passenger will have 1 – 5 enemies (randomly assigned at the start of the game).
  5. If their enemy is at their destination, you either have to wait for the enemy to be picked up or drop them at another company (bus stop). If you abandon them elsewhere, that trip does not count.
  6. You may drop off a passenger if someone at that bus stop has them listed as an enemy (enemy lists are not reciprocal). It’s just your passenger’s setting that limits this.
  7. You may drop a passenger off at the wrong location.
  8. Anyone else (or you) can then pick that passenger up, complete their trip, and get credit for that trip.
  9. You still can carry that passenger later for a successful trip.
  10. When your car goes to a bus stop, it will drop off the passenger you have, unless either of their enemies are there.
  11. When your car goes to a bus stop, if it has room (no passenger or passenger could be dropped), it will pick up 1 passenger from your list.
  12. You cannot pick up the passenger you dropped off there. You can go around the block and load (or more likely, transport someone else and then return).

Vehicle paths

  1. The path is defined by tile units, not by map units. The various units are described in the map section below but for the A.I., everything is in tile units.
  2. The engine will handle direction changes required by a new path. If your car is northbound and the path says go southbound, it will make a U-turn as soon as possible:
  3. Turns can only occur upon entrance to a straight map tile. So the car may have to travel in its present direction for several tiles before a U-turn can be made.
  4. Same issue for a change requiring a right/left turn in a tile when the car has already entered the tile. It has to continue out of that tile and then U-turn, and then right/left turn.
  5. If you provide a new path where the turn will occur after the map tile the car is presently in, then it will happen on that first tile (unless it is a curve).
  6. If you provide no or a bad path, your car will move randomly.
  7. If you hit a bus stop it will drop off the passenger (if allowed) and will pick one up if one is there in your pickup list.
  8. When provided a new path, because the system is real-time and your vehicle may be beyond where it was when you calculated the path, it will:
  9. Walk the new path looking for a map tile matching the tile the car is presently on. If it finds that, it will append the new path at that point.
  10. If no match, it will walk the old path, looking for a map tile where it can join to the new path, looking the length of the new path too. If it finds that, it will append the new path at that point.
  11. If no match, the engine will post a message to your A.I. saying it could not use your new path. It will then continue on the old path. If the old path runs out, it will then move randomly.
  12. If your path is not continuous or has illegal steps (park or office squares), the remaining path will be discarded and the engine will post a message to your A.I. saying it ran out of path.

Maps

  1. We several maps that are randomly picked from for each game. We have several additional maps that you do not have that we will use in the final (to stop hard-coding for the existing maps).
  2. There are tile units and map units. The game moves cars using map units and there are 24 map units per tile. The API for the A.I. is based solely on tile units and the only reason you need to be aware of map units is that once a car is moving through a tile it is locked until it exits the tile.
  3. Collision avoidance is implemented by dividing each tile into 4 sub-tiles and tracking car movement in those sub-tiles. You probably do not need to know this.

Movement

  1. Drivers in Windwardopolis are very safe. They leave 1 car length between cars. They always come to a full stop at stop signs and yellow & red lights.
  2. Cars decelerate & stop instantly (great brakes!)
  3. Cars require time to speed up. Each turn they will increase their speed by 0.1 up to the maximum.
  4. The maximum is 6 map units/turn on straight-aways and 3 map units/turn in curves.
  5. When a car reaches a yellow or red light (front bumper of car will enter the intersection on this tick):
  6. If there is no car in the intersection, the light will turn green and they will continue at full speed.
  7. If another car is in the intersection, your car stops instantly and the other direction turns yellow. All cars in the intersection will continue but no cars will enter the intersection.
  8. Once there is no car in the intersection, it turns green and your car accelerates.
  9. When a car reaches a stop sign.
  10. It will stop even if everything is clear.
  11. It will then go only if no car is within 42 map units of the intersection (from the no stop directions). This is adequate distance for crossing straight, more than needed for a right turn, and less than needed for a left turn (which can then slow the car it moves in front of).
  12. It will wait for a right of way car to clear the intersection even for a right turn when the other car is coming from the right.
  13. Cars wait on others even when moving is safe. For example cars in all 4 directions can make a right turn at the same time. But in Windwardopolis they will not. A car in the intersection is handled the same regardless of curve.
  14. A car wishing to make a left turn always yields to oncoming cars. It will not enter the intersection until it is clear from all other directions.
  15. If opposing cars both wish to make a left turn, the one to the intersection first will turn and the other will wait.
  16. If two cars block each other (they can jammed up if several are trying to get in 1 bus stop at the same time), after 20 ticks the cars will be moved even if they end up on top if each other.
  17. If you come up behind a car that is stopped or that is running at ¼ speed, and you are at full speed, then you will move through the other car to go ahead of it. This will only occur if you will be fully past that other car before it reverts to full speed.
  18. It was implemented this way because the code to move around the car in the other lane, handling oncoming traffic, was a lot of work. We opted for the simple solution.

Programming Environment

The provided code has the server (C# application running on Windows) and 4 sample clients (C#, C++, Java, & Python). You will use the server and one client.

You can run the server and client both on a single computer or the server on one and the client on a second.

  • Disable the firewall on your computers. If running both on a single computer, you need to disable when running for the school semi-final.
  • Again, disable the firewall, especially on the computer running the server component. 60% of the support calls we received last year were because people did not disable the firewall.
  • If running on 2 computers, the clients will connect to the provided IP address. So you can run “PlayerCSharpAI 123.456.789.000” and it will connect to the server at that IP address. If you do not pass an IP address it uses 127.0.0.1 (the local machine).

Start with the sample A.I. program and revise that for you’re A.I. You generally will only need to edit the MyPlayerBrain class, plus any additional classes you create. The other classes in the sample you should be able to use as is

The sample A.I. code is bad. Really, really bad. Do not depend on any of that code to be effective. The pathfinder is very good (last year it was purposely bad) so you should be able to use it as is.

Programming Languages

  • C# & C++ – Microsoft Visual Studio 2012 or 2013. Note that the C++ client is Microsoft C++, not generic C++.
  • C++ – your avatar must be in the working directory for your code.
  • Java – JDK 1.6 or 1.7.
  • Python – 2.7.3.
  • Server component – Windows 7 or 8. You can just run the .exe. However, if you want to run the server part under a debugger, you need to use Visual Studio – 2012 or 2013.

Our Hints

  • Random numbers are your friend. If your calculation scores moving passenger A as a 95 (scale 1 – 100) and passenger B an 89, don’t always take passenger A. Instead get a random number between 0 and 184 (89 + 95) and select based on the returned value.
  • Set the server logging level to INFO and your client to DEBUG. A lot of the time you will need to review the logs to find out what went wrong. By the time you see the problem, the game has moved well beyond that point and so the debugger is useless.
  • Do not rewrite the pathfinder – you’ll spend a lot of time and have no improvement.
  • Implement your approach quickly and then test. Testing will show you what works well and what does not.
  • Test against other teams early (we suggest 12:00, 1:30, & 3:00). Other A.I.s will be very different and much better than the brain-dead A.I. provided. You’ll face different problems. Because of the power-ups, other players can have a significant impact on your A.I.

Using the web

You can look on the web for information. And anything you can find you can use. What you may not do is ask anyone for help. So no posting questions, emailing friends, etc.

The Server Program

The maps used are set in windwardopolis.exe.config. You can change this to be a specific map for your testing.

Running the server

Run windwardopolis.exe.

  • Make sure the files windwardopolis.exe.config and log4net.dll are in the same directory.

There are two command line modes for the server. Normally you will run it as a Forms app and use the menu. However you may find these modes useful.

windwardopolis.exe /t “Anders Hejlsberg”

  • The /t stands for test.
  • The server will run, wait for your client to start, send the setup command to your client, wait for the ready reply, then send an exit to your client and exit with a code of 0.
  • This is used by our game server to test clients when they are uploaded for the final.
  • Replace “Anders Hejlsberg” with your team name.

windwardopolis.exe /a 3 c:\temp\game.xml “Anders Hejlsberg”

  • The /a means automatic.
  • 3 means run 3 games.
  • game.xml is where the scores will be written.
  • Then list 1 – 10 names of the players you want run.
  • When the client A.I.s listed have all connected to the server, it will then run at full speed, for the specified number of games, write the scores to the specified XML file, tell the client(s) to exit, and then exit with a return code of 0.
  • This is used to run all games in the world-wide final.

Running under the debugger

If you wish to run the server component under the debugger (to break and step through the engine), load this program in Visual Studio by going to File, Open, Project/Solution… and selecting the file Windwardopolis.sln.

  • Everything interesting occurs within Windwardopolis.game_engine.Engine.Tick().
  • On each tick the vehicles are moved 0 or 1 map unit (unless un-sticking vehicles where it can be several ticks). The number of ticks to move across a tile unit depends on the movement (straight, inner turn, outer turn, or U-turn).
  • If you change a limo location, it must be on a valid map unit following a TileMovement through a tile. A limo starts moving through a tile with one of X/Y set to 0 and the other set to 6 or 18.

The User Interface

Main Window

  • Join – Drop all A.I. players and wait for new players to join.
  • Lock – Set game ready to start. No new A.I. players can join and internal A.I. players will be added as needed to raise the total to 10.
  • Play – Starts or continues the game.
  • Step – Executes 1 tick of the game.
  • Stop – the game is ended. Additional games may be run for the players joined.
  • Speed – set how many ticks/second to run the game. Values are 1 (slowest) to 1,000. However faster speeds are also limited by the speed of the computer.
  • View – set:
  • The map zoom level.
  • Coordinate numbering on the top and left.
  • Limo shadow – will shadow only remote A.I.s.
  • Limo shadow all – will shadow all limos.
  • Turn sound effects on/off.
  • Player stats window (see below)
  • System messages window.
  • Debug Window (see below).
  • Debug Start – if checked (will have the green triangle) then as soon as a remote A.I. joins, the game will start.
  • Debug Reset – click to end the game, drop all players, and open for joining.
  • Full speed – will run at full speed and not update the map. It will update the player status window once per second.
  • Play Card – you can select any power-up card to be played by any player. The card will be added to that player’s hand and played immediately.

Player Stats

  • Avatar – if one is not set you will get a care bear.
  • Vehicle – your car.
  • Score – your score for this game. Scores across all games are listed below the status bar part.
  • Passenger – if you are carrying a passenger, the passenger you are carrying. No picture and the text {none} if you do not have a passenger.
  • Destination – the requested destination of your passenger. If you do not have a passenger, the bus stop your path is going to.
  • The coffee cups onboard & power-up cards presently impacting you.
  • Team name.
  • The passengers you have successfully transported.

Debug Window

This is a live list of the Companies and passengers.

  • Company – lists the map location of the company.
  • All passengers waiting at that company.
  • Passengers – lists by name.
  • The Limo or Lobby they are in.
  • The destination they next wish to go to.
  • Their route.
  • The companies, in order, they next want to visit. Does not include their present destination.
  • Their enemies.The other passengers they will not exit a limo if those enemies are at the bus stop.

Right Mouse Button

When the game is ready to start or paused, you can click the right mouse button on a car and get this menu.

  • Move Car – select this and then click on any straight road or a 4-way intersection. It will place the car there. For the intersection, click on the quarter tile where it enters the intersection. This will also re-calculate the path from the new location to the destination the car is presently headed to.
  • Set Destination – select this and then click on the bus stop you want the car to next go to. This will also re-calculate the path to the new destination.
  • Set Passenger – select the passenger you want in your car (already delivered passengers are greyed out). You can select passengers in lobbies or in other cars. When you do this the destination is not changed.

Uploading to the Windward server

If you are one of the finalists at your school, you then need to upload your code to Windward.

Key Points

These are the issues commonly tripped over when we did play testing at Windward.

  • You have 2 programs – the server and the one client you will use. You need to run both programs.
  • You start with the sample client code and revise it. (For those that played last year when the pathfinding code purposely sucked, this year the pathfinder is very good. You do not want to rewrite it.)
  • You can send orders to the server at any time. You are not restricted to responding only when you get a message.
  • All units passed to/from the A.I. are in tile units. Map units are used solely within the server.
  • When cars hit a red/yellow signal, stop sign, or wish to turn left they operate the same as in real life if:
  • Cars had no turn signal until they were entering an intersection.
  • Cars would not make a right turn if going straight was not allowed (due to another car in the intersection).

The Game

Transporting Passengers

There are 12 CEOs, each at their own office. Each CEO wants to visit the other 11 offices, in a specific order (their route). Your job is to transport 8 of the CEOs on one leg of their trips.

In addition, each CEO has a list of enemies (other CEOs they dislike). A CEO refuses to disembark the limo at a bus stop that one of their enemies is at. The enemies list of the CEOs presently at a bus stop do not stop a CEO from disembarking (the enemy check is one-way).

  • Example: Larry Page has Tim Cook as an enemy. But Tim Cook does not have Larry Page as an enemy. So Larry Page will not exit a limo at an office where Tim Cook is waiting. But Tim Cook will exit a limo at an office where Larry Page is waiting.
  • The number of enemies each passenger has in rand.Next(Passenger.PointsDelivered, Passenger.PointsDelivered + 3). So Shirley will have 3 – 5 enemies while Larry Ellison will have 1 – 3.

Transporting a CEO (passenger) from one company to another is a transit. If you abandon the passenger at a company other than their destination, that is still a transit, albeit one that you gain no points from.

Coffee Stores

Your passengers expect coffee to be provided in your limo. After three transits, you must restock the coffee by travelling to a coffee store. You can restock sooner and the count of 3 restarts. You cannot restock with a passenger in the car.

The number of coffees you have in your car are displayed in the status window with the power up icons in effect. When transporting a passenger, the coffee for that passenger will be removed when the passenger is delivered.

Power-Ups

You get a bunch of power-ups. You can play these at any time, but some have restrictions depending on the state of other players.

  • MOVE_PASSENGER – You specify a specific passenger that is presently at a company and it will move that passenger to a random company, other than the passenger’s destination. If you specify a passenger that is presently in a limo, the card has no effect and is discarded.
  • CHANGE_DESTINATION – You specify a specific player and if that player has a passenger in their limo, it will change the passenger’s destination to a different random company. If this player has no passenger, the card has no effect and is discarded. If the passenger is within 3 squares of their destination, the card is not played, but it is returned to your hand.
    Note: you do not set the passenger for this powerup, you set the player.
  • MULT_DELIVERY_QUARTER_SPEED – When you pick up your next passenger, your car’s speed will be reduced to ¼ the normal speed until you complete the transit. When you complete the transit the points for the transit will be multiplied by 1.5.
  • ALL_OTHER_CARS_QUARTER_SPEED – All other cars are dropped to ¼ speed for 30 seconds. These are cumulative so if 3 other players play this, you will be at ¼ speed for 90 seconds. You generally will not be stuck behind these cars (see movement below)
  • STOP_CAR – Will stop the specified car for 30 seconds. If the specified car is in a coffee stop, bus stop, or within 3 squares of its destination, this card has no effect and will be returned to your hand. These are cumulative so if 3 other players play this on you, you will be stopped for 90 seconds. You generally will not be stuck behind these cars (see movement below).
  • RELOCATE_ALL_CARS – All cars will be relocated to random locations on the map.
  • RELOCATE_ALL_PASSENGERS – All passengers that are at companies will be relocated to a different random company that is not their present destination, except it will not relocate enemies of your current passenger at your passenger’s destination.
  • MULT_DELIVERING_PASSENGER – There are 9 of these cards, one for each 1 point passenger (you get a random subset of them) and each specifies the passenger they apply to. You do not set the passenger, the card defines it. When playing this card before picking up the passenger, when you deliver them you get 1.2 times the points for that transit. This has no effect if you carry a different passenger for the transit (but they still drink the extra coffee).
  • MULT_DELIVER_AT_COMPANY – There are 12 of these cards (you get a random subset of them) and each specifies the company they apply to. You do not set the company, the card defines it. When playing this card before picking up a passenger, when you deliver them to this company you get 1.2 times the points for that transit. This has no effect if the passenger does not have the specified company as their destination (but they still drink the extra coffee).

MULT_DELIVERY_QUARTER_SPEED, MULT_DELIVERING_PASSENGER, & MULT_DELIVER_AT_COMPANY

  • You may only play one of these for a given transit. If you play several of these the last one is applied and the others are discarded.
  • Playing this card doubles the passenger’s coffee consumption. Therefore you must have 2 (or 3) orders of coffee in your car when you pick up. And both orders will be consumed during the trip. This occurs even if the card has no impact (MULT_DELIVERING_PASSENGER and not that passenger, MULT_DELIVER_AT_COMPANY and not delivered to that company).

The challenges you face are:

  1. You need to arrive at a bus stop (each office has a bus stop) when the passenger is still there. Another car may get there first and then you don’t have anyone to transport.
  2. You have a passenger you want to drop off and one of their enemies is at the drop off bus stop – which stops you from dropping them there. In this case you can abandon them at a different bus stop, but that does not count as a completed trip.
  3. A passenger delivered you may not pick up again. But a passenger abandoned you may pick up again.
  4. You want to find the shortest trips, near where you are. The points are identical for completing a trip that is 5 squares long and one that is 60 squares long.
  5. Restock coffee when you can do so quickly.
  6. Playing the power up cards when they can be best used.
  7. They can be used offensively. Playing STOP_CAR when you are racing another car to pick up a high point passenger.
  8. They can be used defensively. Playing MOVE_PASSENGER to (hopefully) move the passenger you want to a closer company.
  9. You may duplicate the card played by another player (STOP_CAR on the player about to win) which may not be the best use.

Game Setup

  1. The map is randomly selected at the start of each game.
  2. The companies are randomly assigned to the bus-stop locations.
  3. Each CEO starts at their company but the order of their destinations to the other 11 companies are randomly assigned each game.
  4. The enemies of each CEO are randomly assigned each game.
  5. There are 9 power-ups that each provide a point multiplier for a specific 1 point passenger and 12 that provide a point multiplier for delivery to a specific company. You will receive a random 7 of these 21 power-ups.
  6. For the remaining power-ups, you will receive one of each.

What Information you are provided

  1. At game start you are given the map, list of players, list of companies, and list of passengers.
  2. The game is “real-time” but in practice that means everything moves once per tick. You will get a status update every 16 ticks. This will provide the position and passenger of every car, the status of every passenger (where they are, their next destination), and your car’s path and list of passengers to pick up. This will also provide the power-up a player has in effect for the passenger they are presently transporting.
  3. When a power-up is played, you will receive a message telling you what power-up was played.
  4. When anyone arrives at any bus stop all players get a status listing if the passenger was dropped off and if one was picked up.
  5. When your car’s path is used up or bad you will receive a status message.

Sending Orders to the Game

You can send orders at any time. These orders may contain:

  • A new path
  • A new list of passengers to pick up, in preferred order, at the next bus stop.
  • A power-up to play.

Move Orders

The path and pickup are the only movement orders you can send. When your car arrives at a bus stop, if the passenger in your car can disembark, they will. If your car is empty and a passenger in your pickup list can embark, they will. There is no option in your orders to override this.

If the orders you send has no path, it will not update the path (just the pickup list). If the pickup list is empty it will not update the pickup list (just the path).

Note: The game is running when messages are sent to your A.I. and when you’re A.I. sends orders to the server. The messages are asynchronous and the server does not wait for a reply.

Power-Up Orders

PowerUps are all in your card deck. You can draw N cards into your hand. The limit of the number of cards in your hand is:

  • Score < 0.5 –> 4 cards
  • Score < 6 –> 3 cards
  • Score < 8.5 –> 2 cards
  • Score >= 8.5 –> 1 card

When you draw a card, it goes from the deck to your hand. At that point, if you have a score of 0 (starting), it is immediately available to play. If you have a score greater than 0, the card cannot be played until you stop at a company or coffee store.

If your score increases to reduce the cards allowed in hand, a card will be randomly discarded from your hand. In this case it is gone, it is not returned to your deck.

You can send orders to draw, discard, and play cards at any time, subject to the restrictions of a given card.

Power-up orders that effect a transit go through two steps.

  1. They are first assigned as the card to use at the next bus stop. At this point the card is no longer in your hand (and does not count for the total), it is your next stop card. Only 1 card can be your next stop card so if you then assign another transit power-up as your next stop card, the previous one is discarded.
  2. When you arrive at a bus stop, the next stop card is assigned as your transit card. You can only have one transit card and this card is now in effect until you arrive at the next bus stop. This card will be applied when you arrive and is then discarded.

Other players will see the card you have assigned to both the next stop and transit. Consider these cards you place face up when you play them.

The remaining power-ups take place almost immediately. Due to the communication between client and server, there is a quick two steps:

  1. They are first assigned as the card to apply on the next tick of the game engine. There can only be one card assigned to this. Once assigned, it does not count as the total in your hand.
  2. On the next tick of the game the card is processed and then discarded.

Therefore, do not send 2 cards to play with no delay between the cards. You must give the system time to process the first before playing the second. The other players will see this card when it is processed, but not when it is submitted.

Points

  1. The game will be played in 10 rounds with the score from all 10 rounds added up for a final score.
  2. There are 12 passengers who need to go from one company to another.
  3. Each passenger has a series of destinations so after arriving at one, they then want to go on to another.
  4. Each passenger starts at one office and has the other 11, in a random order, to visit.
  5. If a passenger has visited all 12 offices, they can no longer be transported.
  6. A passenger is in a car or waiting at a bus stop (or if they have had 11 trips – done).
  7. There are 9 other cars (you have the tenth) so there are always at least 3 passengers somewhere available for you to pick up.
  8. The round ends when one car has transported 8 passengers to their destination.
  9. Players receive 1 – 3 points for each complete delivery. Each passenger has their point value as a property. Shirley Clawson as CEO of Windward has 3 points, the CEOs of all contest sponsors (HP, Salesforce.com, and JetBrains) have 2 points, and the rest are 1 point.
  10. If a delivery is in process, the percentage complete of the trip measured by the Manhattan distance times 0.5 will be added to the score. This part will be 0 if the car is further away than the pick-up bus stop when the round ends.
  11. The player who delivered 8 passengers receives an additional 2 points.

Passengers

  1. You can only successfully transport a specific passenger once (if your trip is incomplete, you can pick them up again later).
  2. You can only have 1 (or 0) passenger in your car.
  3. Every passenger refuses to go to a bus stop that has any of their enemies.
  4. Each Passenger will have 1 – 5 enemies (randomly assigned at the start of the game).
  5. If their enemy is at their destination, you either have to wait for the enemy to be picked up or drop them at another company (bus stop). If you abandon them elsewhere, that trip does not count.
  6. You may drop off a passenger if someone at that bus stop has them listed as an enemy (enemy lists are not reciprocal). It’s just your passenger’s setting that limits this.
  7. You may drop a passenger off at the wrong location.
  8. Anyone else (or you) can then pick that passenger up, complete their trip, and get credit for that trip.
  9. You still can carry that passenger later for a successful trip.
  10. When your car goes to a bus stop, it will drop off the passenger you have, unless either of their enemies are there.
  11. When your car goes to a bus stop, if it has room (no passenger or passenger could be dropped), it will pick up 1 passenger from your list.
  12. You cannot pick up the passenger you dropped off there. You can go around the block and load (or more likely, transport someone else and then return).

Vehicle paths

  1. The path is defined by tile units, not by map units. The various units are described in the map section below but for the A.I., everything is in tile units.
  2. The engine will handle direction changes required by a new path. If your car is northbound and the path says go southbound, it will make a U-turn as soon as possible:
  3. Turns can only occur upon entrance to a straight map tile. So the car may have to travel in its present direction for several tiles before a U-turn can be made.
  4. Same issue for a change requiring a right/left turn in a tile when the car has already entered the tile. It has to continue out of that tile and then U-turn, and then right/left turn.
  5. If you provide a new path where the turn will occur after the map tile the car is presently in, then it will happen on that first tile (unless it is a curve).
  6. If you provide no or a bad path, your car will move randomly.
  7. If you hit a bus stop it will drop off the passenger (if allowed) and will pick one up if one is there in your pickup list.
  8. When provided a new path, because the system is real-time and your vehicle may be beyond where it was when you calculated the path, it will:
  9. Walk the new path looking for a map tile matching the tile the car is presently on. If it finds that, it will append the new path at that point.
  10. If no match, it will walk the old path, looking for a map tile where it can join to the new path, looking the length of the new path too. If it finds that, it will append the new path at that point.
  11. If no match, the engine will post a message to your A.I. saying it could not use your new path. It will then continue on the old path. If the old path runs out, it will then move randomly.
  12. If your path is not continuous or has illegal steps (park or office squares), the remaining path will be discarded and the engine will post a message to your A.I. saying it ran out of path.

Maps

  1. We several maps that are randomly picked from for each game. We have several additional maps that you do not have that we will use in the final (to stop hard-coding for the existing maps).
  2. There are tile units and map units. The game moves cars using map units and there are 24 map units per tile. The API for the A.I. is based solely on tile units and the only reason you need to be aware of map units is that once a car is moving through a tile it is locked until it exits the tile.
  3. Collision avoidance is implemented by dividing each tile into 4 sub-tiles and tracking car movement in those sub-tiles. You probably do not need to know this.

Movement

  1. Drivers in Windwardopolis are very safe. They leave 1 car length between cars. They always come to a full stop at stop signs and yellow & red lights.
  2. Cars decelerate & stop instantly (great brakes!)
  3. Cars require time to speed up. Each turn they will increase their speed by 0.1 up to the maximum.
  4. The maximum is 6 map units/turn on straight-aways and 3 map units/turn in curves.
  5. When a car reaches a yellow or red light (front bumper of car will enter the intersection on this tick):
  6. If there is no car in the intersection, the light will turn green and they will continue at full speed.
  7. If another car is in the intersection, your car stops instantly and the other direction turns yellow. All cars in the intersection will continue but no cars will enter the intersection.
  8. Once there is no car in the intersection, it turns green and your car accelerates.
  9. When a car reaches a stop sign.
  10. It will stop even if everything is clear.
  11. It will then go only if no car is within 42 map units of the intersection (from the no stop directions). This is adequate distance for crossing straight, more than needed for a right turn, and less than needed for a left turn (which can then slow the car it moves in front of).
  12. It will wait for a right of way car to clear the intersection even for a right turn when the other car is coming from the right.
  13. Cars wait on others even when moving is safe. For example cars in all 4 directions can make a right turn at the same time. But in Windwardopolis they will not. A car in the intersection is handled the same regardless of curve.
  14. A car wishing to make a left turn always yields to oncoming cars. It will not enter the intersection until it is clear from all other directions.
  15. If opposing cars both wish to make a left turn, the one to the intersection first will turn and the other will wait.
  16. If two cars block each other (they can jammed up if several are trying to get in 1 bus stop at the same time), after 20 ticks the cars will be moved even if they end up on top if each other.
  17. If you come up behind a car that is stopped or that is running at ¼ speed, and you are at full speed, then you will move through the other car to go ahead of it. This will only occur if you will be fully past that other car before it reverts to full speed.
  18. It was implemented this way because the code to move around the car in the other lane, handling oncoming traffic, was a lot of work. We opted for the simple solution.

Programming Environment

The provided code has the server (C# application running on Windows) and 4 sample clients (C#, C++, Java, & Python). You will use the server and one client.

You can run the server and client both on a single computer or the server on one and the client on a second.

  • Disable the firewall on your computers. If running both on a single computer, you need to disable when running for the school semi-final.
  • Again, disable the firewall, especially on the computer running the server component. 60% of the support calls we received last year were because people did not disable the firewall.
  • If running on 2 computers, the clients will connect to the provided IP address. So you can run “PlayerCSharpAI 123.456.789.000” and it will connect to the server at that IP address. If you do not pass an IP address it uses 127.0.0.1 (the local machine).

Start with the sample A.I. program and revise that for you’re A.I. You generally will only need to edit the MyPlayerBrain class, plus any additional classes you create. The other classes in the sample you should be able to use as is

The sample A.I. code is bad. Really, really bad. Do not depend on any of that code to be effective. The pathfinder is very good (last year it was purposely bad) so you should be able to use it as is.

Programming Languages

  • C# & C++ – Microsoft Visual Studio 2012 or 2013. Note that the C++ client is Microsoft C++, not generic C++.
  • C++ – your avatar must be in the working directory for your code.
  • Java – JDK 1.6 or 1.7.
  • Python – 2.7.3.
  • Server component – Windows 7 or 8. You can just run the .exe. However, if you want to run the server part under a debugger, you need to use Visual Studio – 2012 or 2013.

Our Hints

  • Random numbers are your friend. If your calculation scores moving passenger A as a 95 (scale 1 – 100) and passenger B an 89, don’t always take passenger A. Instead get a random number between 0 and 184 (89 + 95) and select based on the returned value.
  • Set the server logging level to INFO and your client to DEBUG. A lot of the time you will need to review the logs to find out what went wrong. By the time you see the problem, the game has moved well beyond that point and so the debugger is useless.
  • Do not rewrite the pathfinder – you’ll spend a lot of time and have no improvement.
  • Implement your approach quickly and then test. Testing will show you what works well and what does not.
  • Test against other teams early (we suggest 12:00, 1:30, & 3:00). Other A.I.s will be very different and much better than the brain-dead A.I. provided. You’ll face different problems. Because of the power-ups, other players can have a significant impact on your A.I.

Using the web

You can look on the web for information. And anything you can find you can use. What you may not do is ask anyone for help. So no posting questions, emailing friends, etc.

The Server Program

The maps used are set in windwardopolis.exe.config. You can change this to be a specific map for your testing.

Running the server

Run windwardopolis.exe.

  • Make sure the files windwardopolis.exe.config and log4net.dll are in the same directory.

There are two command line modes for the server. Normally you will run it as a Forms app and use the menu. However you may find these modes useful.

windwardopolis.exe /t “Anders Hejlsberg”

  • The /t stands for test.
  • The server will run, wait for your client to start, send the setup command to your client, wait for the ready reply, then send an exit to your client and exit with a code of 0.
  • This is used by our game server to test clients when they are uploaded for the final.
  • Replace “Anders Hejlsberg” with your team name.

windwardopolis.exe /a 3 c:\temp\game.xml “Anders Hejlsberg”

  • The /a means automatic.
  • 3 means run 3 games.
  • game.xml is where the scores will be written.
  • Then list 1 – 10 names of the players you want run.
  • When the client A.I.s listed have all connected to the server, it will then run at full speed, for the specified number of games, write the scores to the specified XML file, tell the client(s) to exit, and then exit with a return code of 0.
  • This is used to run all games in the world-wide final.

Running under the debugger

If you wish to run the server component under the debugger (to break and step through the engine), load this program in Visual Studio by going to File, Open, Project/Solution… and selecting the file Windwardopolis.sln.

  • Everything interesting occurs within Windwardopolis.game_engine.Engine.Tick().
  • On each tick the vehicles are moved 0 or 1 map unit (unless un-sticking vehicles where it can be several ticks). The number of ticks to move across a tile unit depends on the movement (straight, inner turn, outer turn, or U-turn).
  • If you change a limo location, it must be on a valid map unit following a TileMovement through a tile. A limo starts moving through a tile with one of X/Y set to 0 and the other set to 6 or 18.

The User Interface

Main Window

  • Join – Drop all A.I. players and wait for new players to join.
  • Lock – Set game ready to start. No new A.I. players can join and internal A.I. players will be added as needed to raise the total to 10.
  • Play – Starts or continues the game.
  • Step – Executes 1 tick of the game.
  • Stop – the game is ended. Additional games may be run for the players joined.
  • Speed – set how many ticks/second to run the game. Values are 1 (slowest) to 1,000. However faster speeds are also limited by the speed of the computer.
  • View – set:
  • The map zoom level.
  • Coordinate numbering on the top and left.
  • Limo shadow – will shadow only remote A.I.s.
  • Limo shadow all – will shadow all limos.
  • Turn sound effects on/off.
  • Player stats window (see below)
  • System messages window.
  • Debug Window (see below).
  • Debug Start – if checked (will have the green triangle) then as soon as a remote A.I. joins, the game will start.
  • Debug Reset – click to end the game, drop all players, and open for joining.
  • Full speed – will run at full speed and not update the map. It will update the player status window once per second.
  • Play Card – you can select any power-up card to be played by any player. The card will be added to that player’s hand and played immediately.

Player Stats

  • Avatar – if one is not set you will get a care bear.
  • Vehicle – your car.
  • Score – your score for this game. Scores across all games are listed below the status bar part.
  • Passenger – if you are carrying a passenger, the passenger you are carrying. No picture and the text {none} if you do not have a passenger.
  • Destination – the requested destination of your passenger. If you do not have a passenger, the bus stop your path is going to.
  • The coffee cups onboard & power-up cards presently impacting you.
  • Team name.
  • The passengers you have successfully transported.

Debug Window

This is a live list of the Companies and passengers.

  • Company – lists the map location of the company.
  • All passengers waiting at that company.
  • Passengers – lists by name.
  • The Limo or Lobby they are in.
  • The destination they next wish to go to.
  • Their route.
  • The companies, in order, they next want to visit. Does not include their present destination.
  • Their enemies.The other passengers they will not exit a limo if those enemies are at the bus stop.

Right Mouse Button

When the game is ready to start or paused, you can click the right mouse button on a car and get this menu.

  • Move Car – select this and then click on any straight road or a 4-way intersection. It will place the car there. For the intersection, click on the quarter tile where it enters the intersection. This will also re-calculate the path from the new location to the destination the car is presently headed to.
  • Set Destination – select this and then click on the bus stop you want the car to next go to. This will also re-calculate the path to the new destination.
  • Set Passenger – select the passenger you want in your car (already delivered passengers are greyed out). You can select passengers in lobbies or in other cars. When you do this the destination is not changed.

Uploading to the Windward server

If you are one of the finalists at your school, you then need to upload your code to Windward.

Key Points

These are the issues commonly tripped over when we did play testing at Windward.

  • You have 2 programs – the server and the one client you will use. You need to run both programs.
  • You start with the sample client code and revise it. (For those that played last year when the pathfinding code purposely sucked, this year the pathfinder is very good. You do not want to rewrite it.)
  • You can send orders to the server at any time. You are not restricted to responding only when you get a message.
  • All units passed to/from the A.I. are in tile units. Map units are used solely within the server.
  • When cars hit a red/yellow signal, stop sign, or wish to turn left they operate the same as in real life if:
  • Cars had no turn signal until they were entering an intersection.
  • Cars would not make a right turn if going straight was not allowed (due to another car in the intersection).

Apryse Software Corp. © 2024 All Rights Reserved.