Contest Code
  Home arrow Contest Code arrow Risk - print_map($game, $some_array_of_size_40)
IBM Developerworks
The Best Selling PC Migration Utility.
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Dedicated Servers  
Download TestComplete 
IBM® developerWorks
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
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:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Route your faxes to your email inbox. Private, secure fax numbers available from CallWave. Choose your fax number.

    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

     

    IBM® developerWorks developerWorks - FREE Tools!


    NEW! Application Development Tools for the Mainframe Developer

    You probably have thousands of lines of COBOL code loaded with business intelligence and being used to run your business, along with an army of developers maintaining these applications. Learn how to prepare your applications and developers so you can keep that competitive edge and move to a service-oriented architecture with the IBM Rational Enterprise Modernization solutions. Replay is available for 9 months.
    FREE! Go There Now!


    NEW! Building a grid system using WS-Resource Transfer, Part 4: Using WS-RT for grid monitoring

    In this five-part "Building a grid system using WS-Resource Transfer" series, we look at the use of WS-Resource Transfer (WS-RT) in different areas of the grid environment -- from using it as a method for storing and recovering general information about grid-to-grid monitoring and management, and security. We also examine how WS-RT can be used for the distribution and division of work. In any grid, there is a huge amount of metadata about the grid that needs to be stored and distributed. Using WS-RT makes sharing the information, especially the precise information required by different systems in the grid, significantly easier. Here in Part 4, we look at both sides of the security session, both in terms of using WS-RT as an aid to the authorization process and at combining WS-Security with WS-RT for secure resource exchange.
    FREE! Go There Now!


    NEW! Improve your build process with IBM Rational Build Forge, Part 2: Automate builds for a real-world Tomcat project

    Learn how Rational Build Forge can extend a simple compile and package build process by adding customization and deployment capability. Go from a manual method to automating: checking for code changes; getting the latest source; compiling and packaging; customizing; copying to and restarting a deployment server; and sending e-mail notification that a new version is available.
    FREE! Go There Now!


    NEW! Rational Talks to You: Grady Booch on Architecture

    Join this Rational Talks to You teleconference on November 29 at 1:00 pm ET to participate in an interactive discusssion with Grady Booch around architecture and reuse. Get your questions answered!
    FREE! Go There Now!


    NEW! Rational Talks to You: Scott Ambler on being agile in a global development environment

    Join this Rational Talks to You teleconference on December 6 at 1:00 pm ET to participate in an agile application development discussion and get your questions answered on using IBM Rational Method Composer in a distributed environment.Get your questions answered!
    FREE! Go There Now!


    NEW! The IBM DB2 Detective Game

    Here's a fun way to learn about DB2! Learn or teach the basics of DB2 and relational database with an interactive game called The DB2 Detective Game. The game teaches relational database concepts and shows how technology can be applied to solving real-life problems (the game's theme is a crime investigation). This tutorial has been updated for DB2 9.
    FREE! Go There Now!


    NEW! The role of integrated requirements management in software delivery

    This paper is about the critical role that a discipline called integrated require­ments management can play in helping to ensure that your business goals and IT investments are continuously aligned—whether you are sourcing, integrat­ing, building or maintaining software. It also looks at ways that automated IBM Rational® products can work together to help you use requirements in the very best way.
    FREE! Go There Now!


    NEW! Web development with Eclipse Europa, Part 3: Ruby Development Toolkit and RadRails

    It's a good time to be a Web developer. You've never had more choices in terms of technologies. There are so many great open source Web servers, databases, programming languages, and development frameworks. No matter what combination of technologies you prefer to work with, there is a single integrated development environment (IDE) that can increase your productivity: Eclipse. Here in Part 3, we introduce the RDT and RadRails Eclipse plug-ins and show you how to get these plug-ins and start using them. You will learn how to use RadRails to do many common Ruby on Rails development tasks.
    FREE! Go There Now!


    NEW! Webcast: Introducing the new Information Server and Solutions community: LeverageInformation

    User communities play an important role in communication and collaboration around products, solutions and other areas of special interest to members. Successful communities are able to provide the right mix of content and services to deliver a value proposition that resonates with each audience. Join Tom Inman, VP of Marketing for Information and Platform Solutions as he introduces the new LeverageINFORMATION community. During this webcast, learn about the value provided by the community and how customers and partners derive value from the community in addressing their own technical and business challenges.
    FREE! Go There Now!


    NEW! Webcast: Quickly provide customized, integrated user interfaces with Lotus Notes 8

    IBM Lotus Notes 8 provides a wide range of developers the ability to provide customized, integrated user interfaces via composite applications and via custom sidebar and toolbar plug-ins. This webcast provides you with tips and techniques to use with out-of-the-box capabilities of Lotus Notes 8, and survey how you can share useful components within your own company and within a larger community.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    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


     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway