Jump to content
IGNORED

XB Game Developers Package


senior_falcon

Recommended Posts

Hi Vorticon and senior_falcon,

I have been following your chat for some time and I am very impressed, especially with the quick fixes. I have played the game Stratego several times and I am very curious about the speed of the compiled version. Today I compiled a small xb program with xb256 and it works very easy. Many thanks to senior_falcon for this tool. this is much easier for me than AL.

@Vorticon: If you will, I can make someone tests with your compiled Stratego.

 

I am attaching a disk image of the compiled game. It is started as usual with DSK1.STRATEGO. I think you will be very happy with the play speed as the response time is now only a couple of seconds!

Unfortunately, as I was testing the game this evening, it was playing perfectly, and then I got this error about halfway through. No idea what this means... If you could try a game on real hardware on your end and see if you can replicate that error that would be great. I'm not going to have time to do that myself over the next couple of days.

 

post-25753-0-67864800-1553998190_thumb.jpg

 

STRATEGO.dsk

Link to comment
Share on other sites

Thanks for checking. It seems to be occurring when the computer is plotting a move, which narrow things a bit. When you type RUN again, you are simply restarting the main Stratego program which assumes the graphics have already been defined by the initialization program.

Link to comment
Share on other sites

I have a hunch the compiler is having an issue with this routine called from the main computer move generation routine MOVEGEN. This subroutine is only run when the number of player units is less or equal to 27 including bombs and the flag, which explains why the error is cropping up only in the middle of the game. Wolhess can you double check me on this?

// Locate nearest enemy unit
SUB FINDEN(COMP(,),PLAY(,),KNOWN(),EMOVED(),ID,DX,DY)
OX=COMP(ID,2)::
OY=COMP(ID,3)::
MINDIST=500::
DX=0::
DY=0

FOR I=1 TO 40
	IF PLAY(I,1)=0 THEN 
		skip_piece
	IF KNOWN(I)<>0 AND (PLAY(I,1)>COMP(ID,1) OR (COMP(ID,1)<>3 AND PLAY(I,1)=11)) THEN 
		skip_piece
	IF EMOVED(I)=1 AND COMP(ID,1)=3 THEN
		skip_piece
	X=PLAY(I,2)::
	Y=PLAY(I,3)
	IF ABS(OX-X)<=3 AND ABS(OY-Y)<=2 THEN
		skip_piece
	DIST=SQR(((OX-X-2)^2+(OY-Y)^2)*100)
	IF DIST<MINDIST THEN
		MINDIST=DIST::
		MTX=X::
		MTY=Y
skip_piece:
NEXT I
IF MTX>OX THEN
	DX=1
IF MTX<OX THEN
	DX=-1
IF MTY>OY THEN
	DY=1
IF MTY<OY THEN 
	DY=-1
SUBEND
Link to comment
Share on other sites

so, of 5 games 4 are crashed.

 

1. in my last post.

2. I won the game!

post-62965-0-29959200-1554031634.jpg

3. move Major up to a free place left of the right lake.

post-62965-0-29815900-1554031651.jpg

4. move Colonel right to a free place behind the left lake.

post-62965-0-22223400-1554031681.jpg

5. move Major left to a free place.

post-62965-0-28159700-1554031723.jpg

post-62965-0-26556700-1554031732.jpg

 

I think the emperor order is running and then when Wellington will start it crashes.

  • Like 1
Link to comment
Share on other sites

I don't see anything wrong with the compiled code in the FINDEN subprogram. I will try to set it up to accept values and see if it behaves right.

 

Meanwhile you could do some further detective work. It looks like "STRATEGO" is in a fixed place on the screen. If so, you can easily verify whether the problem is happening in the main program or in one of the subprograms. At the beginning of each subprogram you can have it print the name of the subprogram like so:

3790 SUB FINDEN(COMP(,),PLAY(,),KNOWN(),EMOVED(),ID,DX,DY)
3791 DISPLAY AT(21,11)SIZE(:"FINDEN  "              name of subprogram (6 letters) plus 2 spaces
.....subprogram lines of code.......
3939 DISPLAY AT(21,17)SIZE(2):"MP"                    write MP to the last two spaces
3940 SUBEND 

When the program breaks you will be able to read the name of the subprogram that caused trouble. If it is followed by MP then the fault happened in the main program and the last subprogram called is displayed.

Once you know that a subprogram is causing trouble, you can print each line in the same manner to find exactly where the problem lies.

Edited by senior_falcon
  • Like 1
Link to comment
Share on other sites

You do have a square root after all. (It is not in the version of STRATMAIN that I have)

DIST=SQR(((OX-X-2)^2+(OY-Y)^2)*100)

SQR reports an error if you are taking the square root of a negative number. I'm guessing that's what is happening. You are probably running afoul of the integer arithmetic, causing a negative number when compiled.

 

(edit) I must be losing it. I was sure I did a post about that error only happening when you take a square root of a negative number. But I don't see it, so it must be I forgot to upload it! Doh.

 

(edit) I see your numbers are pretty big - you are squaring a number, squaring another number, then multiplying by 100 and adding them together. So what is happening is that the number you are taking the SQR of is greater than 32767, making it a negative number.

Edited by senior_falcon
Link to comment
Share on other sites

That was indeed the issue. I went ahead and simplified the equation and it seems to be working fine. Frankly I no longer recall why I had the equation the way it was before, so I hope I'm not overlooking some fringe case here.

Wolhess, would you be kind enough to give the program another round of testing? Attached is the updated disk image.

 

STRATEGO.dsk

  • Like 1
Link to comment
Share on other sites

it's done!!!icon_smile.gif

 

I tried it three times and all works very well.

 

Compiled, the game is very fine playable. Vorticon did an outstanding job.

 

And of course the compiler is very practible and easy to use.

 

Thank you to Vorticon for the game and thank you to senior_falcon for this compiler tool.

 

  • Like 3
Link to comment
Share on other sites

That was indeed the issue. I went ahead and simplified the equation and it seems to be working fine. Frankly I no longer recall why I had the equation the way it was before, so I hope I'm not overlooking some fringe case here.

Wolhess, would you be kind enough to give the program another round of testing? Attached is the updated disk image.

 

attachicon.gifSTRATEGO.dsk

 

I think you were using a geometric distance calculation that uses the square root of the sum of the squares.

 

TI Forth has a distance equation for sprite distances but it looks like in a 16 bit integer calculation it eliminated the root and used the magnitude of the sum of the squares as a proxy for the distance. It had to also have an overflow test. Not sure that's optimal but extracting roots is typically slow. (also true for periodontistry) :-)

Link to comment
Share on other sites

Yes, and I am still using that. What I don't recall is why I was substracting 2 from the first term and multiplying the whole thing by 100. I just took those out to circumvent the compiler SQR limitation with negative numbers and so far I'm not seeing any difference in the behavior...

Link to comment
Share on other sites

These are my results with the three try

 

S1.JPG

S2.JPG

S3.JPG

Thank you for testing! Clearly the computer is no match for you :)

Thinking about that, since I still have about 2K left after compilation, I might see if I can make the AI better. I have a couple of ideas. I'll work on it this week and see what I can come up with before officially releasing the compiled game.

Harry, many thanks again for making this possible.

  • Like 2
Link to comment
Share on other sites

Come to think of it, looking at your screenshots, it seems that the computer is giving up too early. I'll do some more tests.

 

EDIT: I just finished a game and the computer fought me tooth and nail till the bitter end with no early surrender. I'll play a few more games later to verify. As far as I can tell so far, everything is working as it should. But I definitely need to beef up the AI.

 

post-25753-0-88359800-1554122721_thumb.jpg

  • Like 1
Link to comment
Share on other sites

For my game know how, the computer AI is good enough so that I can win too. That motivates me to keep playing. If you improve the AI, then maybe over different levels. Similar to Video Chess (Beginner, Novice, Intermediate). (or easy and hard).

Link to comment
Share on other sites

Thinking about that, since I still have about 2K left after compilation, I might see if I can make the AI better. I have a couple of ideas.

You actually have more room than that. If you put the runtime routines into low memory you will have about 10K of memory left. Because the compiled code is more compact that would translate to about 15K of XB instructions!

Depending on how you want to test this, remember that you can use (almost) all 32K for XB.

Link to comment
Share on other sites

You actually have more room than that. If you put the runtime routines into low memory you will have about 10K of memory left. Because the compiled code is more compact that would translate to about 15K of XB instructions!

Depending on how you want to test this, remember that you can use (almost) all 32K for XB.

 

That's really good news! My creative juices are flowing :) More to come...

  • Like 1
Link to comment
Share on other sites

For my game know how, the computer AI is good enough so that I can win too. That motivates me to keep playing. If you improve the AI, then maybe over different levels. Similar to Video Chess (Beginner, Novice, Intermediate). (or easy and hard).

 

What I want to try is come up with an algorithm that allows the computer to take a guess at where the flag is towards the end of the game so it can direct its pieces accordingly. As things currently stand, it just moves towards enemy pieces avoiding known bombs and higher level units and hopes for the best. Also its needs to protect the flag better. Now that I have close to 15K at my disposal per Harry, this might be very doable... That said, debugging is going to be much more difficult since the program is already too large to run in straight XB. I will have to rely heavily on tracers during execution keep track of the execution.

Since I will be adding these capabilities to the existing ones, it would be trivial to activate them only when the selected level is, say, challenging, instead of normal.

  • Like 1
Link to comment
Share on other sites

 

Why don't you give this a try?

Using the full 32K for an XB program

 

 

I don't think that's going to be necessary. I made some additional enhancements to the gameplay but anything more involved would have required a major re-write which I don't really want to do. Even then, it now takes about 10-12 seconds for the computer to come up with a move.

I've played a couple of games with the updated compiled program and it works fine so far. I even lost one of the games... Wolhess, as my favorite tester ( :P) , would you mind playing a few more games and letting me know if you think the AI strength has improved and whether you ran into any execution issues? I've had random lockups under Classic 99 previously.

 

STRATEGO.dsk

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...