Source language: Translate to:

Open Source NeoChess Game

Questions related to the distribution, marketing and selling of applications created with NeoBook. (Formally titled: "Making Money with NeoBook")

Moderators: Neosoft Support, Wrangler

Open Source NeoChess Game

Postby David de Argentina » Mon Oct 15, 2007 7:12 pm

Hi all,

Wanna play chess...?

I found somethere a True Type Chess Font.

I think there is a good theme in order to do a public chess game.

I created table and put it the pieces. I used HPWGrid to do the table.

All rest is to do....

If any is interested on develop part of the game, this is a good place to tell us what part you would develop.

Elementary PUB and Chess Font is here:

http://specialapps.software-zone.com/files/NeoChess.zip

Greetings from Buenos Aires,
David de Argentina
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

A bit difficult...

Postby pamoxi » Wed Oct 17, 2007 4:42 pm

Hi David.

The table and pieces are the easy part.

The problem here is the development of artificial intelligence that manage the PC player and this can play to high level...

It is a bit diffcult to make, but is interesting to study.


Hola David.

El tablero y las piezas son la parte facil.

El problema es como desarrollar el algoritmo de inteligencia artificial necesario para que el programa sea competitivo.

Es algo un poco dificil, pero sería interesante estudiarlo.

Saludos David.
pamoxi
 
Posts: 9
Joined: Sat Oct 13, 2007 4:24 am

Postby David de Argentina » Wed Oct 17, 2007 9:43 pm

Hi Pamoxi,

Thanks for your answer.

you said: "The problem here is the development of artificial intelligence that manage the PC player and this can play to high level... "

This is one posibility... I'm working on another...

I'm trying to create a two players game. Local and remote players.
I assume both players know play chess and all moves are legal.

Actions:
* Redraw table at each move: 100% done
* Generate Chess-Style Notation: 90% done
* Automatize Special moves: like encastling (enroque): 90% done.
* Save game: 70% done.
* Connect players via TCP: 0% done.
* Replay saved game: 0% done

Code could be loaded as Add-on or Library function in order to be attached to other applications...

Greetings from Buenos Aires,
David de Argentina
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Chess game

Postby pamoxi » Thu Oct 18, 2007 4:52 am

Hi David.

Is English the official language for this site?
or we can write in spanish too?

Because my english is not very good...

Recomendation: for TCP connections I think that this not would be only IP to IP, here in Argentina the 80% of ISP have dinamic IP.
pamoxi
 
Posts: 9
Joined: Sat Oct 13, 2007 4:24 am

Re: Chess game

Postby dpayer » Thu Oct 18, 2007 6:24 am

pamoxi wrote:Hi David.

Is English the official language for this site?
or we can write in spanish too?

Because my english is not very good...

Recomendation: for TCP connections I think that this not would be only IP to IP, here in Argentina the 80% of ISP have dinamic IP.


Do services like the free VPN program Hamachi work in Argentina? (http://hamachi.cc or http://logmein.com)

If so, you can make a VPN between players using their free client and then all data is shared as if you are on a lan. It could be a problem with double NATs though (ISP does NATting and your own router does it as well).

David P.
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

CHESSTER - fully functional Chess game using Neobook

Postby RickOShay » Wed Feb 17, 2010 8:46 am

I know this thread is rather old but I have just completed an entire chess game with integrated chess engine. See the new Pub release entitled Chesster. I decided not to release the source code due to the 2 months of hard work I put into it. What will come as a surprise is that Neobook was used to handle all aspects of the GUI and human move authentication.

This is by no means a simple task - but Neobook handled the process exceptionally well. The power of Neobook never ceases to amaze me. I am more than prepared to help should you want to know how individual chess pieces are controlled and human move authentication is handled in this program as well as issues such as drag and drop pre processing, conditional moves, check state, piece rules, FEN string creation etc.

Anyway the offer is there should anyone need a little help. I learnt a lot in the process of building Chesster and have now discovered ways to create many games based on a similar process.
Last edited by RickOShay on Sun Aug 15, 2010 8:17 am, edited 2 times in total.
There's no place like 127.0.0.1

http://www.farenheit451.net
User avatar
RickOShay
 
Posts: 22
Joined: Sun Jul 27, 2008 5:59 am
Location: Cape Town, SA

Postby cp4w » Wed Feb 17, 2010 10:40 am

as well as issues such as drag and drop pre processing

I noticed it in the Resources and it looked great.
Thanks for the offer.

Maybe you would like to share some general snippets or concept, like the one mentioned above.

Thanks
cp4w
 
Posts: 533
Joined: Sun Apr 03, 2005 4:37 pm
Location: Great Neck, NY

Postby Neosoft Support » Wed Feb 17, 2010 10:44 am

Wow! Nice job!
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Chesster

Postby RickOShay » Wed Feb 17, 2010 1:55 pm

To illustrate how the basic drag and drop move rules are applied in Chesster i.e. prior to the moved piece actually being dropped - condition (DropAccept = True) you will need to go through a bit of a setup.

Ok after creating the board graphic each cell has a rectangle named according to the algebraic notation starting bottom left a1 through to h8 (top rhs). 64 cell rectangles in total. They need to be aligned so that they correspond perfectly to each square on the board.

These rectangles are used to indicate what cell a piece has been dropped on (assuming it does not have a piece on top of it - in which case the reported drop target would be a piece not a cell address = possible capture). In this instance where a Polygon object (piece) is positioned over a cell rectangle then the routine has to first determine its position, colour, it's legality, does check condition exist if so will move result in nullifying the check if not move is false plus a quite a few other issues all in the space of a split second as the piece is being dropped on the target cell or piece. So whilst the subroutine may seem quite long it has many exit points and areas which are conditionally skipped. Chess is a complex game and a pawn move is far more complex than the simple rook routine shown below.

Ok first setup some pieces (you may want to do just the rook) - which as mentioned are polygon hotspots, positioned on top of the cell rectangles. These hotspots are named as follows : (starting bottom left) WR1,WN2,WB3,WQ4,WK5,WB6,WN7,WR8. These polygon hotspots have graphics associated to them - they are png files since png supports transparency.

The second row containing the white pawns are: Reading Left to right - WP9,WP10,WP11,WP12,WP13,WP14,WP15,WP16. The black pieces are similarly polygon hotspots with associated graphics. On row 8 we have the black : br17,bn18,bb19,bq20,bk21,bb22,bn23,br24. On row 7 we have the black pawns : bp25,bp26,bp27,bp28,bp29,bp30,bp31,bp32. A total of 32 pieces in all. The numbering I have indicated is important.

Note all polygons containing pieces are transparent and set drag and drop to manual. Under Drag and Drop on the polygon for the rook add the following : (example for the the white rook polygon object bottom left on rectangle a1):

Setvar "[CP]" "1"
Gosub "MoveRNBQ"

Create a listbox somewhere off the program visible area called :
RuleLref containing a list of all cells on the board a1,b1,c1,d1,e1,f1,g1,h1,a2,b2,c2,d2,e2,f2,g2,h2,a3,b3...etc (all 64 cells)
This listbox is used to look up the line number of the rules in the files mentioned below.

Create another listbox called Colnum and put A,B,C,D,E,F,G,H on 8 lines. Used to convert colletter to [colnum].

Create another listbox called Coord with the cell (rectangle) coords on each line. This is the centre position of each rectangle (left,top) eg.
133,614
133,550
133,486
133,422
You can easily get the centre position of a rectangle object by selecting it and then looking at the right at the Object Information panel in Neobook and adding half the width to the left pos and half the height to the top pos. You'll need 64 pairs in total, one pair per line if you are doing the entire board etc.

Create another listbox called Cell and store a1,a2,a3,a4,a5,a6,a7,a8,b1,b2,b3,b4,b5 etc 64 cells - 1 per line. The coords must match the line numbers and cells above. Used for look up or cell address and move coords etc.

Create another listbox called 'Pabrev' put P,R,N,B,Q,K on 6 lines (1 letter per line).

Create one last listbox called 'Types' and store: Porn,Rook,Knight,Bishop,Queen,King on 6 lines 1 per line obviously leave out the ',' as before. These last 2 LB's are used to convert piece names to abreviated letter or visa versa and to pick up the long name for text to speech. Hence the spelling of the word Porn - rather than Pawn! (In case you were wondering ]-))

In the startup of the program you need to add the following. Note you need to d/l Chesster and find these files in the program folder. You'll need RLM.txt V&HLM.txt and lines.txt - for the Rook demo below. These files store cell mapping, rays and move legality (drop targets). Put them in the pub folder. A ray is a contiguous group of neighboring cells starting at the piece position and branching out to the edge of the board. There are 2 types of rays diagonal and V&H. Rooks obviously move in the V&H plain. You will notice that the V&HLM.txt file contains all cells on the board - the routine looks up the current piece position and then loads the respective ray line. It parses rays based on the ; seperator. Then checks the contents of each cell sequentially from piece pos to the last cell in the ray. Cells in the middle will obviously have 4 V&H rays, cells on the side will have 3 and corner cells have 2. Rays are needed to limit piece movement if the intermediary cells are occupied.

Example: Lets say you try to (accidentally?) move a rook from a1 to a5 and there is a piece on a4 - testing for contiguous empty cells is necessary to prevent invalid Drop acceptance i.e. the cell exists in the valid move or drop target list. In testing check condition all contiguous cells in a ray from K to enemy piece X (opposite color) need to be tested to see if they are empty or contain a piece. A King on e8 would obviously not be in check if there was an enemy rook on e2 - if a friendly piece occupied e5 for example.

Program startup:

Code: Select all
...LOAD RULES ............................................................

FileToVar "[PubDir]lines.txt" "[Lines]"
...............................................................

....setup pieces
Setvar "[CP]" "1"
Setvar "[[CP]objname]" "wr1"
Setvar "[[CP]pos]" "A1"
Setvar "[[CP]type]" "R"
Setvar "[a1]" "wr1"

Setvar "[CP]" "2"
Setvar "[[CP]objname]" "wn2"
Setvar "[[CP]pos]" "B1"
Setvar "[[CP]type]" "N"
Setvar "[b1]" "wn2"

Setvar "[CP]" "3"
Setvar "[[CP]objname]" "wb3"
Setvar "[[CP]pos]" "C1"
Setvar "[[CP]type]" "B"
Setvar "[c1]" "wb3"

...............................................................


You only really need the first one for the Rook under setup pieces in startup.

Here's the subroutine for move validation of a Rook: (it's also used for Knight, Bishop and the Queen both white and Black) Note a Knight is referenced as N due to King.

(This is a slightly simplified routine for demonstration and will need to be tweaked quite a bit for it to work - I assume you will get the gist of how this works by removing all calls to other subs that are not included etc. I just don't have the time to create a stripped down working version right now. Sorry it's not too neat and there are some lines / routines that I'm sure could be optimized. Chesster has over 3500 lines of code and it was a lot of work to complete this in 2 months along with graphics etc.

Code: Select all
:MoveRNBQ

Setvar "[Capiece]" ""
Setvar "[DTfound]" ""
Setvar "[Capcolor]" ""
Setvar "[Capiece]" ""
Setvar "[CapCP]" ""
Setvar "[Captype]" ""
Setvar "[[cp]LegalMoves]" ""

...moved piece
Setvar "[Movedpiece]" "[[cp]objname]"
..movedpiecetype =
Setvar "[movedpiecetype]" "[[cp]type]"
ListBoxFindItem "Pabrev" "[movedpiecetype]" "[MovedpiecetypeLnum]"
ListBoxGetItem "types" "[MovedpiecetypeLnum]" "[movedpiecename]"
SubStr "[[cp]objname]" "1" "1" "[Movedpiececolor]"

If "[[cp]type]" "=" "R"
ListBoxFindItem "RuleLref" "[[cp]pos]" "[[cp]LMline]"
IfEx "[[cp]LMline] = 0 or [[cp]LMline] = [#34][#34]"
SetVar "[DropAccept]" "False"
Return
Endif
FileRead "C:\Dev\Chess\RLM.txt" "[[cp]LMline]" "[[cp]LegalMoves]"
StrReplace "[[cp]LegalMoves]" "[[cp]pos]:" "" "[[cp]LegalMoves]" ""
Endif

If "[[cp]type]" "=" "B"
ListBoxFindItem "RuleLref" "[[cp]pos]" "[[cp]LMline]"
IfEx "[[cp]LMline] = 0 or [[cp]LMline] = [#34][#34]"
SetVar "[DropAccept]" "False"
Return
Endif
FileRead "C:\Dev\Chess\BLM.txt" "[[cp]LMline]" "[[cp]LegalMoves]"
StrReplace "[[cp]LegalMoves]" "[[cp]pos]:" "" "[[cp]LegalMoves]" ""
Endif

If "[[cp]type]" "=" "N"
ListBoxFindItem "RuleLref" "[[cp]pos]" "[[cp]LMline]"
IfEx "[[cp]LMline] = 0 or [[cp]LMline] = [#34][#34]"
SetVar "[DropAccept]" "False"
Return
Endif
FileRead "C:\Dev\Chess\NLM.txt" "[[cp]LMline]" "[[cp]LegalMoves]"
StrReplace "[[cp]LegalMoves]" "[[cp]pos]:" "" "[[cp]LegalMoves]" ""
Endif

If "[[cp]type]" "=" "Q"
ListBoxFindItem "RuleLref" "[[cp]pos]" "[[cp]LMline]"
IfEx "[[cp]LMline] = 0 or [[cp]LMline] = [#34][#34]"
SetVar "[DropAccept]" "False"
Return
Endif
FileRead "C:\Dev\Chess\QLM.txt" "[[cp]LMline]" "[[cp]LegalMoves]"
StrReplace "[[cp]LegalMoves]" "[[cp]pos]:" "" "[[cp]LegalMoves]" ""
Endif

...find start cell by searching for object
Loop "1" "8" "[x]"
If "[a[x]]" "=" "[[CP]objname]"
setvar "[FromCell]" "a[x]"
Exitloop
Endif
If "[b[x]]" "=" "[[CP]objname]"
setvar "[FromCell]" "b[x]"
Exitloop
Endif
If "[c[x]]" "=" "[[CP]objname]"
setvar "[FromCell]" "c[x]"
Exitloop
Endif
If "[d[x]]" "=" "[[CP]objname]"
setvar "[FromCell]" "d[x]"
Exitloop
Endif
If "[e[x]]" "=" "[[CP]objname]"
setvar "[FromCell]" "e[x]"
Exitloop
Endif
If "[f[x]]" "=" "[[CP]objname]"
setvar "[FromCell]" "f[x]"
Exitloop
Endif
If "[g[x]]" "=" "[[CP]objname]"
setvar "[FromCell]" "g[x]"
Exitloop
Endif
If "[h[x]]" "=" "[[CP]objname]"
setvar "[FromCell]" "h[x]"
Exitloop
Endif
Endloop

Setvar "[[cp]pos]" "[FromCell]"
SubStr "[FromCell]" "1" "1" "[Fromcellcol]"
ListBoxFindItem "colnum" "[Fromcellcol]" "[Fromcellcolnum]"
SubStr "[[cp]pos]" "2" "1" "[Fromcellrow]"

..Now get ToCell

..if Droptarget is a cell
ListBoxFindItem "Cell" "[Droptarget]" "[DTline]"

If "[DTline]" ">" "0"
Setvar "[Tocell]" "[Droptarget]"
..yes it is a cell
SubStr "[ToCell]" "2" "1" "[Tocellrow]"
SubStr "[DropTarget]" "1" "1" "[Tocellcol]"
ListBoxFindItem "colnum" "[Tocellcol]" "[Tocellcolnum]"

.............FROM TO cells done............................

Else

...if Droptarget is a piece find cell
Loop "1" "8" "[x]"
If "[a[x]]" "=" "[DropTarget]"
setvar "[ToCell]" "a[x]"
Setvar "[Capiece]" "[DropTarget]"
Exitloop
Endif
If "[b[x]]" "=" "[DropTarget]"
setvar "[ToCell]" "b[x]"
Setvar "[Capiece]" "[DropTarget]"
Exitloop
Endif
If "[c[x]]" "=" "[DropTarget]"
setvar "[ToCell]" "c[x]"
Setvar "[Capiece]" "[DropTarget]"
Exitloop
Endif
If "[d[x]]" "=" "[DropTarget]"
setvar "[ToCell]" "d[x]"
Setvar "[Capiece]" "[DropTarget]"
Exitloop
Endif
If "[e[x]]" "=" "[DropTarget]"
setvar "[ToCell]" "e[x]"
Setvar "[Capiece]" "[DropTarget]"
Exitloop
Endif
If "[f[x]]" "=" "[DropTarget]"
setvar "[ToCell]" "f[x]"
Setvar "[Capiece]" "[DropTarget]"
Exitloop
Endif
If "[g[x]]" "=" "[DropTarget]"
setvar "[ToCell]" "g[x]"
Setvar "[Capiece]" "[DropTarget]"
Exitloop
Endif
If "[h[x]]" "=" "[DropTarget]"
setvar "[ToCell]" "h[x]"
Setvar "[Capiece]" "[DropTarget]"
Exitloop
Endif
Endloop

SubStr "[Tocell]" "2" "1" "[Tocellrow]"
SubStr "[Tocell]" "1" "1" "[Tocellcol]"
ListBoxFindItem "colnum" "[Tocellcol]" "[Tocellcolnum]"
SubStr "[Capiece]" "1" "1" "[Capcolor]"
SubStr "[Capiece]" "3" "2" "[CapCP]"
Setvar "[Captype]" "[[CapCP]type]"
ListBoxFindItem "Pabrev" "[Captype]" "[CaptypeLnum]"
ListBoxGetItem "types" "[CaptypeLnum]" "[Capiecename]"
Setvar "[lastmove]" "Capture"

If "[Movedpiececolor]" "=" "[Capcolor]"
SetVar "[DropAccept]" "False"
Return
Endif

Endif

...END CAPTURE

SearchStr "[Tocell]" "[[cp]LegalMoves]" "[DTfound]" ""
IfEx "[DTfound] > 0"

If "[movedpiecetype]" "<>" "N"
..check if intermediary cells occupied [LMcell[n]] [LMn] .......................................
ListBoxFindItem "RuleLref" "[[cp]pos]" "[[cp]LMline]"

IfEx "[Fromcellrow] <> [Tocellrow] and [Fromcellcol] <> [Tocellcol]"
FileRead "C:\Dev\Chess\DiagLM.txt" "[[cp]LMline]" "[[cp]rays]"
StrReplace "[[cp]rays]" "[[cp]pos]:" "" "[[cp]rays]" ""
StrParse "[[cp]rays]" ";" "[ray]" "[r]"
Else
FileRead "C:\Dev\Chess\V&HLM.txt" "[[cp]LMline]" "[[cp]rays]"
StrReplace "[[cp]rays]" "[[cp]pos]:" "" "[[cp]rays]" ""
StrParse "[[cp]rays]" ";" "[ray]" "[r]"
Endif

..which ray
Loop "1" "[r]" "[x]"
SearchStr "[Tocell]" "[ray[x]]" "[Tocellfound]" ""
If "[Tocellfound]" ">" "0"
Setvar "[raynum]" "[x]"
Exitloop
Endif
Endloop

..is intermediary cell in ray occupied if so illegal
StrParse "[ray[raynum]]" "," "[raycell]" "[n]"

Loop "1" "[n]" "[y]"
IfEx "[raycell[y]] <> [Tocell] and [[raycell[y]]] > [#34][#34]"
SetVar "[DropAccept]" "False"
Return
Else
..must be valid ..............END Intermediary cell test...............................
If "[raycell[y]]" "=" "[Tocell]"
Exitloop
Endif
Endif
Endloop

Endif

..does check condition still exist after move....................
Setvar "[[CP]Oldpos]" "[Fromcell]"
Setvar "[TocellOld]" "[[Tocell]]"
Setvar "[[Fromcell]]" ""
Setvar "[[TOcell]]" "[[CP]Objname]"
..simulate move and test for check
Setvar "[[CP]pos]" "[Tocell]"
GoSub "Check[Movedpiececolor]K"
If "[[Movedpiececolor]check]" ">" ""
Setvar "[Fromcell]" "[[CP]Oldpos]"
Setvar "[[CP]pos]" "[[CP]Oldpos]"
Setvar "[[Fromcell]]" "[[CP]Objname]"
Setvar "[[Tocell]]" "[TocellOld]"
SetVar "[DropAccept]" "False"
Return
Else
Setvar "[[Movedpiececolor]check]" ""
Endif
Setvar "[[Fromcell]]" "[[CP]Objname]"
Setvar "[[Tocell]]" "[TocellOld]"

...ok so ray is unoccupied from FROM pos to TO pos
SetVar "[DropAccept]" "True"
Setvar "[[cp]pos]" "[Tocell]"
Setvar "[[Fromcell]]" ""
Setvar "[[Tocell]]" "[[cp]objname]"

IfEx "[Capiece] > [#34][#34] and [Capcolor] <> [Movedpiececolor]"
HideObject "[Capiece]" "None" "0"
GoSub "Captotals"
Setvar "[lastmove]" "Capture"
Endif

IfEx "[lastmove] = [#34][#34] or [lastmove] = Capture"
Setvar "[lastmove]" "Move"
Endif

SetVar "[DropAccept]" "False"
ListBoxFindItem "Cell" "[Tocell]" "[TocellLnum]"
ListBoxGetItem "Coord" "[TocellLnum]" "[ToCellcoord]"
MoveObjectAlongPath "[[cp]objname]" "[ToCellcoord]" "0" "Wait+Center" ""

..update some FEN string data
Setvar "[halfmove]" "[halfmove]+1"
Setvar "[en]" "-"

..(this bit is for storing the scolling move history text - create a text entry box with 'Variable to store text entry' set to [move] and stick it on the page)

If "[turn]" "=" "white"
Setvar "[space]" ""
GoSub "CheckBK"
GoSub "DisableWhite"
GoSub "EnableBlack"
GoSub "WTimer"
Setvar "[turn]" "black"
If "[Capiece]" ">" "[#34][#34]"
Setvar "[move]" "[move][Movenumber]. [[CP]type] [Fromcell] X [Captype] [Tocell] [CEP] [checkM][#13]"
Setvar "[saymove]" "[movedpiecename] captures [Capiecename] [EP]. [Fromcell] to [Tocell]. [bcheck]"
Else
Setvar "[move]" "[move][Movenumber]. [[CP]type] [Fromcell] - [Tocell] [checkM][#13]"
Setvar "[saymove]" "[movedpiecename] [Fromcell] to [Tocell]. [bcheck]"
Endif

Else

GoSub "CheckWK"
GoSub "EnableWhite"
GoSub "DisableBlack"
GoSub "BTimer"
Setvar "[turn]" "white"
Setvar "[Movenumber]" "[Movenumber]+1"
If "[Capiece]" ">" "[#34][#34]"
Setvar "[move]" "[move]                                 [[CP]type] [Fromcell] X [Captype] [Tocell] [CEP] [checkM][#13]"
Setvar "[saymove]" "[movedpiecename] captures [Capiecename] [EP]. [Fromcell] to [Tocell]. [wcheck]"
Else
Setvar "[move]" "[move]                                 [[CP]type] [Fromcell] - [Tocell] [checkM][#13]"
Setvar "[saymove]" "[movedpiecename] [Fromcell] to [Tocell]. [wcheck]"
Endif
Endif

...if rook moved change fen and stop castle on side rook moved
IfEx "[[cp]objname] = WR1 and [Wcast] > [#34][#34]"
Setvar "[WR1moved]" "True"
StrReplace "[Wcast]" "Q" "" "[Wcast]" ""
Endif
IfEX "[[cp]objname] = WR8 and [Wcast] > [#34][#34]"
Setvar "[WR8moved]" "True"
StrReplace "[Wcast]" "K" "" "[Wcast]" ""
Endif
IfEx "[[cp]objname] = BR17 and [Bcast] > [#34][#34]"
Setvar "[BR17moved]" "True"
StrReplace "[Bcast]" "q" "" "[Bcast]" ""
Endif
IfEx "[[cp]objname] = BR24 and [Bcast] > [#34][#34]"
Setvar "[BR24moved]" "True"
StrReplace "[Bcast]" "k" "" "[Bcast]" ""
Endif

Gosub "FEN"

If "[speak]" "=" "Checked"
Mat_Speech_Speak "[saymove]" "2"
Else
PlaySoundFile "D:\sound effects\blip.wav" "Normal"
Endif

..output and add the move to the game file.
FileWrite "[gamname]" "Append" "[Fromcell]-[Tocell][promT]"

..if the player is playing the computer do this
IfEx "[AIgame] = True and [AIplays] = white and [turn] = white"
Gosub "AIWmove"
Else
Setvar "[AImove]" "False"
Endif
IfEx "[AIgame] = True and [AIplays] = black and [turn] = black"
Gosub "AIBmove"
Else
Setvar "[AImove]" "False"
Endif

Else
SetVar "[DropAccept]" "False"
Endif

Return


Ok so there's a lot of extra stuff and some I have removed but you should get the point of what is involved.

The key is mapping cell names to variables with the same name [a1] [a2] etc and the pieces are named with the [cp] value at the end so WR1 is white Rook and the 1 is the [cp] variable name used to interrogate variables [[cp]type] [[cp]color] [[cp]objname] - note the [[cp]type is needed since in pawns they might be promoted to QRN or B.

Anyway I hope this is of some help and its not too confusing. I tried many different ways - the above process obviously limits drops 'off board' and the use of ray files is a simple way to determine horizontal and vertical and diag move legality.

Regards

Mike
There's no place like 127.0.0.1

http://www.farenheit451.net
User avatar
RickOShay
 
Posts: 22
Joined: Sun Jul 27, 2008 5:59 am
Location: Cape Town, SA


Return to Distributing, Marketing and Selling NeoBook Applications

Who is online

Users browsing this forum: No registered users and 1 guest