diff options
author | Will Robertson <aliask@rockbox.org> | 2007-08-05 09:20:20 +0000 |
---|---|---|
committer | Will Robertson <aliask@rockbox.org> | 2007-08-05 09:20:20 +0000 |
commit | 97c4694bc2b82f4f2274b277f8bce22aaf348a22 (patch) | |
tree | 2d005c7b3a43d580795d89478511d59ad06584e6 | |
parent | 739f0ecd9490d2b59f29c27df520269968a3b956 (diff) | |
download | rockbox-97c4694bc2b82f4f2274b277f8bce22aaf348a22.tar.gz rockbox-97c4694bc2b82f4f2274b277f8bce22aaf348a22.zip |
FS#7536 - Make the superdom score calculation more elegant - thanks to Johnathon Mihalop
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14188 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugins/superdom.c | 133 |
1 files changed, 27 insertions, 106 deletions
diff --git a/apps/plugins/superdom.c b/apps/plugins/superdom.c index b39b00a6a3..f963d7f828 100644 --- a/apps/plugins/superdom.c +++ b/apps/plugins/superdom.c | |||
@@ -350,112 +350,33 @@ void draw_board(void) { | |||
350 | } | 350 | } |
351 | 351 | ||
352 | int calc_strength(bool colour, int x, int y) { | 352 | int calc_strength(bool colour, int x, int y) { |
353 | /* Yes, I know. Please, if you know how, fix it. */ | 353 | int a, b, score=0; |
354 | int score=0; | 354 | for (a = -1; a < 2; a++){ |
355 | if(board[x][y].colour == colour) { | 355 | for (b = -1; b < 2; b++){ |
356 | score+=10; | 356 | if (b == 0){ |
357 | } | 357 | if(board[x + a][y].colour == colour) |
358 | if(board[x+1][y].colour == colour) { | 358 | score+=10; |
359 | score+=10; | 359 | if(((board[x + a][y].colour == colour) && board[x + a][y].tank) || ((board[x + a][y].colour == colour) && board[x + a][y].farm)) |
360 | } | 360 | score+=30; |
361 | if(board[x][y+1].colour == colour) { | 361 | if(((board[x + a][y].colour == colour) && board[x + a][y].plane) || ((board[x + a][y].colour == colour) && board[x + a][y].ind)) |
362 | score+=10; | 362 | score+=40; |
363 | } | 363 | if((board[x + a][y].colour == colour) && board[x + a][y].nuke) |
364 | if(board[x-1][y].colour == colour) { | 364 | score+=20; |
365 | score+=10; | 365 | if((board[x + a][y].colour == colour) && board[x + a][y].men) |
366 | } | 366 | score+=(board[x + a][y].men*133/1000); |
367 | if(board[x][y-1].colour == colour) { | 367 | } else if (a == 0){ |
368 | score+=10; | 368 | if(board[x][y + b].colour == colour) |
369 | } | 369 | score+=10; |
370 | if((board[x][y].colour == colour) && board[x][y].tank) { | 370 | if(((board[x][y + b].colour == colour) && board[x][y + b].tank) || ((board[x][y + b].colour == colour) && board[x][y + b].farm)) |
371 | score+=30; | 371 | score+=30; |
372 | } | 372 | if(((board[x][y + b].colour == colour) && board[x][y + b].plane) || ((board[x][y + b].colour == colour) && board[x][y + b].ind)) |
373 | if((board[x+1][y].colour == colour) && board[x+1][y].tank) { | 373 | score+=40; |
374 | score+=30; | 374 | if((board[x][y + b].colour == colour) && board[x][y + b].nuke) |
375 | } | 375 | score+=20; |
376 | if((board[x][y+1].colour == colour) && board[x][y+1].tank) { | 376 | if((board[x][y + b].colour == colour) && board[x][y + b].men) |
377 | score+=30; | 377 | score+=(board[x][y + b].men*133/1000); |
378 | } | 378 | } |
379 | if((board[x-1][y].colour == colour) && board[x-1][y].tank) { | 379 | } |
380 | score+=30; | ||
381 | } | ||
382 | if((board[x][y-1].colour == colour) && board[x][y-1].tank) { | ||
383 | score+=30; | ||
384 | } | ||
385 | if((board[x][y].colour == colour) && board[x][y].plane) { | ||
386 | score+=40; | ||
387 | } | ||
388 | if((board[x+1][y].colour == colour) && board[x+1][y].plane) { | ||
389 | score+=40; | ||
390 | } | ||
391 | if((board[x][y+1].colour == colour) && board[x][y+1].plane) { | ||
392 | score+=40; | ||
393 | } | ||
394 | if((board[x-1][y].colour == colour) && board[x-1][y].plane) { | ||
395 | score+=40; | ||
396 | } | ||
397 | if((board[x][y-1].colour == colour) && board[x][y-1].plane) { | ||
398 | score+=40; | ||
399 | } | ||
400 | if((board[x][y].colour == colour) && board[x][y].ind) { | ||
401 | score+=40; | ||
402 | } | ||
403 | if((board[x+1][y].colour == colour) && board[x+1][y].ind) { | ||
404 | score+=40; | ||
405 | } | ||
406 | if((board[x][y+1].colour == colour) && board[x][y+1].ind) { | ||
407 | score+=40; | ||
408 | } | ||
409 | if((board[x-1][y].colour == colour) && board[x-1][y].ind) { | ||
410 | score+=40; | ||
411 | } | ||
412 | if((board[x][y-1].colour == colour) && board[x][y-1].ind) { | ||
413 | score+=40; | ||
414 | } | ||
415 | if((board[x][y].colour == colour) && board[x][y].farm) { | ||
416 | score+=30; | ||
417 | } | ||
418 | if((board[x+1][y].colour == colour) && board[x+1][y].farm) { | ||
419 | score+=30; | ||
420 | } | ||
421 | if((board[x][y+1].colour == colour) && board[x][y+1].farm) { | ||
422 | score+=30; | ||
423 | } | ||
424 | if((board[x-1][y].colour == colour) && board[x-1][y].farm) { | ||
425 | score+=30; | ||
426 | } | ||
427 | if((board[x][y-1].colour == colour) && board[x][y-1].farm) { | ||
428 | score+=30; | ||
429 | } | ||
430 | if((board[x][y].colour == colour) && board[x][y].nuke) { | ||
431 | score+=20; | ||
432 | } | ||
433 | if((board[x+1][y].colour == colour) && board[x+1][y].nuke) { | ||
434 | score+=20; | ||
435 | } | ||
436 | if((board[x][y+1].colour == colour) && board[x][y+1].nuke) { | ||
437 | score+=20; | ||
438 | } | ||
439 | if((board[x-1][y].colour == colour) && board[x-1][y].nuke) { | ||
440 | score+=20; | ||
441 | } | ||
442 | if((board[x][y-1].colour == colour) && board[x][y-1].nuke) { | ||
443 | score+=20; | ||
444 | } | ||
445 | if((board[x][y].colour == colour) && board[x][y].men) { | ||
446 | score+=(board[x][y].men*133/1000); | ||
447 | } | ||
448 | if((board[x+1][y].colour == colour) && board[x+1][y].men) { | ||
449 | score+=(board[x+1][y].men*133/1000); | ||
450 | } | ||
451 | if((board[x][y+1].colour == colour) && board[x][y+1].men) { | ||
452 | score+=(board[x][y+1].men*133/1000); | ||
453 | } | ||
454 | if((board[x-1][y].colour == colour) && board[x-1][y].men) { | ||
455 | score+=(board[x-1][y].men*133/1000); | ||
456 | } | ||
457 | if((board[x][y-1].colour == colour) && board[x][y-1].men) { | ||
458 | score+=(board[x][y-1].men*133/1000); | ||
459 | } | 380 | } |
460 | return score; | 381 | return score; |
461 | } | 382 | } |