Skip to content
This repository was archived by the owner on Jun 23, 2022. It is now read-only.

glynx/Software-Challenge-Ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Software Challenge is a contest for computer sience schools in germany. The task for the pupil is it to develop clients for a given board game. In the contest the clients of the school play against each other to see which class implemented the best computer player.

For more info look at www.software-challenge.de

The Software Challenge offers a Client-Lib for Java and for Delphi. To extend the possible usage of programming languages, this project offers an implementation in Ruby. It consists of 2 parts, the XML-Proxy Client and the SitClient.

For the Server <=> Client communication the Software Challenge uses a XML based protocol (objects are serialized via XStream) When you want to develop your Client in another language it’s much work to implement the integeration of this protocol. The XML Proxy is a simple Client which is written in Ruby, it connects to the server-socket and opens another socket for your client. The XML is converted into a string based format that is posted via the socket. So for your implementation you do not need to parse the XML stuff, you just get a bunch of strings seperated by some special characters that you can easy parse via usual string operations

Blocks: In the format are several blocks that contain other messages, their format is: “BEGIN|<type>” and “END|<type>” The following block-types exist:

  • Game starts when the client conntects to the server and ends when the result is sent by the server.

  • Board is send initially when the game ist started, contains the whole board with all nodes and their neighbors

  • GameState Eeach round there is a Game state send by the server, it contains the current state of the game.

  • Result is sent when the game is finished. It contains the definition of the score fragments, the scores and their causes.

Messages:

Each message sent in one block has the format:

"<type of the message>|<payload>"

The payload< consists of n attributes, seperated by “;”.

Each attribute has the format

"<type>:<value>"

or if there are multiple values associated with the attribute

"<type>:<value 1>,<value 2>,...,<value x>"

Example:

"CURRENT|turn:0;player:RED

The payload can be empty, for example for a move request:

"MOVE_REQUEST|"

Sending a Move to the server

When you want to send the reply to a move request, your client has to send a message of the format:

"MOVE|sheep:<sheep id>;<target-node id>"

The proxy client will then send this message in XML format to the server.

You can use proxy client standalone via “./xml_proxy.rb <ARGS>” or “ruby xml_proxy.rb <ARGS>”

There are several arguments accepted by the xml_proxy, use “–help” for more information about the arguments.

If you would like to use the proxy from ruby, you can:

require 'proxy_client'

If you would like to use your client from the commandline, just require your logic_class in the sit_client.rb and use use

ruby client_starter.rb --logic_class MyLogicClass <any args for the proxy you would like to use>

At first you should require the sit_client. After this you can use the args hash which contains the setting the proxy should be set up with, like :host, :port, :verbose … (for all arguments look at xml_proxy.rb), and pass it to the new Method of the ProxyClient

“ProxyClient.new” or “ProxyClient.new(args)”

After this you can use “.start” to start the ProxyClient and the ProxyServer. To stop the ProxyClient you can use “.finished!”

The Proxy opens a Socket which your Client can connect to. This socket is per default on port 14000 but via the -pp parameter this port can be changed. Using any programming language you can connect to this port with your client, receive the messages and send moves to the server using the format described above!

The SitClient provided in the “sit_client.rb” is a full featured Ruby simple client, that uses the XML Proxy to communicate with the server. It supports the integration of own logic. For building a own logic, just extend AbstractLogic and initialize the SitLogic with the logic you would like to use:

"SitClient.new(MyNewLogic)"

Your logic has to respond_to the move_requested method, which should return an array for [sheep,target] where target is the target-node where the sheep should move to. (You can either use the indexes of the sheeps and nodes or the objects themselve)

To find your move you can use @board,@state and @client

This are the buildin classes:

  • Board is the board of nodes that classify the field

  • State is the current game_state, consisting of sheeps, dice…

For more information about the possibilities look at the Classes.

  • The xml proxy should be able to communicate via pipes!

  • When terminating the client while connected to the server, the next time the one or two of the players in the GameState are lost..seems to be a issue of the server, causes the client to crash!

About

A XML-Proxy and a Client Lib for the Software Challenge 2011

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages