Skip to main content

Making a dynamic sequence(in Java)



Hey guys im having a problem trying to program out a set of logic. I want to make a Go(the board game) problem. What i want my program to do is read in an xml file that represents a series of steps a person can make to complete the puzzle, or a even a dead end. So in the xml it would look something like







<Step x="4" y="5">

<Response x="4" y="6" />

<Step x="3" y="6" victory="true">

</Step>

</Step>

<!-- This is a dead end -->

<Step x="4" y="4">

<Response x="4" y="5" />



<Step x="5" y="5" defeat="true"></Step>

<Step x="6" y="4" defeat="true"></Step>

</Step>







My thought is to make a link list of sorts where my xml handler(im using SAX) uses the step class to store a step inside a step, but i cant conceptualize how i would run down the list like that. Does anyone have a clean way of doing something like this? *Note i need to run down each and every step, and if the step doesnt exist, call them wrong and make them try again, but im willing to change my xml to whatever it needs to be.


Comments

  1. Looks like you would like to store tree of possible steps and responses?

    I would create a class Step with player=player1 (or player2).

    <Step player="p1" x="4" y="5">
    <Step player="p2" x="4" y="6">
    <Step player="p1" x="3" y="6" victory="true" />
    </Step>
    <Step player="p2" x="4" y="3">
    <Step player="p1" x="3" y="6">
    //some more steps
    </Step>
    </Step>
    </Step>


    or just list of steps

    <Step player="p1" x="4" y="5">
    <Step player="p2" x="4" y="4">
    ...

    ReplyDelete

Post a Comment

Popular posts from this blog

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex