Re: How to create a square grid like chess board???

From: Heath Hunnicutt (heath-usenet_at_removeThis.ofb.net)
Date: 10/18/04


Date: Mon, 18 Oct 2004 21:33:34 +0000 (UTC)

On 2004-10-18, Bart Demoen <bmd@cs.kuleuven.ac.be> wrote:
| tombolo wrote:
|> Hi...
|>
|> i'm doing a small system for stowing cargo containers on a
|> vessel. The concept and positioning of stowing these containers are
|> the same as placing a chessman on one of the chessboard's cell. so,
|> how do i implement the rows and columns?
|
| Please try Google. "Prolog chess" does wonders !

Oh, please.

RFC CHARTER FOR comp.lang.prolog:

0.0 All posts requesting advice for prolog representations should be
immediately chastised. These posts are always form university
students attempting to avoid their assigned work. These posts are
never opportunities to spread the ideas of logic programming or
prolog.

Anyway...

I came across a solution to the Chess N-Queens problem here:
http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_11.html

This is what many think of when they think of "Solving a chess
problem" with Prolog. However, the solution I reference takes
advantage of the fact that the problem space can be represented as
possible permutations, some of which satisfy the constraints.

What about a 'real' problem. Suppose you want to put the heavy
containers on the bottom, but the ones that need electricity in
section A, and those which need cooling in A or B, and they need to
also be in a low-cost order to unload a certain order of ports?

The solution can always be represented as a permutation of items in a
list for projects like this where there are a set number of pieces and
a set number of 'berths'. The question is how to search the
permutation space. Especially a real cargo ship, with perhaps 400
containers on it, has multiple real constraints and is a crazy
problem.

|> Can anyone show me an
|> example? i heard it can be done using lists.
|
| Where did you hear that it can be done with lists ? It is most amazing
| that you got such precise information on the power of lists, because
| with lists, you can do "everything" (that can be done in any other
| reasonable programming language) ... So, where did you hear that ?

Wow! Friendly!

|> And one more thing, how do i tell the system to skip the occupied
|> cell?
|> By using the not/1 predicate?
|
| I wouldn't abuse not/1 for skipping occupied cells.
| Not/1 is too powerful and you might skip un-occupied cells by accident.
| Or worse, you might turn a seemingly un-occupied cell into an occupied
| one later on. Scary isn't it ?

It would be scary if you had made it plain instead of meaningless.

| One more person with a very low esteem of this newsgroup :-(

Don't beat yourself up.

Heath



Relevant Pages

  • Re: matrix
    ... > matrices (this is not my exercise, but a start point), I've ... Cell is Row * Columns + Column, ... > in prolog? ... list of lists implementation due to Richard O'Keefe, ...
    (comp.lang.prolog)
  • Re: How to create a square grid like chess board???
    ... The concept and positioning of stowing these containers are ... > 0.0 All posts requesting advice for prolog representations should be ... i heard it can be done using lists. ...
    (comp.lang.prolog)
  • Re: Mneson use experience, limits
    ... Call it SCOPE, for Signatured COntainers ... The main motivation is the prospect of using SCOPE together with the concurrency and distributed features of Ada to make an elegant and reliable database engine inherently more appropriate for Ada applications than any binding to an external C library. ... all allocation, writing and reading primitive operations replaced by cell operations, or by operations of a container based on ... A persistence container is obtained by instantiation with the cell packages of the required persistence levels. ...
    (comp.lang.ada)
  • Re: Adapting software to multiple usage patterns
    ... The library is part of "the language". ... I have written a handful of list implementations, ... had perfectly adequate implementations of both lists ... that is missing is a common interface for containers. ...
    (comp.lang.c)
  • Re: avoiding recursion in repr?
    ... >>Is there any equivalent function for defining new container classes ... >>written in Python, or do potentially recursive containers have to be ... but __repr__ for standard containers. ... code for lists and dictionaries correctly, ...
    (comp.lang.python)