1. Better strategy?

I am trying to devise a lock-step scheduling algorithm, and it seems to help me to phrase it in terms of a simple colour card game, with greedy/naughty children and a bowl of sweets. Just wanted to see if anyone can spot any simplifications, glaring errors, or had any other equally whacky ideas. I need a meaningful english language strategy description rather than any code.

Let there be a black card for the teacher, and (pair per child) two red, two orange, two yellow, two green, two blue, etc. 
The teacher starts with the black card and all colour2 cards in their hand. There are no cards on the table at the start. 
All children start with a colour1 card and wait for the matching colour2 card to be put on the table. 
<loop> 
The teacher selects a colour2 card and puts it down on the table, let's say red2, and waits for red1. 
The child with red1 picks up red2, takes a sweet, puts down red1, and waits for the black card. 
The teacher can now pick up red1, put down black, and wait for red2. 
The child with the red2 can now swap it for the black card, and wait for red1. 
The teacher can now pick up the red2 card, put down red1, and wait for the black. 
The child with the black card can pick up red1 and put down the black, and wait for red2. 
The teacher can now pick up the black and select another colour2 (goto loop) 
 
Notes:  Only one player is ever waiting for a specific card[1], different to the one they just put down[2]. 
        Nobody can ever put down a card they are not currently holding[3]. 
        There may be a simpler way (perhaps with red1<->red2 swapped per round) but I can't see it. 
        [1] possibly important [2] important [3] extremely important! 

Pete

PS Anyone suggesting using tasks will be e-kneecapped getlost (I seek strategy description, not code)

new topic     » topic index » view message » categorize

2. Re: Better strategy?

petelomax said...

I am trying to devise a lock-step scheduling algorithm, and it seems to help me to phrase it in terms of a simple colour card game, with greedy/naughty children and a bowl of sweets. Just wanted to see if anyone can spot any simplifications, glaring errors, or had any other equally whacky ideas. I need a meaningful english language strategy description rather than any code.

Let there be a black card for the teacher, and (pair per child) two red, two orange, two yellow, two green, two blue, etc. 
The teacher starts with the black card and all colour2 cards in their hand. There are no cards on the table at the start. 
All children start with a colour1 card and wait for the matching colour2 card to be put on the table. 
<loop> 
The teacher selects a colour2 card and puts it down on the table, let's say red2, and waits for red1. 
The child with red1 picks up red2, takes a sweet, puts down red1, and waits for the black card. 
The teacher can now pick up red1, put down black, and wait for red2. 
The child with the red2 can now swap it for the black card, and wait for red1. 
The teacher can now pick up the red2 card, put down red1, and wait for the black. 
The child with the black card can pick up red1 and put down the black, and wait for red2. 
The teacher can now pick up the black and select another colour2 (goto loop) 
 
Notes:  Only one player is ever waiting for a specific card[1], different to the one they just put down[2]. 
        Nobody can ever put down a card they are not currently holding[3]. 
        There may be a simpler way (perhaps with red1<->red2 swapped per round) but I can't see it. 
        [1] possibly important [2] important [3] extremely important! 

Pete

PS Anyone suggesting using tasks will be e-kneecapped getlost (I seek strategy description, not code)

Pete,

It might help if we knew (i) the context that requires such an algorithm and (ii) what volumes are involved and (iii) is it for something in real-time. Your description implies a synchronous algorithm, could it be asynchronous instead? Note: I am not suggesting using tasks..

According to the internet (in the context of multiplayer RTS games) You'll want to do client side prediction to deal with latency issues.

Spock

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu