Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Open Source Projects
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Open Source Projects The place to discuss Basic4ppc open source applications.


Pocket Burning Sand (Open Source)


Reply
 
LinkBack Thread Tools Display Modes
  #221 (permalink)  
Old 12-14-2007, 03:37 PM
Basic4ppc Veteran
 
Join Date: Nov 2007
Posts: 316
Awards Showcase
Beta Tester 
Total Awards: 1
Default Ive made a logic error

AG new library is faster.

Unfortnuantely Ive realised something which has only been apparent now Im working on the reactions.

My logic for the movement of pixels was slightly wrong

It should be two independent steps
If u can move vertically do so,
if u can move horizontally do so.


it was
try and move verticle & horizontal amounts, if u can do it
If u cant just do the horizontal amount


The difference in these two logics can be demonstrated with the following glitch in the current version
It takes a long time for a pile of water to level out

What happens top water molecule cant move down and (left) say so will just move left. but then may next try to move down and right, not be able to do it so just move right! So it goes back to where it was without falling down!

Sorry everyone, Particularly AG, can u alter that please?
It also helps with the reactions - I will explain later when I release that
Reply With Quote
  #222 (permalink)  
Old 12-14-2007, 03:53 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,690
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

I suppose this is really for Colin. It is a code fragment showing how I think the library might handle interaction rules efficiently.

Basically it needs an array of colours (remember that the top byte needs to be 0xFF = 256 on a PPC) with the background at index 0.
It would also need arrays of rules, probabilities, and two of colours to change the interacting particles into - one or both of which could be 0 (clear).

A rule entry would be a number - the product of one colour index * number of colurs + the other colour index - the correspponding entries in the other arrays are obvious.

The library would build a set of larger probability and change colour arrays all numcolurs * numcolours long and zero them. It would take each rule and add the probability and change colours at the rule index in the new arrays. It would also commutate the rule so it only needs to be specified once in the passed rule array.

The idea is that in the timer loop when moving a colour the destination colour is read and the rule index calculated from the particles own colour and the probability looked up. If not zero then the interaction would be calculated and performed. Cleared particles would be set to backgrgound and would percolate away as normal but invisibly. There is no chance of doing any further manipulation and retaining some decent level of performance.

Comments welcome.
Attached Files
File Type: txt RuleCode.txt (1.7 KB, 3 views)
Reply With Quote
  #223 (permalink)  
Old 12-14-2007, 04:05 PM
Basic4ppc Veteran
 
Join Date: Nov 2007
Posts: 316
Awards Showcase
Beta Tester 
Total Awards: 1
Default

I'll give that some thought - sounds good. But the particle being hit cant change unless it searches thro the whole array to find what is at that x,y position Thats why I have only the hitting pixel affected. Works in practice
Hold on a bit tho before coding that lot because Im still middevelopment!

Dont like the idea of black pixels just perculating away tho. Just a line to say if pcolor=cBlack then send it to the destroy routine much more efficient. Then can use that slot in the array

Last edited by colin9876 : 12-14-2007 at 04:19 PM.
Reply With Quote
  #224 (permalink)  
Old 12-14-2007, 04:21 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,690
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by colin9876 View Post
I'll give that some thought - sounds clever. But the particle being hit cant change unless it searches thro the whole array to find what is at that x,y positiom
You're right - missed that!

Quote:
Dont like the idea of black pixels just perculating away tho. Just a line to say if pcolor=cBlack then send it to the destroy routine much more efficient. Then can use that slot in the array
I thought that I found a problem with that, but I can't now think what it was so you're probably right again.

Modified logic attached - didn't see much sdifference myself however. New property DllVersion added - this one is 2.1.
Attached Files
File Type: zip BitmapHandler2Dll.zip (5.3 KB, 4 views)
Reply With Quote
  #225 (permalink)  
Old 12-14-2007, 04:31 PM
Basic4ppc Veteran
 
Join Date: Nov 2007
Posts: 316
Awards Showcase
Beta Tester 
Total Awards: 1
Default fantastic but

Nearly there, the reason u didnt notice much difference is because the logic change also needs the line re move sideways to go to
if getcol(nx,ny) <> bcolor
then nx=x(i)

Then the next bit is
if nx<>x(i) or ny<>y(i){
unplot (x(i),y(i))
plot(nx, ny)
}

Last edited by colin9876 : 12-14-2007 at 04:58 PM.
Reply With Quote
  #226 (permalink)  
Old 12-14-2007, 04:36 PM
Basic4ppc Veteran
 
Join Date: Nov 2007
Posts: 316
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Sorry that really is the last change!, but that is a critical one for things to react properly

Last edited by colin9876 : 12-14-2007 at 04:39 PM.
Reply With Quote
  #227 (permalink)  
Old 12-14-2007, 04:38 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,690
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by colin9876 View Post
But the particle being hit cant change
A particle could check if it is still the same colour when it's its' time to move. Unlike the former GetPixel the pointer based GetColor should be quite a cheap operation. It could then reset its probability and gravity from arrays passed alongside the colour array in initialise. The same tables could be used by AddElement and would help efficiency a bit.

EDIT :- It could also destroy itself if it was now background
Reply With Quote
  #228 (permalink)  
Old 12-14-2007, 04:42 PM
Basic4ppc Veteran
 
Join Date: Nov 2007
Posts: 316
Awards Showcase
Beta Tester 
Total Awards: 1
Default

ok good idea,

Back to the
move horiz
move vert

the reason the change hasnt made any difference yet is because it still only moves down if it moves horizontally. See the other line change required above!! Because the actual make the move was still within the horizontal move if statement!)

Last edited by colin9876 : 12-14-2007 at 04:56 PM.
Reply With Quote
  #229 (permalink)  
Old 12-14-2007, 05:00 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,690
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Version 2.2 - still looks much the same end result to me!
Attached Files
File Type: zip BitmapHandler2Dll.zip (5.4 KB, 4 views)
Reply With Quote
  #230 (permalink)  
Old 12-14-2007, 05:36 PM
Basic4ppc Veteran
 
Join Date: Nov 2007
Posts: 316
Awards Showcase
Beta Tester 
Total Awards: 1
Default Just out of interest

Bumps do level out a bit faster now the logics better
The reason hills dont level out quicker is because the outer dropping particles stop the inner ones from moving - but I think thats how BS is supposed to be. Its like that in th PC version

Im very happy with how its comming along. New library is better than ever. Its running amazingly well.

Last edited by colin9876 : 12-14-2007 at 05:40 PM.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tippy v.1.0 [open source] N1c0_ds Share Your Creations 4 Yesterday 10:08 PM
Personal Pocket PC Wiki tsteward Open Source Projects 120 11-11-2008 09:55 AM
Another Pocket Wiki digitaldon37 Open Source Projects 1 09-17-2008 11:01 AM
Pocket Burning Sand neilnapier Questions & Help Needed 2 11-05-2007 08:53 PM
dzSpy - Spy and Task Manager App - Open Source dzt Share Your Creations 3 07-15-2007 06:21 AM


All times are GMT. The time now is 04:07 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0