Contest Code

  Home arrow Contest Code arrow Risk - print_map($game, $some_array_of...
CONTEST CODE

Risk - print_map($game, $some_array_of_size_40)
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2003-07-16

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    A function to print current Risk map, with small land numbers, number of soldiers and "something" more for each land.
    "something" is whatever you put in $some_array_of_size_40[$land_number]
    I use this to debug heuristics calculation (menaces from each land to a given one, number of moves to each land, ...)
    Based on my table-map thing, of course.

    By : gatopeich

    <?PHP
    $map_head ="<html>
    <head>
    <title>Risk Table Map</title>
    <style type=\"text/css\">
    table {font-size:10;}
    td { text-align: left; vertical-align: top;}
    .N_America { background-color: #ffff22;}
    .S_America { background-color: #2255ff;}
    .Europe { background-color: #ff22ff;}
    .Asia { background-color: #55ff55;}
    .Africa { background-color: #aa5533;}
    .Oceania { background-color: #ffa000;}
    .bridge { background-color: #a0a0a0;}
    .A { background-color: #ff0000; font-size:12;font-weight:bold;}
    .B { background-color: #00ff00; font-size:12;font-weight:bold;}
    .C { background-color: #0000ff; font-size:12;font-weight:bold;}
    .D { background-color: #ffff00; font-size:12;font-weight:bold;}
    .X { background-color: #808080;}
    </style>
    </head>
    <body>
    ";
    $map_start="<table cellpadding=0 cellspacing=0 border=1 width=100% bgcolor=#ddddff>
    <tr>
    <td>'</td><td>'</td><td>'</td><td>'</td><td>'</td>
    <td class=N_America rowspan=3 colspan=3>";
    $map_land[]=2;
    //<table align=center class="A"><td>11</td></table>
    $map[]="</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td class=Asia rowspan=4 colspan=1>";
    $map_land[]=20;
    //<table align=center class="B"><td>11</td></table>
    $map[]="</td><td class=Asia>";
    $map_land[]=21;
    //<table align=center class="C"><td>11</td></table>
    $map[]="</td><td class=Asia rowspan=3 colspan=1>";
    $map_land[]= 22;
    //<table align=center class=D><td>1</td></table>
    $map[]="</td><td>'</td></tr><tr><td>'</td><td>'</td><td>'</td><td class=N_America rowspan=2 colspan=2>";
    $map_land[]= 1;
    $map[]="</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td class=Asia rowspan=4 colspan=2>";
    $map_land[]= 19;
    $map[]="</td><td class=Asia>";
    $map_land[]= 23;
    $map[]="</td><td>'</td></tr><tr><td class=bridge>-</td><td class=N_America rowspan=2 colspan=2>";
    $map_land[]= 0;
    $map[]="</td><td class=bridge rowspan=2 colspan=1>-</td><td>'</td><td>'</td><td class=Europe rowspan=3 colspan=2>";
    $map_land[]= 13;
    $map[]="</td><td class=Europe rowspan=5 colspan=2>";
    $map_land[]= 14;
    $map[]="</td><td class=Asia rowspan=3 colspan=1>";
    $map_land[]= 24;
    $map[]="</td><td class=bridge>-</td></tr><tr><td>'</td><td class=N_America rowspan=4 colspan=1>";
    $map_land[]= 3;
    $map[]="</td><td class=N_America rowspan=4 colspan=4>";
    $map_land[]= 4;
    $map[]="</td><td class=Europe>";
    $map_land[]= 12;
    $map[]="</td><td class=bridge>-</td><td class=Asia>";
    $map_land[]= 25;
    $map[]="</td><td>'</td></tr><tr><td>'</td><td>'</td><td>'</td><td class=bridge rowspan=1 colspan=2>-</td><td class=Europe rowspan=2 colspan=1>";
    $map_land[]= 15;
    $map[]="</td><td class=Asia rowspan=4 colspan=2>";
    $map_land[]= 29;
    $map[]="</td><td>'</td><td>'</td></tr><tr><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td class=Europe rowspan=2 colspan=2>";
    $map_land[]= 17;
    $map[]="</td><td class=Asia colspan=2 rowspan=2>";
    $map_land[]= 27;
    $map[]="</td><td>'</td><td>'</td></tr><tr><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td class=Europe rowspan=3 colspan=1>";
    $map_land[]= 16;
    $map[]="</td><td>'</td><td>'</td></tr><tr><td>'</td><td>'</td><td>'</td><td class=N_America rowspan=2 colspan=2>";
    $map_land[]= 5;
    $map[]="</td><td class=N_America rowspan=2 colspan=2>";
    $map_land[]= 6;
    $map[]="</td><td>'</td><td>'</td><td>'</td><td class=Europe rowspan=1 colspan=3>";
    $map_land[]= 18;
    $map[]="</td><td class=Asia rowspan=4 colspan=2>";
    $map_land[]= 26;
    $map[]="</td><td class=Asia rowspan=5 colspan=1>";
    $map_land[]= 28;
    $map[]="</td><td>'</td><td>'</td></tr><tr><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td class=bridge>-</td><td>'</td><td class=Asia rowspan=3 colspan=1>";
    $map_land[]= 30;
    $map[]="</td><td>'</td><td>'</td><td>'</td></tr><tr><td>'</td><td>'</td><td>'</td><td>'</td><td class=N_America rowspan=2 colspan=2>";
    $map_land[]= 7;
    $map[]="</td><td>'</td><td>'</td><td>'</td><td>'</td><td class=Africa rowspan=4 colspan=1>";
    $map_land[]= 31;
    $map[]="</td><td class=Africa rowspan=1 colspan=3>";
    $map_land[]= 32;
    $map[]="</td><td>'</td><td>'</td><td>'</td></tr><tr><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td class=Africa rowspan=2 colspan=3>";
    $map_land[]= 33;
    $map[]="</td><td class=bridge>-</td><td>'</td><td>'</td></tr><tr><td>'</td><td>'</td><td>'</td><td>'</td><td class=S_America rowspan=1 colspan=3>";
    $map_land[]= 8;
    $map[]="</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td class=Oceania>";
    $map_land[]= 36;
    $map[]="</td><td class=Oceania>";
    $map_land[]= 37;
    $map[]="</td><td>'</td></tr><tr><td>'</td><td>'</td><td>'</td><td>'</td><td class=S_America rowspan=2 colspan=2>";
    $map_land[]= 10;
    $map[]="</td><td class=S_America rowspan=3 colspan=3>";
    $map_land[]= 9;
    $map[]="</td><td class=bridge>-</td><td class=Africa rowspan=2 colspan=1>";
    $map_land[]= 34;
    $map[]="</td><td class=Africa rowspan=3 colspan=2>";
    $map_land[]= 35;
    $map[]="</td><td>'</td><td>'</td><td>'</td><td>'</td><td class=Oceania rowspan=2 colspan=1>";
    $map_land[]= 38;
    $map[]="</td><td class=Oceania rowspan=2 colspan=1>";
    $map_land[]= 39;
    $map[]="</td><td>'</td></tr><tr><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td></tr><tr><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td class=S_America rowspan=3 colspan=1>";
    $map_land[]= 11;
    $map[]="</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td></tr><tr><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td></tr><tr><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td><td>'</td></tr></table>";

    function print_map($game, $other_data=null){
    global $map_start, $map_land, $map;
    print $map_start;
    foreach($map_land as $i=> $land){
    print $land;
    if(isset($other_data[$land])) print ", $other_data[$land]";
    print "<table border=1 align=center class=".$game->landowners[$land]."><td>".$game->nosoldiers[$land]."</td></table>";
    print $map[$i];
    }
    }

    ?>

    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Contest Code Articles
    More By Codewalkers

    blog comments powered by Disqus

    CONTEST CODE ARTICLES

    - Visual Map Editor And Generator
    - Corridors map generator
    - PHP-JAVA Class Code Generator
    - Risk - print_map($game, $some_array_of_size_...
    - Risk: The Original ShowGame/Map
    - Showgame2
    - Risk map output
    - CTF-Judge, better "auto" controls
    - Capture The Flag -- The JUDGE

    Developer Shed Affiliates

     



    © 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap