|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#61 |
|
Senior Member
Iscritto dal: Nov 2005
Messaggi: 1545
|
mi spiego meglio... se la gemma che non deve uscire è la nr 3. se esce 4 diventa 5 se esce 5 diventa la 0. Ma se esce 0 rimane 0. Quindi la 0 ha probabilità doppia di uscire!!! Giusto?
|
|
|
|
|
|
#62 | |
|
Bannato
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
|
Quote:
adesso Bonfo deve risolvere... |
|
|
|
|
|
|
#63 | |
|
Senior Member
Iscritto dal: Nov 2005
Messaggi: 1545
|
Quote:
ahhh no perchè c'è il -1 nel module... ho capito... però continuo a non essere sicuro sul firstGemExtraction e secondGemExtraction... boh |
|
|
|
|
|
|
#64 |
|
Senior Member
Iscritto dal: Nov 2005
Messaggi: 1545
|
e ora ho capito anche quelli... però ora li rinomino
|
|
|
|
|
|
#65 | |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Quote:
Se la gemma estratta è la 3 e N = 5 (quindi al massimo posso estrarre 4) di fatto la popolazione su cui estraggo è: 0, 1, 2, 4 Infatti passando al random generator N-1 (cioè 4) posso tirare fuori N-1 numeri da 0 a 3...ma se l'ultima gemma estratta è 3, tutti i numeri che posso estrarre >= 3 vengono incrementati...quindi mi riporto in una situazione corretta, esattamente come sopra: 0, 1, 2, 4... |
|
|
|
|
|
|
#66 |
|
Senior Member
Iscritto dal: Nov 2005
Messaggi: 1545
|
sìsì capito tutto... era il first ed il second che non mi ritornava più che altro... ma ora ricordo anche che la gemma deve essere diversa non dall'ultima ma dalla penultima
|
|
|
|
|
|
#67 | |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Quote:
PS: questa cosa è testata... |
|
|
|
|
|
|
#68 |
|
Senior Member
Iscritto dal: Nov 2005
Città: Bologna
Messaggi: 1303
|
Modificata GemFactory:
Codice:
private int firstGemRandomIndex = GEM_TYPES.length;
private int secondGemRandomIndex = GEM_TYPES.length;
private int firstChestRandomIndex = CHEST_TYPES.length;
private int secondChestRandomIndex = CHEST_TYPES.length;
private boolean firstGemExtraction = true;
private boolean firstChestExtraction = true;
Codice:
public Gem createRandomGem()
{
int module = GEM_TYPES.length - 1;
if(firstGemExtraction)
{
module = GEM_TYPES.length;
firstGemExtraction = false;
}
int randomIndex = randomGenerator.extract(module);
if(randomIndex >= secondGemRandomIndex)
{
randomIndex = (randomIndex + 1) % GEM_TYPES.length;
}
secondGemRandomIndex = firstGemRandomIndex;
firstGemRandomIndex = randomIndex;
return create(GEM_TYPES[randomIndex]);
}
public Gem createRandomChest()
{
int module = CHEST_TYPES.length - 1;
if(firstChestExtraction)
{
module = CHEST_TYPES.length;
firstChestExtraction = false;
}
int randomIndex = randomGenerator.extract(module);
if(randomIndex >= secondChestRandomIndex)
{
randomIndex = (randomIndex + 1) % CHEST_TYPES.length;
}
secondChestRandomIndex = firstChestRandomIndex;
firstChestRandomIndex = randomIndex;
return create(CHEST_TYPES[randomIndex]);
}
Prossimo Test: Codice:
public void testNotTwoEqualChestSequence()
{
int[] percentages={1, 1};
factory = GemFactory.createForTesting(new MockRandomGenerator(percentages));
assertNotSame(factory.createRandomChest(),factory.createRandomChest());
}
|
|
|
|
|
|
#69 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Testate anche questa sequenza di estrazioni che DEVE funzionare: diamond_chest, diamond_gem, diamond_chest
|
|
|
|
|
|
#70 | |
|
Senior Member
Iscritto dal: Nov 2005
Messaggi: 1545
|
Quote:
Codice:
public void testSameIndexForGemAndChest()
{
int[] percentages={1, 0, 1};
factory = GemFactory.createForTesting(new MockRandomGenerator(percentages));
Gem gem = factory.createRandomGem();
assertSame(gem.getType(), RUBY);
factory.createRandomGem();
gem = factory.createRandomChest();
assertSame(gem.getType(), RUBY_CHEST);
}
|
|
|
|
|
|
|
#71 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Secondo me no...basta provare
|
|
|
|
|
|
#72 | |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Quote:
|
|
|
|
|
|
|
#73 | |
|
Senior Member
Iscritto dal: Oct 2002
Città: San Jose, California
Messaggi: 11794
|
Quote:
__________________
"We in the game industry are lucky enough to be able to create our visions" @ NVIDIA |
|
|
|
|
|
|
#74 |
|
Bannato
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
|
cancellare post plz
|
|
|
|
|
|
#75 |
|
Senior Member
Iscritto dal: Nov 2005
Messaggi: 1545
|
che post?
|
|
|
|
|
|
#76 | |
|
Bannato
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
|
Quote:
|
|
|
|
|
|
|
#77 |
|
Senior Member
Iscritto dal: Nov 2005
Messaggi: 1545
|
mi spiego meglio... manca ancora un test per il task... Ovvero quello che testa che Grid inserisca una GemsPair con un Chest (o 2
Ultima modifica di Ufo13 : 26-01-2006 alle 20:39. |
|
|
|
|
|
#78 | |
|
Bannato
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
|
Quote:
Codice:
public void testGemQueueCreatesChestsToo()
{
int mockValues[] = {0, 1, 99, 1};
MockRandomGenerator randomGenerator = new MockRandomGenerator(mockValues);
gemQueue = GemQueue.createForTesting(randomGenerator);
gemQueue.fillQueueRandomly();
assertSame(gemQueue.extract().getType(), RUBY);
assertSame(gemQueue.extract().getType(), RUBY_CHEST);
}
|
|
|
|
|
|
|
#79 | ||
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Quote:
Codice:
public void testChestGemChestSequence()
{
int indexes[] = {99, 1, 0, 4, 99, 1};
factory = GemFactory.createForTesting(new MockRandomGenerator(indexes));
GemType firstChest = factory.createRandomDroppable().getType();
factory.createRandomDroppable().getType();
GemType lastChest = factory.createRandomDroppable().getType();
assertSame("first chest was not of same type of last chest", firstChest, lastChest);
}
public void testGemGemChestGemSequence()
{
int indexes[] = {0, 1, 0, 2, 99, 3, 0, 1};
factory = GemFactory.createForTesting(new MockRandomGenerator(indexes));
GemType firstGem = factory.createRandomDroppable().getType();
factory.createRandomDroppable().getType();
factory.createRandomDroppable().getType();
GemType lastGem = factory.createRandomDroppable().getType();
assertSame("first Gem was not of same type of last Gem", firstGem, lastGem);
}
|
||
|
|
|
|
|
#80 |
|
Senior Member
Iscritto dal: Nov 2005
Messaggi: 1545
|
falliscono?
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 08:19.



















