WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
 

Help with assembly, I need help with a code to make a puzzle.

smokymo
Quote Post


New Member
*

Group: Members
Posts: 6
Member No.: 15211
Joined: 17-November 08


Hello, I need help with a puzzle I am trying to make in assembly. the description is down below

There is a famous puzzle invented in the 19th century which you may have seen, or indeed tried to solve. Imagine a tray consisting of 16 spaces arranged in four rows. So, there are four slots in each row. On these 16 spaces, there are 15 tiles numbered in ascending order. The space is at the bottom right-hand corner. This is known as the “Golden Board” or, more simply, the solution. An approximation of what it looks like is shown in the table below:
______________________________
|1|2|3|4|
|5|6|7|8|
|9|10|11|12|
|13|14|15|_|
_________________________________
Now imagine that these tiles are rearranged in some random order that looks something like this:
_____________________________
|1|6|4|2\
|7|_|11|3|
|5|9|10|8|
|13|15|15|12|
_______________________________

In order to solve the puzzle, you have to slide them around the board to arrive back at the initial “Golden Board”.

I have to do the following:

1. load up a grid on screen and initialise it so that the tiles are in the correct order.
2. Allow the user to press the “r” key to generate a random starting position.
3. allow the user to make a move. (how you do this is up to you)
4. determine how many moves it takes the player to win the game. When a winning position has been reached, (I.E., when the tiles are back in order) you should print a message telling the user how many moves it took.

My question is how do I display the tile grid with numbers in them and allow user to select a tile. Any help is appreciated.Thanks
PMEmail Poster
Top
JimG
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 725
Member No.: 11
Joined: 16-May 04


QUOTE
My question is how do I display the tile grid with numbers in them and allow user to select a tile.


I would suggest using bitmaps (bmps) to display a picture of the number. By doing this, you could switch to using letters rather than numbers, or switch to a drawing sectioned up into pieces or any number of other ideas, without changing any other code. By telling the program which set of bmps to use, it could handle any foreign language, abstract line drawings, the ideas are endless.

Which brings us to how the user selects a tile. I would use the arrow keys. A down arrow would move the tile above the space into the space. A left arrow would move the tile that is to the right of the space, into the space. etc. Ignore illegal moves. This would be immediate moves, press the key and the move takes place, no need to press the enter key. This would work no matter if you use numbers, letters, pictures, or whatever. You would probably also have to allow the user to click on a tile with the mouse to select it for the keyboard challenged people, but using the arrows would be much quicker. You could keep track of the time it takes the user to solve a puzzle.

Also, I wouldn't limit myself to a four by four puzzle. The code could would be virtually identical for any size puzzle you wanted, whether 2 by 2 or 100 by 200.
PMEmail Poster
Top
smokymo
Quote Post


New Member
*

Group: Members
Posts: 6
Member No.: 15211
Joined: 17-November 08


I am sort of geting an idea but can please explain it a bit further.

How do draw a tile grid 4 by 4 with numbers in them(Do I have to switch to vga mode, Do I have to have a loop waiting for the user to press the arrow key or buffer.)
Bitmaps ?
Maybe an example piece of code please coz I have a hard time grasping this.
By the way, Ihave to make this for x86 platform and I using Tasm and tlink if it matters.
Thanks
PMEmail Poster
Top
JimG
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 725
Member No.: 11
Joined: 16-May 04


I afraid I can't really help here. If you were writing a masm program for windows, no problem. I haven't written a dos program in a very long time, and never one with graphics, nor have I ever used tasm. Hopefully someone else will step up and help.
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google