taruss
12/28/2015 7:14:00 PM
On Sunday, December 27, 2015 at 1:49:34 PM UTC-8, Malice wrote:
> On Sunday, 27 December 2015 21:06:51 UTC+1, Tom Russ wrote:
> > OK, there are several parts here.
> >
> > First, you need to write a program to play chess.
>
> I completely agree. This part I'm aware of, and I will probably do this first. I'm more concerned of second part.
>
> >
> > Second, you need to interact with the browser.
> > * For background, you should look into the GET and POST methods for HTTP requests.
> > * Then you need to select one of the web server packages that are available. It's been a while since
> > I have done anything like this, so you should get recommendations from others. Although a quick
> > look at Cliki.net suggests perhaps Drakma would work for you.
>
> I've worked with drakma(slightly), it was fine.
>
> > * You then need to GET the input page for the chess site.
> > -- Determine the state of the game. If it is just graphical, this could be a problem!
>
> I don't think so - even if it was graphical, graphics should be fixed, so some simple checks for colour in few pixels should do(or so I hope).
>
> > -- Determine if input is required (i.e., is it time for you to move? Have you instead lost or won?)
> > * Probably POST the information required by the interaction of the web site. This would be the form
> > contents that contains your input.
> > -- Set the proper input fields.
> > -- Send the properly encoded response to the web server.
>
> Now, this web thing is completely new to me- I've never done anything with it. Therefore, here goes the question that might be utterly stupid, but here it goes: if I understand what you're saying, you want me to start some server in background and use it to send and receive packages from the web client. That's fine by me, there should be some tutorial stuff around there. However, I am worried that this might not be what I'm looking for - I worry that it might be hard to either prove(from second server) that it's indeed me who's sending the request, or if I do this just okay - that notification will be sent to my server instead of browser(so I won't bet graphical update from web browser).
>
> Of course I might be (and probably am) completely wrong, so feel free to correct me.
If I understand correctly, you want to build a web client that talks to a
third-party web server that actually runs the chess game.
So you would write a program that uses the client tools to interact with the
third-party web server. In effect, you will be building a programmatic web
"browser" that would play the part of a regular web browser when you interact
with the web site in the standard manner.
Whatever mechanism the web server uses to manage the interaction with the web
browser should also work when your program interacts with the browser. This
could be based on cookies, a hidden input field in the form, or some other
form of session id. As long as your client code properly acts like a regular
web client/browser, you should be able to interact with it.
You do have an advantage doing this from lisp, because you can try out parts of
the interaction and examine the results interactively as you build up the
system. As a start, you would want to GET the page from the web server and
see what it looks like. Then you could try to construct a proper response to
send and see if that works.
Where could this go wrong?
Well, if this is a JavaScript heavy interaction page, then it could be much
more difficult to work out the interactions, since a browser would be running
a program that manages the interaction rather than using the standard HTTP
GET/PUT/POST methods. You may still be able to figure out the API that the
page uses, but that would require more analysis of the page than if it is a
more standard HTTP/HTML page.