Ir al contenido


Foto

crear un robot


  • Por favor identifícate para responder
18 respuestas en este tema

#1 alextruenobur

alextruenobur

    Newbie

  • Miembros
  • Pip
  • 5 mensajes
  • Locationvenezuela

Escrito 20 mayo 2009 - 02:28

Realice una simulacion de un robot formador de palabras.

1. El usuario introducira un maximo de diez palabras
2. La palabras se esparciran letra por letra de forma aleatoria en el tablero.
3. El tablero contara con un minimo de 3 obstaculos y un maximo de 12 , cuyo valor del rango sera aleatorio
4. Las dimensiones del tablero son de acuerdo a la comodidad del programador
5.El resto del tablero se llenara con espacios en blanco
6.El robot no saldra del tablero
7.El robot debe ser visible en todo momento
8 El algoritmo de busqueda se caracteriza por empezar a formar la primera palabra que introdujo el usuario moviendose siempre a la letra correspondiente mas cercana.
9 El robot no podra tocar un obtaculo.
10. Las letras seleccionadas no podran formar parte de otra solucion de palabra
11. El juego termina cuando el robot forme todas las palabras o cuando el usuario desee salir..... 

me puedes responder esto por favor

cualquier cosa aqui le dejo mi correo:: xxxxx@xxxxx.com


  • 0

#2 poliburro

poliburro

    Advanced Member

  • Administrador
  • 4.945 mensajes
  • LocationMéxico

Escrito 20 mayo 2009 - 02:41


me puedes responder esto por favor


Claro, cuál es la pregunta?


  • 0

#3 eduarcol

eduarcol

    Advanced Member

  • Administrador
  • 4.483 mensajes
  • LocationVenezuela

Escrito 20 mayo 2009 - 03:54

Hola Alex, vamos a ayudarte, pero dime mas o menos que necesitas saber, o es una tarea y no tienes ni la mas remota idea de por donde comenzar??
  • 0

#4 Delphius

Delphius

    Advanced Member

  • Administrador
  • 6.295 mensajes
  • LocationArgentina

Escrito 20 mayo 2009 - 09:28

Hola alextruenobur,
¡Bienvenido a DelphiAccess!

Creo que serí­a más apropiado a que tu vayas exponiendo tus avances y tus dudas e inquietudes, en la medida en que continúes y surjan las dudas te asistimos. ¿Te parece?

En lo personal, considero que es mucho más fructí­fero y productivo que uno mismo haga el trabajo, con un poco de guia y asesoramiento a que esperar a que le hicieran la "tarea".

Por otro lado... no es bueno que expusieras tu e-mail. Hay muchos boots y demás "bichos" navegando por toda la red buscando direcciones de correo electrónico a fin de propagar y vender más spam.
Además que se busca fomentar la participación abierta y de toda la comunidad.

Saludos,
  • 0

#5 poliburro

poliburro

    Advanced Member

  • Administrador
  • 4.945 mensajes
  • LocationMéxico

Escrito 21 mayo 2009 - 07:47

Más bien creo que se trata de una confusión del compañero. Me llegó un correo con su pregunta podrí­a ser que aún no maneja bien el foro.

cito su pregunta:

la pregunta es la siguiente tengo q formar una simulacion de un robot formador de palabras tambien saber los algoritmo generales q se utilizaron para realizar dicho programa una estructura de datos un planteamiento del problema una descripcion de funciones y procedimiento....??? claro todo esto despues de aver creado el dicho programa esto es un informe del mismo... !!!! la verdad no lo se crear y me gustaria q me orientaran un poco tampoco se tata de q me hagan la tarea bueno con mucho respeto me dirijo y me despido



  • 0

#6 root

root

    mister

  • Miembro Platino
  • PipPipPip
  • 529 mensajes
  • LocationMexico D.F:

Escrito 21 mayo 2009 - 09:01

yo preguntaria
cual es el objeto de esto ???
  • 0

#7 egostar

egostar

    missing my father, I love my mother.

  • Administrador
  • 14.448 mensajes
  • LocationMéxico

Escrito 21 mayo 2009 - 09:34

Hola

Me imagino que lo que le piden es algo como esto:

Imagen Enviada

Salud OS
  • 0

#8 Delphius

Delphius

    Advanced Member

  • Administrador
  • 6.295 mensajes
  • LocationArgentina

Escrito 21 mayo 2009 - 09:41

Hola alextruenobur,
Disculpa si mis palabras te resultaron ofensivas, es necesario que comprendas que no todo podemos resolverte y que es fundamental la participación y predisposición del interesado para poder avanzar.

La cuestión es que nos brindas ciertos lineamientos y esperas que en base a ellos te propongamos una solución o alternativa. Y esto puede ser contraproducente para ti. Nuestras propuestas pueden llegar a ser lo suficientemente compleja como para que tu la entiendas.
En cambio, si tuviéramos algún elemento base con el cual podamos comenzar, se hace más fácil proponerte diseños, soluciones y alternativas.

Dices que no tienes ideas de como enfocar el trabajo... Me cuesta creer que no tengas al menos un bosquejo simple en mente... algo "visual".
Partamos de algo fundamental: ¿Qué tan amplios o básicos son tus conocimientos de programación en general y sobre Delphi?

No es por ser malo pero deberí­as hacer un esfuerzo para visualizar el problema en una apreciación general, ya después se puede ir analizando punto a punto a fin de ajustar el diseño. Piensa un poco... que de todo esos puntos es lo más crí­tico, lo central y necesario. Lo que debe ser suficientemente estable... ¿el robot, el tablero, el algoritmo de búsqueda, las palabras, los obstáculos? Que es lo más importante?
En base a ellos se puede enfocar el pensamiento y ver como unir las ideas.

Una pregunta que puede serte útil: ¿Qué estructuras de datos consideras que pueden ser de utilidad para llevar una representación abstracta y/o visual de un tablero? Idem para el caso de la lista de palabras.

Saludos,
  • 0

#9 Delphius

Delphius

    Advanced Member

  • Administrador
  • 6.295 mensajes
  • LocationArgentina

Escrito 21 mayo 2009 - 09:48

Hola egostar... yo no creo que sea algo parecido al scrable (¿se escribe así­?).
A como interpreto la "consigna", las letras se distribuyen de forma aleatoria. Por ejemplo, para la palabra HOLA la H en (1,5), O en (6,9), L en (4,2) y A en (10, 8). Luego el robot va desplazándose "cuadro" a "cuadro" fijándose si la letra que encuentra le sirve para formar la palabra.

El algoritmo de búsqueda puede ser los suficientemente como una "fuerza bruta", que no tenga memoria y se recorra todo el tablero hasta lograr todas las palabras... como se lo puede diseñar con cierta inteligencia como ir recordando la ubicación de ciertas letras y optar por ir el camino más corto hasta las mismas.

Saludos,
  • 0

#10 alextruenobur

alextruenobur

    Newbie

  • Miembros
  • Pip
  • 5 mensajes
  • Locationvenezuela

Escrito 21 mayo 2009 - 04:09

esta es mas o menos la idea que tengo para realizar un robot en pascal formador de palabras:

pueden ayudarme a corregir errores por favor no pude compilar



delphi
  1. Type tiletype
  2. Field x
  3. Field y
  4. Field tilenum
  5. End Type
  6.  
  7. Type word
  8. Field wordstring$
  9. Field startx,starty,endx,endy
  10. Field points
  11. Field id
  12. Field playernum
  13. End Type
  14.  
  15. Type Info
  16. Field txt$
  17. End Type
  18.  
  19. Type player
  20. Field name$
  21. Field net_id
  22. Field playernum
  23. End Type
  24.  
  25. Type coltype
  26. Field r,g,b
  27. End Type
  28.  
  29. Const MSG_RECVBAG = 1 ; incoming bag of tiles and tilesused
  30. Const MSG_RECVTILES = 2 ; incoming tiles/word
  31. Const MSG_CLEARTILES = 3 ; word was rejected clear tiles from board
  32. Const MSG_RECVSYNC = 4 ; new player receives all info
  33. Const MSG_CHAT = 5 ; text messages
  34. Const MSG_PLACETILES = 6 ; word accepted - place it on board
  35. Const MSG_NEXTPLAYER = 7 ; turn complete - pass it to next player
  36. Const MSG_SYNCME = 8 ; request for bag, tilesused and a playernum
  37. Const MSG_CONFIRM = 9 ; ask for a y/n true false response
  38. Const MSG_ACC_REJ = 10 ; the y/n response
  39. Const MSG_RECVWORDS = 11 ; list of words and locations - for synch up
  40. Const MSG_MAPPING = 12 ; net_id - playernum mapping
  41. Const MSG_SCORE = 13 ; game is over, final score
  42. Const MSG_NEWPLAYER = 100
  43. Const MSG_PLAYERQUIT = 101
  44. Const MSG_NEWHOST = 102
  45. Const MSG_SESSIONLOST = 200
  46.  
  47. Const MAXPLAYERS = 4
  48. Const MSGTICKS = 100 ; number of ticks that the message is displayed
  49.  
  50. Global numplayers = 1
  51. Global mynum = -5 ; my turn number set to 0 to 3; 0 is the host
  52. Global playernum = 0 ; cycles 0,1,0,1... or 0,1,2,0,1,2... or 0,1,2,3,0,1,2,3
  53. Global tilesused = 0  ; 0-100
  54. Global rowcol = 0 ; 1 = col, 2 = row
  55. Global tilesplaced ; 0-7
  56. Global turnscore ; score for the current turn
  57. Dim totalscore(4) ; total scores for all players
  58. Global exmode=False
  59. Global showmess
  60. Global mess$ ;
  61. Global numwords ; number of words played
  62. Global holdingtile
  63. Global tileheld
  64. Global quit
  65. Global multiplay=0
  66. Global nsync=False
  67. Global gameover=False
  68. Global numrsvps
  69. Dim reply(4)
  70. Global chat$
  71. Global passed = 0
  72. Dim playeralive(4)
  73. Global scoresent=False
  74. Global imhost = False
  75. Global singleplayer
  76.  
  77. Global showpanel ; toggle 0,1,2,...  words, tiles, points, ...
  78. Global numpanels = 3  ; 4 for debug
  79. Dim tpw$(4) ; tile points words panels
  80. tpw$(0) = "Show Tile List"
  81. tpw$(1) = "Show Point List"
  82. If numpanels = 3
  83. tpw$(2) = "Show Word List"
  84. Else
  85. tpw$(2) = "Show Bag Tiles"  ; for debug - show list of tiles in bag
  86. tpw$(3) = "Show Word List"
  87. EndIf
  88.  
  89. Dim pcol.coltype(4)
  90. For t = 0 To 3
  91. pcol.coltype(t) = New coltype
  92. Read pcol(t)\r
  93. Read pcol(t)\g
  94. Read pcol(t)\b
  95. Next
  96. ; player color data r,g,b
  97. Data 0,100,255
  98. Data 255,255,100
  99. Data 255,100,255
  100. Data 100,255,100
  101.  
  102. Dim boardbg(15,15)
  103. Dim boardt(15,15)
  104.  
  105. For x=0 To 14
  106. For y = 0 To 14
  107. Read boardbg(x,y)
  108. Next
  109. Next
  110. ;star=0,dw,tw,dl,tl=4,b=5
  111. Data 2,5,5,3,5,5,5,2,5,5,5,3,5,5,2
  112. Data 5,1,5,5,5,4,5,5,5,4,5,5,5,1,5
  113. Data 5,5,1,5,5,5,3,5,3,5,5,5,1,5,5
  114. Data 3,5,5,1,5,5,5,3,5,5,5,1,5,5,3
  115. Data 5,5,5,5,1,5,5,5,5,5,1,5,5,5,5
  116. Data 5,4,5,5,5,4,5,5,5,4,5,5,5,4,5
  117. Data 5,5,3,5,5,5,3,5,3,5,5,5,3,5,5
  118. Data 2,5,5,3,5,5,5,0,5,5,5,3,5,5,2
  119. Data 5,5,3,5,5,5,3,5,3,5,5,5,3,5,5
  120. Data 5,4,5,5,5,4,5,5,5,4,5,5,5,4,5
  121. Data 5,5,5,5,1,5,5,5,5,5,1,5,5,5,5
  122. Data 3,5,5,1,5,5,5,3,5,5,5,1,5,5,3
  123. Data 5,5,1,5,5,5,3,5,3,5,5,5,1,5,5
  124. Data 5,1,5,5,5,4,5,5,5,4,5,5,5,1,5
  125. Data 2,5,5,3,5,5,5,2,5,5,5,3,5,5,2
  126.  
  127. SeedRnd MilliSecs()
  128.  
  129. Dim distribution(27)
  130. Dim shuffled(100)
  131.  
  132. t=0
  133. For l = 0 To 26
  134. Read lcount
  135. distribution(l) = lcount
  136. For x = t To t + lcount-1
  137. shuffled(x) = l
  138. Next
  139. t=t+lcount
  140. Next
  141.  
  142. ; 100 tiles
  143. .distributiondata
  144. Data 9,2,2,4,12,2,3,2,9,1,1,4,2,6,8,2,1,6,4,6,4,2,2,1,2,1,2
  145.  
  146. Dim points(27)
  147. For t = 0 To 26
  148. Read points(t)
  149. Next
  150. ; points
  151. Data 1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,1,4,4,8,4,10,0
  152.  
  153. Dim rack(12),exrack(12)
  154.  
  155. Global menux=18*33
  156. Global menuy=15*33+10
  157.  
  158. ; Set up display:
  159. Graphics 800,600,32,2
  160.  
  161. ; Load images:
  162. Global letters = LoadAnimImage ("letters.bmp",32,32,0,70)
  163. Global pointer = LoadAnimImage ("pointer.bmp",32,32,0,1)
  164.  
  165.  
  166. SetBuffer BackBuffer()
  167. DoIntro()
  168.  
  169. SetBuffer FrontBuffer()
  170. ;get player name
  171. Cls
  172. Color 255,255,255
  173. Text 16,116,"Player name?"
  174. Locate 16,132
  175. Repeat
  176. name$=Input$()
  177. Until name$<>""
  178.  
  179. FlushKeys()
  180.  
  181. ; single or mutiplayer game?
  182. Text 16,148,"Single Player Game? Y/N"
  183. answer=0
  184. Repeat
  185. Delay 1
  186. If KeyHit(21) Then answer = 1 ; Y
  187. If KeyHit(49) Then answer = -1; N
  188. Until answer <> 0
  189. If answer = 1
  190. singleplayer = True
  191. EndIf
  192.  
  193.  
  194. If singleplayer = False
  195. multiplay = StartNetGame()
  196. Else
  197. multiplay = 2
  198. EndIf
  199. ;create a local player
  200. Global player.player = New player
  201. player\name=name$
  202. If singleplayer = False
  203. player\net_id=CreateNetPlayer( name$ )
  204. Else
  205. player\net_id=0
  206. EndIf
  207. player\playernum = 0 ; the only place the host playernum gets assigned
  208.  
  209. For t = 0 To 3:playeralive(t)=False:Next
  210.  
  211. If multiplay = 2 ;=2 created new game
  212. tilesused = 0
  213. mynum = 0
  214. imhost = True
  215. playeralive(0) = True
  216. ShuffleTiles()
  217. ClearBoard()
  218. ClearRack()
  219. RefillRack()
  220. ElseIf multiplay = 1
  221. ;=1 joining a game
  222. ClearBoard()
  223. ClearRack()
  224. ; send this request when joining a game
  225. SendNetMsg 8,"Sync me up!",player\net_id,0,0
  226. cnt = 0
  227. While nsync=False Or mynum=-5
  228. ; get bag of tiles and tilesused and mynum
  229. GetNetMessages()
  230. cnt = cnt+1
  231. Delay 10
  232. ; try again?
  233. If cnt > 100 Then cnt=0:SendNetMsg 8,"Sync me up!",player\net_id,0,0
  234. Wend
  235. If mynum <0 ; (-1 returned - only 3 can join a game)
  236. Cls
  237. Text 16,16,"Host is not accepting any more players."
  238. Delay 4000
  239. End
  240. EndIf
  241. playeralive(mynum) = True
  242. RefillRack()
  243. SendBag()
  244. Else
  245. ; =0 couldn't start game
  246. Cls
  247. Text 16,16,"Could not start Game.(Multiplayer problem.)"
  248. Delay 4000
  249. End
  250. EndIf
  251.  
  252. holdingtile=False
  253. quit=False
  254. showpanel=0
  255. numwords=0
  256.  
  257. SetBuffer BackBuffer()
  258.  
  259.  
  260.  
  261. ; Main loop:
  262. Repeat
  263.  
  264. If MouseHit(1)
  265. x=MouseX()/33
  266. y=MouseY()/33
  267. If x>=0 And x < 15 And y>=0 And y< 15 And exmode=False And playernum = mynum
  268. tilethere = boardt(x,y)
  269. For tin.tiletype=Each tiletype
  270. If tin\x = x And tin\y = y Then tilethere=tin\tilenum
  271. Next
  272. Select tilethere
  273. Case -1
  274. ; nothing there
  275. If holdingtile = True
  276. ; action depends on how many tiles are down
  277. Select tilesplaced
  278. Case 0
  279. ; drop tile anywhere
  280. tin.tiletype=New tiletype
  281. tin\x = x
  282. tin\y = y
  283. tin\tilenum = tileheld
  284. tilesplaced = tilesplaced+1
  285. holdingtile=False
  286. Case 1
  287. ;drop tile here if same row or column
  288. tin.tiletype = First tiletype
  289. xfirst = tin\x
  290. If x = xfirst Or y= tin\y
  291. tin.tiletype=New tiletype
  292. tin\x = x
  293. tin\y = y
  294. tin\tilenum = tileheld
  295. tilesplaced = tilesplaced+1
  296. holdingtile=False
  297. ; next tile must be same row or column
  298. If x = xfirst Then rowcol = 1 Else rowcol = 2
  299. EndIf
  300. Default
  301. ; 3rd to 7th tiles - compare against the 1st
  302. tin.tiletype = First tiletype
  303. Select rowcol
  304. Case 1
  305. ; same column?
  306. If x = tin\x
  307. tin.tiletype=New tiletype
  308. tin\x = x
  309. tin\y = y
  310. tin\tilenum = tileheld
  311. tilesplaced = tilesplaced+1
  312. holdingtile=False
  313. Else
  314. showmess=MSGTICKS
  315. mess$="Must be in the same column or row!"
  316. EndIf
  317. Case 2
  318. ; same row?
  319. If y = tin\y
  320. tin.tiletype=New tiletype
  321. tin\x = x
  322. tin\y = y
  323. tin\tilenum = tileheld
  324. tilesplaced = tilesplaced+1
  325. holdingtile=False
  326. Else
  327. showmess=MSGTICKS
  328. mess$="Must be in the same row or column!"
  329. EndIf
  330. End Select
  331. End Select
  332. Else
  333. ; click on board while not holding a tile
  334. ; so do nothing ?
  335. EndIf
  336. Default
  337. If holdingtile = False
  338. ; can only pick up tiles we are placing this turn
  339. ; find the tile, remove it from board and hold it
  340. For tin.tiletype=Each tiletype
  341. If x = tin\x And y=tin\y
  342. holdingtile = True
  343. tileheld = tin\tilenum
  344. tilesplaced = tilesplaced - 1
  345. Delete tin
  346. EndIf
  347. Next
  348. Else
  349. ; there is a tile there, swap it with the one in hand
  350. If boardt(x,y)=-1
  351. For tin.tiletype=Each tiletype
  352. If tin\x = x And tin\y = y
  353. temp = tin\tilenum
  354. tin\tilenum = tileheld
  355. tileheld=temp
  356. EndIf
  357. Next
  358. Else
  359. ; can't swap with tiles placed in previous turns
  360. showmess=MSGTICKS
  361. mess$ = "Can't Overlap Tiles"
  362. EndIf
  363. EndIf
  364. End Select
  365. Else
  366. CheckMenu()
  367. CheckRack(x,y)
  368. EndIf
  369. EndIf
  370.  
  371. If singleplayer = False GetNetMessages()
  372. If singleplayer = False GetChatString()
  373.  
  374. If KeyDown (1)=1 ; ESC- quit?
  375. If Confirm("Quit") = True
  376. quit=True
  377. EndIf
  378. EndIf
  379.  
  380. DrawAll()
  381. ; show it....
  382. Flip
  383. counter = counter + 1
  384. ;If KeyHit(88) SaveBuffer(FrontBuffer(),"SNAPHOT"+counter+".bmp")
  385. VWait
  386.  
  387. Until quit=True
  388. End
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395. ;----------------------------------------------------------------------------------
  396. Function DrawAll()
  397. ; draw everything....
  398. Cls
  399. Color 255,255,255
  400. Rect 0,0,800,600,0
  401. DrawTiles()
  402. DrawScores()
  403. If singleplayer = False DrawChat()
  404. If holdingtile = True
  405. DrawBlock letters,MouseX()-14,MouseY()-14,35
  406. DrawBlock letters,MouseX()-15,MouseY()-15,35
  407. DrawBlock letters,MouseX()-16,MouseY()-16,tileheld
  408. EndIf
  409. DrawImage pointer,MouseX(),MouseY(),0
  410. If gameover = True
  411. Color 255,255,60
  412. Text MouseX(),MouseY(),"Game Over"
  413. EndIf
  414. If showmess >0
  415. showmess=showmess-1
  416. Color 255,60,60
  417. Text 10,17*33+8,mess$
  418. EndIf
  419. End Function
  420.  
  421.  
  422.  
  423.  
  424.  
  425. Function DrawChat()
  426. y=33*13-2-10
  427. r=255
  428. Color 255,255,0
  429. Rect 33*15+2,33*13-14,300,12*6+9,0
  430. Text 33*15+5,y,">"+chat$
  431. For i.Info=Each Info
  432. If r> 180
  433. Color r,r,0
  434. y=y+12
  435. Text 33*15+5,y,i\txt$
  436. r=r-16
  437. Else
  438. Delete i
  439. EndIf
  440. Next
  441. End Function
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448. Function GetNetMessages()
  449. While RecvNetMsg()
  450. Select NetMsgType()
  451. Case 1:
  452. ; updated bag of tiles, tilesused
  453. RecvBag( NetMsgData$() )
  454. Case 2:
  455. ; list of tiles came in
  456. RecvTiles( NetMsgData$() )
  457. Case 3:
  458. ; word rejected - delete it
  459. ClearTiles()
  460. Case 4:
  461. ; received mynum
  462. mynum = Int(Mid$( NetMsgData$(),1,6 ))
  463. playernum = Int(Mid$( NetMsgData$(),6,6 ))
  464. Case 5:
  465. ; chat message
  466. info( NetPlayerName$( NetMsgFrom() )+":"+NetMsgData$() )
  467. Case 6:
  468. ; all have accepted - so place the tiles
  469. passed=0
  470. AcceptTiles()
  471. Case 7:
  472. ; next player
  473. playernum=NextPlayer()
  474. If tilesused = 100
  475. passed=passed+1:IsGameOver()
  476. EndIf
  477. ; info("Player "+Abs(playernum+1)+" is Up")
  478. Case 8:
  479. If imhost = True  ; only the host replies
  480. ; sync request - send bag of tiles and tilesused and playernumber
  481. ; info("synch req from " + NetPlayerName$(NetMsgFrom()))
  482. SendPlayerNum(NetMsgFrom())
  483. SendBag()
  484. SendWords(NetMsgFrom())
  485. SendPlayerNumAll() ;let all players know who's who
  486. EndIf
  487. Case 9:
  488. ; pop up the confirm y/n, then send response to player that asked
  489. rsvp = Confirm(NetMsgData$())
  490. If rsvp
  491. SendNetMsg 10,"Accept",player\net_id,NetMsgFrom(),0
  492. Else
  493. SendNetMsg 10,"Reject",player\net_id,NetMsgFrom(),0
  494. EndIf
  495. Case 10:
  496. ; confirm response y/n
  497. p.player=FindPlayer( NetMsgFrom() )
  498. If p<>Null
  499. info( p\name+" says "+NetMsgData$())
  500. numrsvps=numrsvps+1
  501. If NetMsgData$() = "Accept"
  502. reply(p\playernum) = True
  503. Else
  504. reply(p\playernum) = False
  505. EndIf
  506. EndIf
  507. Case 11:
  508. ; list of words came in
  509. RecvWords( NetMsgData$() )
  510. Case 12:
  511. ; recv mappings of net_id->playernum from the host
  512. net_id = Int(Mid$( NetMsgData$(),1,10 ))
  513. pnum = Int(Mid$( NetMsgData$(),10,6 ))
  514. p.Player=FindPlayer( net_id )
  515. If p<>Null
  516. p\playernum = pnum
  517. playeralive(pnum) = True
  518. ;info(NetMsgData$())
  519. EndIf
  520. Case 13:; MSG_SCORE
  521. ; recv final scores
  522. pscore = Int(Mid$( NetMsgData$(),1,4 ))
  523. p.Player=FindPlayer( NetMsgFrom() )
  524. If p<>Null
  525. totalscore(p\playernum ) = pscore
  526. EndIf
  527. gameover=True
  528. SendMyScore()
  529. Case 100:
  530. If numplayers =< MAXPLAYERS
  531. p.player=New player
  532. p\net_id=NetMsgFrom()
  533. p\name=NetPlayerName$( NetMsgFrom() )
  534. info( p\name + " has joined the game. " )
  535. numplayers=numplayers+1
  536. EndIf
  537. Case 101:
  538. p.player=FindPlayer( NetMsgFrom() )
  539. If p<>Null
  540. info( p\name+" has left the game. " )
  541. ; if it was their turn, then pass turn to next player
  542. ; if they had tiles on their rack??? TODO!!!!! - recover tiles
  543. playeralive(p\playernum) = False
  544. If p\playernum = playernum
  545. Delete p
  546. playernum = NextPlayer()
  547. Else
  548. Delete p
  549. EndIf
  550. numplayers=numplayers-1
  551. EndIf
  552. Case 102:
  553. info( "I'm the new host! " )
  554. imhost=True
  555. Case 200:
  556. EndGraphics
  557. Text 0,0,"The session has been lost!"
  558. WaitKey
  559. End
  560. End Select
  561. Wend
  562.  
  563. End Function
  564.  
  565.  
  566.  
  567.  
  568. Function GetChatString()
  569. ;Chat - build the chat string - send on enter key
  570. key=GetKey()
  571. If key
  572. If key=13
  573. If chat$<>""
  574. SendNetMsg MSG_CHAT,chat$,player\net_id,0,0
  575. info(chat$)
  576. EndIf
  577. chat$=""
  578. Else If key=8
  579. If Len(chat$)>0 Then chat$=Left$(chat$,Len(chat$)-1)
  580. Else If key>=32 And key<127
  581. If Len(chat$)<31 Then chat$=chat$+Chr$(key)
  582. EndIf
  583. EndIf
  584. End Function
  585.  
  586.  
  587.  
  588.  
  589.  
  590. Function info( t$ )
  591. i.Info=New Info
  592. i\txt$=Mid$(t$,1,31)
  593. Insert i Before First Info
  594. End Function
  595.  
  596.  
  597.  
  598.  
  599.  
  600. Function RecvBag( msg$ )
  601. For t= 1 To 100
  602. kar$ = Mid$(msg$,t,1)
  603. If kar$ <> "?" Then num = Asc(kar$)-65 Else num = 26
  604. If num >25 Then num=26
  605. shuffled(t-1)=num
  606. Next
  607. x=Int(Mid$( msg$,101,6 ))
  608. ;info("recvbag tilesused="+Mid$(msg$,101,6))
  609. tilesused = x
  610. nsync=True
  611. End Function
  612.  
  613.  
  614.  
  615.  
  616.  
  617. Function RecvTiles( msg$ )
  618. For t= 0 To Len(msg$)/3-1
  619. kar$ = Mid$(msg$,t*3+1,1)
  620. If kar$ <> "?" Then num = Asc(kar$)-65 Else num = 26
  621. x = Asc(Mid$(msg$,t*3+2,1))-65
  622. y = Asc(Mid$(msg$,t*3+3,1))-65
  623. tin.tiletype=New tiletype
  624. tin\x = x
  625. tin\y = y
  626. tin\tilenum = num
  627. tilesplaced = tilesplaced+1
  628. Next
  629. End Function
  630.  
  631.  
  632.  
  633.  
  634.  
  635. Function FindPlayer.player( id )
  636. ;find player with player id
  637. For p.player=Each player
  638. If p\net_id=id Then Return p
  639. Next
  640. End Function
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647. Function SendBag()
  648. ; update all the other players about the newly changed bag of tiles - shuffle()
  649. ; 100 characters + tilesused (6 chrs)
  650. shuffles$=""
  651. For t= 0 To 99
  652. If shuffled(t) < 26 Then kar$ = Chr$(shuffled(t)+65) Else kar$="?"
  653. shuffle$=shuffle$+kar$
  654. Next
  655. shuffle$=shuffle$+LSet$(Int(tilesused),6)
  656. ;info("sendbag tilesused="+LSet$(Int(tilesused),6))
  657. SendNetMsg MSG_RECVBAG,shuffle$,player\net_id,0,0
  658. End Function
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665. Function SendPlaceTiles()
  666. SendNetMsg MSG_PLACETILES,"Place tiles!",player\net_id,0,0
  667. End Function
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674. Function SendPlayerNum(net_id)
  675. ; someone wants to join - find a spot, if full send a -1
  676. ; find free playernum
  677. pn = -1
  678. For t = MAXPLAYERS-1 To 0 Step -1
  679. If playeralive(t) = False
  680. pn = t
  681. EndIf
  682. Next
  683. playnum$=LSet$(Int(pn),6)
  684. ; tack on the current playernum too
  685. playnum$=playnum$+LSet$(Int(playernum),6)
  686. SendNetMsg 4,playnum$,player\net_id,net_id,0
  687. p.player=FindPlayer( net_id )
  688. If p<>Null
  689. p\playernum = pn
  690. If pn > -1
  691. playeralive(pn) = True
  692. EndIf
  693. EndIf
  694. End Function
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701. Function SendPlayerNumAll()
  702. ; the host sends out list of net_id->playernum mapping after new player joins
  703. For p.player = Each player
  704. playnums$=LSet$(Int(p\net_id),10)
  705. playnums$=playnums$+LSet$(Int(p\playernum),4)
  706. SendNetMsg MSG_MAPPING,playnums$,player\net_id,0,0
  707. Next
  708. End Function
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715. Function SendTiles()
  716. ; update all the other players about the tiles we are placing down
  717. ; eg A at 0,0  C at 0,1 E at 0,2  = AAACABEAC
  718. ; - unpacked in 3s at other end - max 21 characters
  719. tile$=""
  720. For t.tiletype = Each tiletype
  721. If t\tilenum < 26 Then kar$ = Chr$(t\tilenum+65) Else kar$="?"
  722. x$ = Chr$(t\x+65)
  723. y$ = Chr$(t\y+65)
  724. tiles$=tiles$+kar$+x$+y$
  725. Next
  726. SendNetMsg MSG_RECVTILES,tiles$,player\net_id,0,0
  727. End Function
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734. Function SendWords(net_id)
  735. ; update the player's word list
  736. words$ = ""
  737. For w.word = Each word
  738. ; pack the word info into a string
  739. words$=words$+LSet$(Int(Len(w\wordstring$)),3)
  740. words$=words$+w\wordstring$
  741. words$=words$+LSet$(Int(w\startx),3)
  742. words$=words$+LSet$(Int(w\starty),3)
  743. words$=words$+LSet$(Int(w\endx),3)
  744. words$=words$+LSet$(Int(w\endy),3)
  745. words$=words$+LSet$(Int(w\points),3)
  746. words$=words$+LSet$(Int(w\id),3)
  747. words$=words$+LSet$(Int(w\playernum),3)
  748. Next
  749. SendNetMsg MSG_RECVWORDS,words$,player\net_id,net_id,0
  750. End Function
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757. Function RecvWords(msg$)
  758. ;unpack the words and add them to board and add up the scores
  759. pos=1
  760. While pos < Len(msg$)
  761. w.word = New word
  762. wlen = Int(Mid$( msg$,pos,3 ))
  763. w\wordstring$ = Mid$( msg$, pos+3, wlen )
  764. w\startx = Int(Mid$( msg$,pos+3+wlen,3 ))
  765. w\starty = Int(Mid$( msg$,pos+3+wlen+3,3 ))
  766. w\endx = Int(Mid$( msg$,pos+3+wlen+6,3 ))
  767. w\endy = Int(Mid$( msg$,pos+3+wlen+9,3 ))
  768. w\points = Int(Mid$( msg$,pos+3+wlen+12,3 ))
  769. w\id = Int(Mid$( msg$,pos+3+wlen+15,3 ))
  770. w\playernum = Int(Mid$( msg$,pos+3+wlen+18,3 ))
  771. pos=pos+wlen+24
  772. ;info(w\wordstring$ +" "+ w\starty + " " +w\endy )
  773. Wend
  774. ; do something with the words....
  775. For w.word=Each word
  776. If w\endx-w\startx > 0
  777. pos = 1
  778. For t = w\startx To w\endx
  779. kar$ = Mid$(w\wordstring$, pos, 1)
  780. If kar$ <> "?" Then num = Asc(kar$)-65 Else num = 26
  781. boardt(t,w\starty)=num
  782. pos=pos+1
  783. Next
  784. Else
  785. pos = 1
  786. For t = w\starty To w\endy
  787. kar$ = Mid$(w\wordstring$, pos, 1)
  788. If kar$ <> "?" Then num = Asc(kar$)-65 Else num = 26
  789. boardt(w\startx,t)=num
  790. pos=pos+1
  791. Next
  792. EndIf
  793. totalscore(w\playernum) = totalscore(w\playernum) + w\points
  794. Next
  795. End Function
  796.  
  797.  
  798.  
  799.  
  800.  
  801.  
  802. Function AcceptTiles()
  803. ; ordered to place the tiles from another player down on board, update counters
  804. turnscore = CalculatePoints()
  805. totalscore(playernum)=totalscore(playernum)+turnscore
  806. tilesplaced = 0
  807. tilesused = tilesused + PlaceTiles()
  808. If tilesused > 100 Then tilesused = 100
  809. End Function
  810.  
  811.  
  812.  
  813.  
  814.  
  815. Function GetResponses()
  816. x=MouseX()
  817. y=MouseY()
  818. If x>800-200 Then x=800-200
  819. If x<50 Then x=50
  820. If y>600-100 Then y=600-100
  821. If y<50 Then y=50
  822. For t = 0 To 3
  823. reply(t) = True
  824. Next
  825. numrsvps = 0
  826. SendNetMsg MSG_CONFIRM,"Accept",player\net_id,0,0
  827. While numrsvps < numplayers-1
  828. DrawAll()
  829. Color 255,255,255
  830. Rect 0,0,800,600,0
  831. Color 255,255,0
  832. Rect x-2,y-2,136,34
  833. Color 80,80,220
  834. Rect x,y,132,30
  835. Color 255,255,255
  836. Text x+10,y+2,"Please Wait"
  837. Flip
  838. GetNetMessages()
  839. Wend
  840. For t = 0 To 3
  841. If reply(t) = False Then Return False
  842. Next
  843. Return True
  844. End Function
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852. Function DrawScores()
  853. For t=0 To 3
  854. Color pcol(t)\r,pcol(t)\g,pcol(t)\b
  855. If playeralive(t)
  856. Text 33*13,15*33+15+t*12,"P"+Abs(t+1)+" Score: " + totalscore(t)
  857. EndIf
  858. Next
  859. Color pcol(playernum)\r,pcol(playernum)\g,pcol(playernum)\b
  860. If playernum = mynum
  861. Text 33*13,15*33+15+4*12,"You're Up P"+Abs(playernum+1)+"!"
  862. Else
  863. Text 33*13,15*33+15+4*12,"Player " + Abs(playernum+1)+ " is Up"
  864. EndIf
  865. Color 240,30,30
  866. Text 33*13,15*33+15+5*12,"Tiles Left: " + Abs(100-tilesused)
  867. If singleplayer = False
  868. Text 33*13,15*33+15+6*12,"Player " + Abs(mynum+1) + " of " + Abs(numplayers)
  869. EndIf
  870. End Function
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877. Function NextPlayer()
  878.  
  879. t = playernum
  880. Repeat
  881. t=t+1:If t > 3 Then t = 0
  882. Until playeralive(t)= True
  883. Return t
  884.  
  885. End Function
  886.  
  887.  
  888.  
  889.  
  890.  
  891. Function IsGameOver()
  892. If tilesused = 100 And gameover=False  ; out of tiles and not already ended
  893. rcount = 0
  894. For t = 0 To 11
  895. If rack(t) > -1 Then rcount = rcount + 1
  896. Next
  897. If rcount = 0 Then gameover = True
  898. ; check if everyone has passed since we ran out of tiles
  899. If passed = numplayers Then gameover = True
  900.  
  901. If gameover = True
  902. rackscore = 0
  903. For t = 0 To 11
  904. If rack(t) > -1
  905. rackscore = rackscore + points(rack(t))
  906. EndIf
  907. Next
  908.  
  909. If rcount = 0
  910. ; add rackscores from other players - calculate by what's not on the board.
  911. ; incorrect if player drops out, taking tiles with them, this includes those tiles
  912. tscore = 0
  913. For t = 0 To 26
  914. tscore = tscore + points(t)*distribution(t)
  915. Next
  916. bscore = 0
  917. For x = 0 To 14
  918. For y = 0 To 14
  919. If boardt(x,y) > -1 Then bscore = bscore + points(boardt(x,y))
  920. Next
  921. Next
  922. totalscore(mynum) = totalscore(mynum) + tscore - bscore
  923. Else
  924. totalscore(mynum) = totalscore(mynum) - rackscore
  925. EndIf
  926. sc$ = LSet$(Int(totalscore(mynum)),4)
  927. If singleplayer = False SendNetMsg MSG_SCORE,sc$,player\net_id,0,0
  928. scoresent = True
  929. EndIf
  930. EndIf
  931. End Function
  932.  
  933.  
  934.  
  935.  
  936.  
  937. Function SendMyScore()
  938. If scoresent = False
  939. rackscore = 0
  940. For t = 0 To 11
  941. If rack(t) > -1
  942. rackscore = rackscore + points(rack(t))
  943. EndIf
  944. Next
  945.  
  946. totalscore(mynum) = totalscore(mynum) - rackscore
  947.  
  948. sc$ = LSet$(Int(totalscore(mynum)),4)
  949. SendNetMsg MSG_SCORE,sc$,player\net_id,0,0
  950. scoresent = True
  951. EndIf
  952. End Function
  953.  
  954.  
  955.  
  956.  
  957.  
  958. Function SendNextPlayer()
  959. SendNetMsg MSG_NEXTPLAYER,"Next Player",player\net_id,0,0
  960. End Function
  961.  
  962.  
  963.  
  964.  
  965. Function CheckMenu()
  966. x= MouseX()/33
  967. If x=18 And holdingtile = False
  968. ; menu items
  969. y1 = (MouseY()-menuy)/12
  970. ;DrawImage letters,menux,menuy+12*y1,39
  971. Select y1
  972. Case 0
  973. ; player wants to end their turn by playing tiles
  974. If playernum = mynum
  975. If CheckTilePlacement()
  976. allok = False
  977. If singleplayer = False SendTiles()
  978. ; pass info to other players and wait for accept or reject responses
  979. If singleplayer = False
  980. allok=GetResponses()
  981. Else
  982. allok=True
  983. EndIf
  984. ; if all accept then place them and add points
  985. If allok
  986. If singleplayer = False SendPlaceTiles() ; tell all players to place word, update tilesused
  987. turnscore = CalculatePoints()
  988. totalscore(playernum)=totalscore(playernum)+turnscore
  989. tilesplaced = 0
  990. PlaceTiles()
  991. RefillRack() ; alters tilesused
  992. ; if rack is now empty then the game is done
  993. IsGameOver()
  994. playernum = NextPlayer()
  995. ; send net message - update playernum
  996. If singleplayer = False SendNextPlayer()
  997. Else
  998. If singleplayer = False SendNetMsg MSG_CLEARTILES,"Clear Tiles",player\net_id,0,0
  999. mess$="Your word was rejected!"
  1000. showmess=MSGTICKS
  1001. ; TODO: clear tiles and skip turn???? - left to players for now
  1002. EndIf
  1003. EndIf
  1004. EndIf
  1005. Case 1
  1006. ; player wants to end their turn by skipping
  1007. If playernum = mynum And singleplayer = False
  1008. If Confirm("Pass") = True
  1009. If tilesplaced = 0
  1010. IsGameOver()
  1011. playernum = NextPlayer()
  1012. ; send net message - update playernum
  1013. If singleplayer = False SendNextPlayer()
  1014. Else
  1015. mess$="Please remove tiles from board first!"
  1016. showmess=MSGTICKS
  1017. EndIf
  1018. EndIf
  1019. EndIf
  1020. Case 2
  1021. ; player wants to end their turn by swapping tiles
  1022. If playernum = mynum And tilesused < 100
  1023. Select exmode
  1024. Case True
  1025. numtiles = 0
  1026. For t = 0 To 11
  1027. If exrack(t) > -1 Then numtiles = numtiles + 1
  1028. Next
  1029. If numtiles > 0
  1030. If Confirm("Swap") = True
  1031. If ExchangeTiles() = True
  1032. exmode=False
  1033. showmess=0
  1034. playernum = NextPlayer()
  1035. ; send new shuffled array to all players
  1036. If singleplayer = False SendBag()
  1037. ; send net message - update playernum
  1038. If singleplayer = False SendNextPlayer()
  1039. EndIf
  1040. EndIf
  1041. Else
  1042. mess$="Swap canceled."
  1043. showmess=MSGTICKS
  1044. exmode=False
  1045. EndIf
  1046. Case False
  1047. If tilesplaced > 0
  1048. mess$="Please remove tiles from board first!"
  1049. showmess=MSGTICKS
  1050. Else
  1051. exmode=True
  1052. mess$="Place tiles to discard on the upper rack."
  1053. showmess=MSGTICKS
  1054. EndIf
  1055. End Select
  1056. EndIf
  1057. Case 3
  1058. ; can shuffle anytime
  1059. ShuffleRack()
  1060. Case 4
  1061. ; rotate through the display panels - anytime
  1062. ; 0 - words, 1 - tiles, 2 - points
  1063. showpanel = showpanel + 1
  1064. If showpanel > numpanels-1 Then showpanel = 0 ; debug
  1065. Case 5
  1066. If singleplayer = True
  1067. ; only - will be removed from final version
  1068. If Confirm("Reset") = True
  1069. gameover=False
  1070. exmode=False
  1071. ShuffleTiles()
  1072. ClearTiles()
  1073. ClearWordList()
  1074. For t = 0 To 3:totalscore(t)=0:Next
  1075. tilesused = 0
  1076. numwords=0
  1077. ClearBoard()
  1078. ClearRack()
  1079. RefillRack()
  1080. EndIf
  1081. EndIf
  1082. Case 6
  1083. If Confirm("Quit") = True
  1084. quit=True
  1085. EndIf
  1086. End Select
  1087. EndIf
  1088. End Function
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095. Function CheckRack(x,y)
  1096. ; check if we clicked on the rack or exchange rack
  1097. If holdingtile = True
  1098. ; if holding a tile
  1099. If y=16 And x>=0 And x<12
  1100. If rack(x) = -1
  1101. ;put back on the rack in empty spot
  1102. rack(x) = tileheld
  1103. holdingtile=False
  1104. Else
  1105. ;swap tile with the one under it
  1106. temp=tileheld
  1107. tileheld=rack(x)
  1108. rack(x)=temp
  1109. EndIf
  1110. EndIf
  1111. If y=15 And x>=0 And x<12 And exmode=True
  1112. If exrack(x) = -1
  1113. ;put on the  exchange rack
  1114. exrack(x) = tileheld
  1115. holdingtile=False
  1116. Else
  1117. ;swap tile with the one under it
  1118. temp=tileheld
  1119. tileheld=exrack(x)
  1120. exrack(x)=temp
  1121. EndIf
  1122. EndIf
  1123. Else
  1124. If y=16 And x>=0 And x<12
  1125. If rack(x) >-1
  1126. ;Pick up a tile from the rack
  1127. tileheld = rack(x)
  1128. rack(x) = -1
  1129. holdingtile=True
  1130. EndIf
  1131. EndIf
  1132. If y=15 And x>=0 And x<12 And exmode=True
  1133. If exrack(x) >-1
  1134. ;Pick up a tile from the exrack
  1135. tileheld = exrack(x)
  1136. exrack(x) = -1
  1137. holdingtile=True
  1138. EndIf
  1139. EndIf
  1140. EndIf
  1141. End Function
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150. Function Confirm(conf$)
  1151. ; draw box with  No  Yes  boxes at the bottom
  1152. x=MouseX()
  1153. y=MouseY()
  1154. If x>800-200 Then x=800-200
  1155. If x<50 Then x=50
  1156. If y>600-100 Then y=600-100
  1157. If y<50 Then y=50
  1158. answer=False
  1159. While answer=False
  1160. If KeyHit(21) Then answer = True:ret=True
  1161. If KeyHit(49) Then answer = True:ret=False
  1162. If MouseHit(1)
  1163. ; check position
  1164. xm=MouseX():ym=MouseY()
  1165. If xm>x+5 And xm< x+25 And ym>y+19 And ym<y+29
  1166. ; no hit
  1167. answer = True:ret=False
  1168. EndIf
  1169. If xm>x+105 And xm< x+125 And ym>y+19 And ym<y+29
  1170. ; yes hit
  1171. answer = True:ret=True
  1172. EndIf
  1173. EndIf
  1174. DrawAll()
  1175. If tmr < 50 Then Color 255,255,0 Else Color 255,0,0
  1176. Rect x-2,y-2,136,34
  1177. Color 80,80,220
  1178. Rect x,y,132,30
  1179. Color 255,255,255
  1180. Text x+10,y+2,conf$+" y/n?"
  1181. DrawImage letters,x+5,y+19,38
  1182. DrawImage letters,x+105,y+19,37
  1183. DrawImage pointer,MouseX(),MouseY(),0
  1184. tmr=tmr+1:If tmr> 100 Then tmr=0
  1185. Flip
  1186. Wend
  1187. Return ret
  1188. End Function
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195. Function PlaceTiles()
  1196. t=0
  1197. For tin.tiletype=Each tiletype
  1198. ;place floating tiles on board
  1199. boardt(tin\x,tin\y) = tin\tilenum
  1200. Delete tin
  1201. t=t+1
  1202. Next
  1203. Return t
  1204. End Function
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211. Function CheckTilePlacement()
  1212.  
  1213. tin.tiletype = First tiletype
  1214. If tin <> Null
  1215. highx = tin\x
  1216. highy = tin\y
  1217. lowx = tin\x
  1218. lowy = tin\y
  1219. tcount=0
  1220. For tin.tiletype=Each tiletype
  1221. boardt(tin\x,tin\y) = -2 ; mark this for next step
  1222. If tin\x > highx Then highx=tin\x
  1223. If tin\x < lowx Then lowx=tin\x
  1224. If tin\y > highy Then highy=tin\y
  1225. If tin\y < lowy Then lowy=tin\y
  1226. tcount=tcount+1
  1227. Next
  1228.  
  1229. ;check that there are tiles between the highx and lowx and highy and lowy
  1230. For x = lowx To highx
  1231. If boardt(x,lowy) =-1
  1232. showmess=MSGTICKS
  1233. mess$ = "Must be a continuous Row or Column!"
  1234. For tin.tiletype=Each tiletype
  1235. boardt(tin\x,tin\y) = -1
  1236. Next
  1237. Return False ; gap in the row
  1238. EndIf
  1239. Next
  1240. For y = lowy To highy
  1241. If boardt(lowx,y) =-1
  1242. showmess=MSGTICKS
  1243. mess$ = "Must be a continuous Column or Row!"
  1244. For tin.tiletype=Each tiletype
  1245. boardt(tin\x,tin\y) = -1
  1246. Next
  1247. Return False ; gap in the column
  1248. EndIf
  1249. Next
  1250.  
  1251. If boardt(7,7) <= -1  ; -1 or -2 on first turn , -2 is ok
  1252. ; not enough tiles
  1253. If tcount < 2
  1254. showmess=MSGTICKS
  1255. mess$ = "First word must be at least 2 tiles!"
  1256. For tin.tiletype=Each tiletype
  1257. boardt(tin\x,tin\y) = -1
  1258. Next
  1259. Return False
  1260. EndIf
  1261.  
  1262. ; first word must be on center square
  1263. If boardt(7,7) = -1
  1264. showmess=MSGTICKS
  1265. mess$ = "First word must be on center square!"
  1266. For tin.tiletype=Each tiletype
  1267. boardt(tin\x,tin\y) = -1
  1268. Next
  1269. Return False
  1270. EndIf
  1271. Else
  1272. ;check single tile is next to existing tile
  1273. tok=0
  1274. For tin.tiletype = Each tiletype
  1275. tabove=0
  1276. tbelow=0
  1277. tright=0
  1278. tleft=0
  1279. If tin\y-1 >=0 Then tabove=boardt(tin\x,tin\y-1)
  1280. If tin\y+1 <15 Then tbelow=boardt(tin\x,tin\y+1)
  1281. If tin\x+1 <15 Then tright=boardt(tin\x+1,tin\y)
  1282. If tin\x-1 >=0 Then tleft=boardt(tin\x-1,tin\y)
  1283. If tabove>-1 Or tbelow > -1 Or tright >-1 Or tleft >-1
  1284. tok=tok+1
  1285. EndIf
  1286. Next
  1287. If tok = 0
  1288. showmess=MSGTICKS
  1289. mess$ = "Must be next to another tile!"
  1290. For tin.tiletype=Each tiletype
  1291. boardt(tin\x,tin\y) = -1
  1292. Next
  1293. Return False ; lone tile
  1294. EndIf
  1295. EndIf
  1296. Else
  1297. ; no tiles placed
  1298. showmess=MSGTICKS
  1299. mess$="No tiles placed on board!"
  1300. Return False
  1301. EndIf
  1302.  
  1303. Return True
  1304.  
  1305. End Function
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313. Function CalculatePoints()
  1314. score = 0
  1315. tin.tiletype = First tiletype
  1316. If tin <> Null
  1317. highx = tin\x
  1318. highy = tin\y
  1319. lowx = tin\x
  1320. lowy = tin\y
  1321. tcount=0
  1322. For tin.tiletype=Each tiletype
  1323. boardt(tin\x,tin\y) = -2
  1324. If tin\x > highx Then highx=tin\x
  1325. If tin\x < lowx Then lowx=tin\x
  1326. If tin\y > highy Then highy=tin\y
  1327. If tin\y < lowy Then lowy=tin\y
  1328. tcount=tcount+1
  1329. Next
  1330.  
  1331. If tilesplaced > 1
  1332. ; are tiles in a row?
  1333. If highx-lowx > 0
  1334. ;tiles in a row
  1335. ;find complete row - check lower and higher
  1336. If lowx > 0
  1337. If boardt(lowx-1,lowy) >-1
  1338. ok=True
  1339. Repeat
  1340. lowx=lowx-1
  1341. If lowx=0
  1342. ok=False
  1343. Else
  1344. If boardt(lowx-1 ,lowy) < 0 Then ok=False
  1345. EndIf
  1346. Until Not ok
  1347. EndIf
  1348. EndIf
  1349. If highx < 14
  1350. If boardt(highx+1,lowy) >-1
  1351. ok=True
  1352. Repeat
  1353. highx=highx+1
  1354. If highx=14
  1355. ok=False
  1356. Else
  1357. If boardt(highx+1,lowy) < 0 Then ok=False ; here!!!
  1358. EndIf
  1359. Until Not ok
  1360. EndIf
  1361. EndIf
  1362.  
  1363. bonusx = 1:word$=""
  1364. For x = lowx To highx
  1365. If boardt(x,lowy) >-1
  1366. score = score + points(boardt(x,lowy))
  1367. If boardt(x,lowy) <26 Then word$=word$+Chr$(boardt(x,lowy)+65) Else word$=word$+"?"
  1368. Else
  1369. For tin.tiletype=Each tiletype
  1370. If tin\x = x
  1371. ; found the tile on this square
  1372. score = score + points(tin\tilenum)*TileBonus(x,lowy)
  1373. If tin\tilenum <26 Then word$=word$+Chr$(tin\tilenum+65) Else word$=word$+"?"
  1374. EndIf
  1375. Next
  1376. bonusx = bonusx * WordBonus(x,lowy)
  1377. EndIf
  1378. Next
  1379. score = score * bonusx
  1380. If tcount = 7
  1381. score=score+50
  1382. mess = 100
  1383. mess$=mess$+"50 Point Bonus for using all tiles!"
  1384. EndIf
  1385. AddNewWord(lowx,highx,lowy,lowy,word$,score)
  1386.  
  1387. For tin.tiletype=Each tiletype
  1388. ; check for tiles above and below, if there are then get the points
  1389. lowy= tin\y
  1390. highy= tin\y
  1391. If lowy>0
  1392. If boardt(tin\x,lowy-1) > -1
  1393. ok=True
  1394. Repeat
  1395. lowy=lowy-1
  1396. If lowy=0
  1397. ok=False
  1398. Else
  1399. If boardt(tin\x ,lowy-1) < 0 Then ok=False
  1400. EndIf
  1401. Until Not ok
  1402. EndIf
  1403. EndIf
  1404. If highy <14
  1405. If boardt(tin\x,highy+1) > -1
  1406. ok=True
  1407. Repeat
  1408. highy=highy+1
  1409. If highy=14
  1410. ok=False
  1411. Else
  1412. If boardt(tin\x ,highy+1) < 0 Then ok=False
  1413. EndIf
  1414. Until Not ok
  1415. EndIf
  1416. EndIf
  1417. If highy-lowy > 0
  1418. score = score + PointsForCol(tin\x,lowy,highy,tin\tilenum)
  1419. EndIf
  1420. Next
  1421. Else
  1422. ;the tiles are in a column
  1423. ;find complete column - check lower and higher
  1424. If lowy > 0
  1425. If boardt(lowx,lowy-1) >-1
  1426. ok=True
  1427. Repeat
  1428. lowy=lowy-1
  1429. If lowy=0
  1430. ok=False
  1431. Else
  1432. If boardt(lowx ,lowy-1) < 0 Then ok = False
  1433. EndIf
  1434. Until Not ok
  1435. EndIf
  1436. EndIf
  1437. If highy < 14
  1438. If boardt(lowx,highy+1) >-1
  1439. ok=True
  1440. Repeat
  1441. highy=highy+1
  1442. If highy=14
  1443. ok=False
  1444. Else
  1445. If boardt(lowx ,highy+1) < 0 Then ok=False
  1446. EndIf
  1447. Until Not ok
  1448. EndIf
  1449. EndIf
  1450.  
  1451. bonusx = 1:word$=""
  1452. For y = lowy To highy
  1453. If boardt(lowx,y) >-1
  1454. score = score + points(boardt(lowx,y))
  1455. If boardt(lowx,y) <26 Then word$=word$+Chr$(boardt(lowx,y)+65) Else word$=word$+"?"
  1456. Else
  1457. For tin.tiletype=Each tiletype
  1458. If tin\y = y
  1459. ; found the tile on this square
  1460. score = score + points(tin\tilenum)*TileBonus(lowx,y)
  1461. If tin\tilenum <26 Then word$=word$+Chr$(tin\tilenum+65) Else word$=word$+"?"
  1462. EndIf
  1463. Next
  1464. bonusx = bonusx * WordBonus(lowx,y)
  1465. EndIf
  1466. Next
  1467. score = score * bonusx
  1468. If tcount = 7
  1469. score=score+50
  1470. mess = 100
  1471. mess$=mess$+"50 Point Bonus for using all tiles!"
  1472. EndIf
  1473. AddNewWord(lowx,lowx,lowy,highy,word$,score)
  1474.  
  1475. For tin.tiletype=Each tiletype
  1476. ; check for tiles left and right, if there are then get the points
  1477. lowx= tin\x
  1478. highx= tin\x
  1479. If lowx>0
  1480. If boardt(lowx-1,tin\y) > -1
  1481. ok=True
  1482. Repeat
  1483. lowx=lowx-1
  1484. If lowx=0
  1485. ok=False
  1486. Else
  1487. If boardt(lowx-1 ,tin\y) < 0 Then ok=False
  1488. EndIf
  1489. Until Not ok
  1490. EndIf
  1491. EndIf
  1492. If highx <14
  1493. If boardt(highx+1,tin\y) > -1
  1494. ok=True
  1495. Repeat
  1496. highx=highx+1
  1497. If highx=14
  1498. ok=False
  1499. Else
  1500. If boardt(highx+1 ,tin\y) < 0 Then ok=False
  1501. EndIf
  1502. Until Not ok
  1503. EndIf
  1504. EndIf
  1505. If highx-lowx > 0
  1506. score = score + PointsForRow(lowx,highx,tin\y,tin\tilenum)
  1507. EndIf
  1508. Next
  1509. EndIf
  1510. Else
  1511. ; single tile placed - check both row and column
  1512. tin.tiletype = First tiletype
  1513. lowx= tin\x
  1514. highx= tin\x
  1515. lowy= tin\y
  1516. highy= tin\y
  1517. If lowx > 0
  1518. If boardt(lowx-1,lowy) >-1
  1519. ok=True
  1520. Repeat
  1521. lowx=lowx-1
  1522. If lowx = 0
  1523. ok = False
  1524. Else
  1525. If boardt(lowx-1,lowy) < 0 Then ok = False
  1526. EndIf
  1527. Until Not ok
  1528. EndIf
  1529. EndIf
  1530. If highx < 14
  1531. If boardt(highx+1,lowy) >-1
  1532. ok=True
  1533. Repeat
  1534. highx=highx+1
  1535. If highx=14
  1536. ok=False
  1537. Else
  1538. If boardt(highx+1,lowy) < 0 Then ok=False
  1539. EndIf
  1540. Until Not ok
  1541. EndIf
  1542. EndIf
  1543.  
  1544. If highx-lowx > 0
  1545. score = score + PointsForRow(lowx,highx,tin\y,tin\tilenum)
  1546. EndIf
  1547.  
  1548. tin.tiletype= First tiletype
  1549. lowx= tin\x
  1550. highx= tin\x
  1551. lowy= tin\y
  1552. highy= tin\y
  1553. If lowy > 0
  1554. If boardt(lowx,lowy-1) >-1
  1555. ok=True
  1556. Repeat
  1557. lowy=lowy-1
  1558. If lowy=0
  1559. ok=False
  1560. Else
  1561. If boardt(lowx ,lowy-1) < 0 Then ok=False
  1562. EndIf
  1563. Until Not ok
  1564. EndIf
  1565. EndIf
  1566. If highy < 14
  1567. If boardt(lowx,highy+1) >-1
  1568. ok=True
  1569. Repeat
  1570. highy=highy+1
  1571. If highy=14
  1572. ok=False
  1573. Else
  1574. If boardt(lowx ,highy+1) < 0 Then ok=False
  1575. EndIf
  1576. Until Not ok
  1577. EndIf
  1578. EndIf
  1579. If highy-lowy > 0
  1580. score = score + PointsForCol(tin\x,lowy,highy,tin\tilenum)
  1581. EndIf
  1582. EndIf
  1583. EndIf
  1584.  
  1585. Return score
  1586. End Function
  1587.  
  1588.  
  1589.  
  1590.  
  1591. Function PointsForRow(xlow,xhigh,y,tilenum)
  1592. bonusx = 1:word$=""
  1593. For x = xlow To xhigh
  1594. If boardt(x,y) >-1
  1595. rowscore = rowscore + points(boardt(x,y))
  1596. If boardt(x,y)<26 Then word$=word$+Chr$(boardt(x,y)+65) Else word$=word$+"?"
  1597. Else
  1598. rowscore = rowscore + points(tilenum)*TileBonus(x,y)
  1599. bonusx = bonusx * WordBonus(x,y)
  1600. If tilenum < 26 Then word$=word$+Chr$(tilenum+65) Else word$=word$+"?"
  1601. EndIf
  1602. Next
  1603. rowscore = rowscore * bonusx
  1604. AddNewWord(xlow,xhigh,y,y,word$,rowscore)
  1605.  
  1606. Return rowscore
  1607. End Function
  1608.  
  1609.  
  1610.  
  1611.  
  1612. Function PointsForCol(x,ylow,yhigh,tilenum)
  1613. bonusx = 1:word$=""
  1614. For y = ylow To yhigh
  1615. If boardt(x,y) >-1
  1616. colscore = colscore + points(boardt(x,y))
  1617. If boardt(x,y)<26 Then word$=word$+Chr$(boardt(x,y)+65) Else word$=word$+"?"
  1618. Else
  1619. colscore = colscore + points(tilenum)*TileBonus(x,y)
  1620. bonusx = bonusx * WordBonus(x,y)
  1621. If tilenum < 26 Then word$=word$+Chr$(tilenum+65) Else word$=word$+"?"
  1622. EndIf
  1623. Next
  1624. colscore = colscore * bonusx
  1625. AddNewWord(x,x,ylow,yhigh,word$,colscore)
  1626.  
  1627. Return colscore
  1628. End Function
  1629.  
  1630.  
  1631.  
  1632.  
  1633. Function AddNewWord(lx,hx,ly,hy,word$,score)
  1634. numwords=numwords+1
  1635. w.word = New word
  1636. w\wordstring = word$
  1637. w\startx = lx
  1638. w\starty = ly
  1639. w\endx = hx
  1640. w\endy = hy
  1641. w\points = score
  1642. w\playernum = playernum
  1643. w\id=numwords
  1644. End Function
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650. Function TileBonus(x,y)
  1651. Select boardbg(x,y)
  1652. Case 3 ; double letter square
  1653. Return 2
  1654. Case 4 ; triple letter square
  1655. Return 3
  1656. Default
  1657. Return 1
  1658. End Select
  1659. End Function
  1660.  
  1661.  
  1662.  
  1663.  
  1664. Function WordBonus(x,y)
  1665. Select boardbg(x,y)
  1666. Case 0 ; double word center square
  1667. Return 2
  1668. Case 1 ; double word square
  1669. Return 2
  1670. Case 2 ; triple word square
  1671. Return 3
  1672. Default
  1673. Return 1
  1674. End Select
  1675. End Function
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682. Function ExchangeTiles()
  1683. numtiles = 0
  1684. For t = 0 To 11
  1685. If exrack(t) > -1 Then numtiles = numtiles + 1
  1686. Next
  1687.  
  1688. If 100-tilesused >= numtiles
  1689.  
  1690. ;swap the tiles with the top ones
  1691. nt=0
  1692. For t = 0 To 11
  1693. If exrack(t) > -1
  1694. temp=exrack(t)
  1695. exrack(t)=shuffled(tilesused+nt)
  1696. shuffled(tilesused+nt)=temp
  1697. nt=nt+1
  1698. EndIf
  1699. Next
  1700.  
  1701. ;shuffle the exchanged tiles back into the shuffled array
  1702. For t = 0 To numtiles-1 ; max 0 to 6
  1703. loc= Rnd(tilesused,100)
  1704. temp=shuffled(loc)
  1705. shuffled(loc) = shuffled(tilesused+t)
  1706. shuffled(tilesused+t) = temp
  1707. Next
  1708.  
  1709. ;transfer them from exrack to the rack
  1710. nt=0
  1711. For t = 0 To 11
  1712. If exrack(t) > -1
  1713. While rack(nt) > -1
  1714. nt=nt+1
  1715. Wend
  1716. rack(nt)=exrack(t)
  1717. exrack(t)=-1
  1718. nt=nt+1
  1719. EndIf
  1720. Next
  1721.  
  1722. Else
  1723. If tilesused =100
  1724. mess$="There are no tiles left!"
  1725. Else
  1726. mess$="There are only "+ Abs(100-tilesused)+" tiles left!"
  1727. EndIf
  1728. showmess = MSGTICKS
  1729. Return False
  1730. EndIf
  1731.  
  1732. Return True
  1733. End Function
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740. Function RefillRack()
  1741. numtiles = 0
  1742. For t = 0 To 11
  1743. If rack(t) > -1 Then numtiles = numtiles + 1
  1744. Next
  1745. t = 0
  1746. While numtiles < 7 And tilesused<100 And t < 12
  1747. If rack(t) = -1
  1748. rack(t)=shuffled(tilesused)
  1749. tilesused = tilesused +1
  1750. numtiles = numtiles +1
  1751. EndIf
  1752. t= t+1
  1753. Wend
  1754. End Function
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762. Function DrawTiles()
  1763. ;white background - eliminate this by changing bkground of board tiles to white
  1764. Color 255,255,255
  1765. Rect 0,0,15*33+1,15*33+1
  1766. ;draw the board
  1767. For x = 0 To 14
  1768. For y = 0 To 14
  1769. If boardt(x,y) >= 0
  1770. DrawBlock letters,x*33+1,y*33+1,boardt(x,y)
  1771. Else
  1772. DrawBlock letters,x*33+1,y*33+1,30+boardbg(x,y)
  1773. EndIf
  1774. Next
  1775. Next
  1776.  
  1777. ;draw rack and tiles on rack
  1778. Color 160,80,50
  1779. Rect 0,16*33-3,12*33+3,33+6,1
  1780. For t= 0 To 11
  1781. If rack(t) > -1
  1782. DrawBlock letters,t*33+1,16*33,rack(t)
  1783. EndIf
  1784. Next
  1785.  
  1786. ;draw exrack and tiles on exrack
  1787. If exmode=True
  1788. Color 80,140,50
  1789. Rect 0,15*33,12*33+3,33,1
  1790. For t= 0 To 11
  1791. If exrack(t) > -1
  1792. DrawBlock letters,t*33+1,15*33,exrack(t)
  1793. EndIf
  1794. Next
  1795. EndIf
  1796.  
  1797. ; draw menu items
  1798. Color 60,60,200
  1799. DrawImage letters,menux,menuy  ,39:Text menux+28,menuy-2,"Done"
  1800. If singleplayer = False And numplayers >1
  1801. DrawImage letters,menux,menuy+12,39:Text menux+28,menuy+10,"Pass"
  1802. EndIf
  1803. If tilesused < 100
  1804. DrawImage letters,menux,menuy+24,39:Text menux+28,menuy+22,"Swap Tiles"
  1805. EndIf
  1806. DrawImage letters,menux,menuy+36,39:Text menux+28,menuy+34,"Shuffle Rack"
  1807. DrawImage letters,menux,menuy+48,39:Text menux+28,menuy+46,tpw$(showpanel)
  1808. If singleplayer = True
  1809. DrawImage letters,menux,menuy+60,39:Text menux+28,menuy+58,"Reset Game"
  1810. EndIf
  1811. DrawImage letters,menux,menuy+72,39:Text menux+28,menuy+70,"Quit"
  1812.  
  1813. ;draw the tiles in play
  1814. Color 255,0,0
  1815. For tin.tiletype=Each tiletype
  1816. Rect tin\x*33-1+1,tin\y*33-1+1,34,34
  1817. DrawBlock letters,tin\x*33+1,tin\y*33+1,tin\tilenum+40
  1818. Next
  1819.  
  1820. Select showpanel
  1821. Case 0
  1822. Text 33*16,0,"Words played (points):"
  1823. row=1:col=0
  1824. For w.word=Each word
  1825. Color pcol(w\playernum)\r,pcol(w\playernum)\g,pcol(w\playernum)\b
  1826. Text 33*15+5+col*140,row*12+3,w\wordstring+" ("+w\points+")"
  1827. ;,w\wordstring+"("+w\startx+","+w\starty+")-("+w\endx+","+w\endy+")"+w\points
  1828. row = row+1:If row>33 Then col=col+1:row=1
  1829. Next
  1830. Case 1
  1831. Text 33*16,0,"Available Tiles:"
  1832. For t=0 To 26
  1833. kar$=Chr$(t+65):If t=26 Then kar$="Blank"
  1834. Text 33*16+15,t*12+15,kar$+" ("+distribution(t)+")"
  1835. Next
  1836. Case 2
  1837. Text 33*16,0,"Points per Tile:"
  1838. For t=0 To 26
  1839. kar$=Chr$(t+65):If t=26 Then kar$="Blank"
  1840. Text 33*16+15,t*12+15,kar$+" - "+points(t)
  1841. Next
  1842. Case 3
  1843. Text 33*16,0,"Tiles in the Bag:"
  1844. row=1:col=0
  1845. For t = 0 To 99
  1846. If t> 99-tilesused Then Color 255,255,0 Else Color 255,0,0
  1847. If shuffled(99-t) < 26 Then kar$ = Chr$(shuffled(99-t)+65) Else kar$="?" 
  1848. Text 33*15+25+col*40,row*12+3,kar$
  1849. row = row+1:If row>25 Then col=col+1:row=1
  1850. Next
  1851. End Select
  1852.  
  1853. End Function
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859. Function ShuffleRack()
  1860. ;shuffle the tiles in the rack
  1861. For t=0 To 100
  1862. f= Rnd(0,11)
  1863. s= Rnd(0,11)
  1864. temp = rack(f)
  1865. rack(f) = rack(s)
  1866. rack(s) = temp
  1867. Next
  1868. End Function
  1869.  
  1870.  
  1871.  
  1872. Function ShuffleTiles()
  1873. ;shuffle the  full bag of tiles
  1874. For t=0 To 1000
  1875. f= Rnd(0,100)
  1876. s=Rnd(0,100)
  1877. temp = shuffled(f)
  1878. shuffled(f) = shuffled(s)
  1879. shuffled(s) = temp
  1880. Next
  1881. End Function
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888. Function ClearBoard()
  1889. For t = 0 To 14
  1890. For s= 0 To 14
  1891. boardt(t,s)=-1
  1892. Next
  1893. Next
  1894. End Function
  1895.  
  1896.  
  1897.  
  1898. Function ClearRack()
  1899. For t = 0 To 11
  1900. rack(t) = -1
  1901. exrack(t) = -1
  1902. Next
  1903. End Function
  1904.  
  1905.  
  1906.  
  1907. Function ClearWordList()
  1908. For w.word=Each word
  1909. Delete w
  1910. Next
  1911. End Function
  1912.  
  1913.  
  1914.  
  1915. Function ClearTiles()
  1916. For tin.tiletype=Each tiletype
  1917. Delete tin
  1918. Next
  1919. End Function
  1920.  
  1921.  
  1922.  
  1923.  
  1924.  
  1925. Function DoIntro()
  1926.  
  1927. Delay 100
  1928.  
  1929. done = False
  1930.  
  1931. While Not done
  1932. Restore introletters
  1933. For x = 0 To 14
  1934. For y = 0 To 14
  1935. boardt(x,y) = -1
  1936. Next
  1937. Next
  1938. intletter$ = "a"
  1939. flash = False
  1940. While intletter$ <> "0" And (Not done)
  1941. Cls
  1942. For x = 0 To 14
  1943. For y = 0 To 14
  1944. If boardt(x,y) >= 0
  1945. DrawBlock letters,x*33+140,y*33+140,boardt(x,y)
  1946. EndIf
  1947. Next
  1948. Next
  1949. Read intletter$,x,y
  1950. If intletter$ <> "0"
  1951. boardt(x,y) = Asc(intletter$)-65
  1952. EndIf
  1953. If flash Then Color 255,0,0 Else Color 255,255,255
  1954. Text 250,490,"Press ESC to Play"
  1955. flash = Not flash
  1956. Flip
  1957. ; If KeyHit(88) SaveBuffer(FrontBuffer(),"SNAPHOT"+counter+".bmp")
  1958. If KeyHit(1) Then done = True
  1959. Delay 300
  1960. Wend
  1961. Delay 100
  1962. Wend
  1963.  
  1964. End Function
  1965.  
  1966.  
  1967. .introletters
  1968. Data "S",2,3
  1969. Data "C",3,3
  1970. Data "R",4,3
  1971. Data "A",5,3
  1972. Data "B",6,3
  1973. Data "B",7,3
  1974. Data "L",8,3
  1975. Data "E",9,3
  1976. Data "E",9,3
  1977. ;Data "E",9,3
  1978. ;Data "E",9,3
  1979. ;Data "E",9,3
  1980.  
  1981. Data "B",7,3
  1982. Data "Y",7,4
  1983. Data "Y",7,4
  1984. ;Data "Y",7,4
  1985. ;Data "Y",7,4
  1986. ;Data "Y",7,4
  1987.  
  1988.  
  1989. Data "M",5,2
  1990. ;Data "A",5,3
  1991. Data "R",5,4
  1992. Data "K",5,5
  1993. Data "K",5,5
  1994. ;Data "K",5,5
  1995. ;Data "K",5,5
  1996. ;Data "K",5,5
  1997.  
  1998. Data "I",3,1
  1999. Data "N",3,2
  2000. ;Data "C",3,3
  2001. Data "I",3,4
  2002. Data "T",3,5
  2003. Data "T",3,6
  2004. Data "I",3,7
  2005. Data "I",3,7
  2006. ;Data "I",3,7
  2007. ;Data "I",3,7
  2008. ;Data "I",3,7
  2009.  
  2010.  
  2011. Data "C",9,0
  2012. Data "O",9,1
  2013. Data "D",9,2
  2014. ;Data "E",9,3
  2015. Data "D",9,4
  2016. Data "D",9,4
  2017. ;Data "D",9,4
  2018. ;Data "D",9,4
  2019. ;Data "D",9,4
  2020.  
  2021.  
  2022. ;Data "I",3,1
  2023. Data "N",4,1
  2024. Data "N",4,1
  2025. ;Data "N",4,1
  2026. ;Data "N",4,1
  2027. ;Data "N",4,1
  2028.  
  2029. Data "B",1,7
  2030. Data "L",2,7
  2031. ;Data "I",3,7
  2032. Data "T",4,7
  2033. Data "Z",5,7
  2034. Data "B",6,7
  2035. Data "A",7,7
  2036. Data "S",8,7
  2037. Data "I",9,7
  2038. Data "C",10,7
  2039. Data "C",10,7
  2040. ;Data "C",10,7
  2041. ;Data "C",10,7
  2042. ;Data "C",10,7
  2043.  
  2044. Data "0",0,0s



  • 0

#11 egostar

egostar

    missing my father, I love my mother.

  • Administrador
  • 14.448 mensajes
  • LocationMéxico

Escrito 21 mayo 2009 - 04:22

Hola alextruenobur

Me tome la libertad de combinar los temas, para que no se pierda la idea de esto, postea en este siempre.

Además edite tu mensaje para que se vea un poco mejor con las etiquetas Delphi, te recomiendo que leas la guia del uso de las etiquetas

Salud OS
  • 0

#12 poliburro

poliburro

    Advanced Member

  • Administrador
  • 4.945 mensajes
  • LocationMéxico

Escrito 21 mayo 2009 - 04:51

Que interesante  :o  :o

busqué robot + pascal en google y me encontré esto:

http://pascal.source...txt/probots.htm
  • 0

#13 Caral

Caral

    Advanced Member

  • Moderador
  • PipPipPip
  • 4.266 mensajes
  • LocationCosta Rica

Escrito 21 mayo 2009 - 05:51

Hola
Perdón mi ignorancia pero estas cositas no me resultaron conocidas:


delphi
  1. End Type


o


delphi
  1. EndIf


o


delphi
  1. Dim pcol.coltype(4)


0


delphi
  1. Dim boardbg(15,15)
  2. Dim boardt(15,15)


0


delphi
  1. For x=0 To 14
  2. For y = 0 To 14
  3. Read boardbg(x,y)
  4. Next
  5. Next
  6. ;star=0,dw,tw,dl,tl=4,b=5
  7. Data 2,5,5,3,5,5,5,2,5,5,5,3,5,5,2
  8. .........


y asi otras.
No se, por eso pregunto, me sonaron a código VB. :$
Hay esto en Delphi??, se usa??.
Saludos

  • 0

#14 cHackAll

cHackAll

    Advanced Member

  • Administrador
  • 599 mensajes

Escrito 21 mayo 2009 - 06:12

...Hay esto en Delphi??, se usa??...


delphi
  1. type
  2. TType = record
  3. // . . .
  4. end; // End Type



delphi
  1. if Algo1.Enabled then
  2.   begin
  3. // . . .
  4.   end; // EndIf



delphi
  1. type
  2. pcol = record // no me convence!
  3.   coltype: array [0..3] of Variant; // Dim pcol.coltype(4)
  4. // . . .



delphi
  1. var // este si me convence
  2. boardbg: array [0..14, 0..14] of Variant; // Dim boardbg(15,15)



delphi
  1. for x := 0 to 14 do // For x=0 To 14
  2.   for y := 0 to 14 do // For y = 0 To 14
  3.   Read(boardbg(x,y)); // Read boardbg(x,y)
  4. {implicito en Delphi} // Next
  5. {declaracion e inicializacion}// ;star=0,dw,tw,dl,tl=4,b=5
  6. {llamada a "Data" con X args}Data 2,5,5,3,5,5,5,2,5,5,5,3,5,5,2
  7. {puntos suspensivos}.........



Salud
  • 0

#15 alextruenobur

alextruenobur

    Newbie

  • Miembros
  • Pip
  • 5 mensajes
  • Locationvenezuela

Escrito 21 mayo 2009 - 09:14

es un programa en lenguaje pascal por eso son todas esas cositas  lo q quiero es q complile q corra y no se como hacerlo bueno la verdad no es ese prorgama si se dan cuenta no es lo q estoy pidiendo solo es un ejemplo on bosquejo de lo q quiero hacer y exactamente no es el mismo juego no es el robot q quiero hacer
  • 0

#16 egostar

egostar

    missing my father, I love my mother.

  • Administrador
  • 14.448 mensajes
  • LocationMéxico

Escrito 21 mayo 2009 - 09:19

es un programa en lenguaje pascal por eso son todas esas cositas  lo q quiero es q complile q corra y no se como hacerlo bueno la verdad no es ese prorgama si se dan cuenta no es lo q estoy pidiendo solo es un ejemplo on bosquejo de lo q quiero hacer y exactamente no es el mismo juego no es el robot q quiero hacer


Hola alextruenobur

^o| *-) 8-) Lo que quieres es que se traduzca a pascal????

Y si no es lo que necesitas, para que colocar el código, no entiendo .....

Salud OS
  • 0

#17 JoAnCa

JoAnCa

    Advanced Member

  • Miembro Platino
  • PipPipPip
  • 775 mensajes
  • LocationPinar del Río, Cuba

Escrito 22 mayo 2009 - 09:49

Coincido con Caral, este codigo cada vez que lo leo se me parece mas a BASIC

Type
...
End Type

if ...
else ...
endif

for con Next

asignaciones con = en lugar de :=


Digo, a lo mejor delphi no se parece a pascal y por eso lo confundo con basic  :s

Es posible que lo que desee alextruenobur sea lo que pregunta egostar, traducirlo a pascal

  • 0

#18 Delphius

Delphius

    Advanced Member

  • Administrador
  • 6.295 mensajes
  • LocationArgentina

Escrito 22 mayo 2009 - 11:49

Hola,

Creo que alextruenobur tiene una confusión enorme, habla de Pascal pero el código que expone es Visual Basic.

No se si se trata de que lo que busca es "traducir" el código a Pascal (o en todo caso a Delphi) ó si por el contrario usa VB y por alguna confusión piensa o tiene entendido que esa sintaxis es Pascal.
Si lo que buscas es traducir, pues... considero que la mejor medicina es leer la ayuda de Pascal y familiarizarte con la sintaxis. El libro de Luis Joyanes Aguilar es muy bueno.
Por el contrario... si sabes al menos lo básico de Pascal, deberí­as estar consciente de que esa sintaxis no es Pascal. Y en este caso tu duda o inquietud deberí­a haber sido algo parecido a esto: "miren encontré o tengo este código que está en otro lenguaje y me cuesta traducirlo a Pascal".

Pero claro, tu dices que no lo puedes compilar... y eso me lleva a dudar ¿sabes o no al menos algo de Pascal? ¿Qué tanto sabes de programación? ¿Hasta donde llegan tus conocimientos?

alextruenobur, con todo respecto, serí­a mejor que te tomaras el debido tiempo para expresar tus inquietudes, tus dudas e ideas.

Suena difí­cil creer que no tengas al menos una visión o panorama parcial de como enfocar al trabajo. Sigo sosteniendo que serí­a más apropiado que hagas un esfuerzo por abstraer una idea.

Por ejemplo, un tablero se puede traducir en una matriz, se puede disponer de un array dinámico (o fijo, como gustes) para llevar el listado de las palabras. Al menos estas dos estructuras de datos pueden ser empleadas para enfocar el diseño lógico del sistema. El uso de records también pueden ser de utilidad.

Sinceramente no se que esperas al mostrarnos semejante cantidad de código. Cuando lo vi me dije... ¡A no, ni loco me voy a poner a estudiarlo todo! Una parte, visión o idea puedo aceptar... pero exponer de frente un código de semejante tamaño es un atropello.

Y no es porque sea vago, sino porque considero que eso es ya un abuso para con quienes amablemente quieren asesorarte. Lo primero que se me viene a la mente es: "les paso el código y me lo arreglan".

Tal vez es una mala apreciación, y una falta de mi parte el pensar así­. Tal vez no es tu intensión, pero debido a semejante pedido es fácil pensar y actuar de esa manera.

Hablas de Pascal... ¿Te refieres a Turbo Pascal? ¿O por el contrario a Object Pascal (Delphi)?
En Delphi algunas cosas serán más fáciles de hacer que en Turbo Pascal. Si se trata de TP (Turbo Pascal), lo más odioso y tedioso es estar "pintando" en pantalla. Pero esto es ya una apreciación visual, lo importante es el aspecto lógico.

Si se trata de un trabajo a presentar, que es lo más problable, ¿no crees que serí­a oportuno pedir ayuda y guia a tu profesor? El profesor no está únicamente para dictar la clase. Se supone que debe ser un guí­a, asesorar a sus alumnos. Está en tu derecho de pedir asistencia.

Yo no se que pensar de todo esto...

Saludos,
  • 0

#19 BlackDaemon

BlackDaemon

    Member

  • Miembros
  • PipPip
  • 22 mensajes

Escrito 28 mayo 2009 - 06:23

Hola

Pienso que al amigo le dieron una tarea, este quiere que le hagan el código, luego al ver que nadie tení­a intención de hacerlo expuso un "pequeño" ejemplo en VB de algo "parecido" a lo que el necesita, pero como veo que no tiene la menor idea (como yo xD) está confundido y pensó que es sintaxis de pascal, en fin, por cierto yo me pregunto, si le dieron la tarea esa, para mi es complicada y imagino que la deben de dar en alguna asignatura de programación I  o II, de la universidad, peroooo cómo llegó el tí­o este ahí­ sin saber la sitanxis por lo menos?  :|

Actualmente estoy llevando introducción a la programación en c#, vamos, diagramas de flujo y esas cosillas, luego pasar a código, pero venga va, yo creo que se reconocer lo básico de la sintaxis de c#

Espero que al amigo pueda resolver su problema con ayuda del foro o de dios :)

Saludos!

PD todo lo que dije no se malinterprete, está fuera del tema, lo sé, no fué con mala intención ni nada  (y)
  • 0




IP.Board spam blocked by CleanTalk.